summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event')
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java89
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java54
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java53
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java53
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java52
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java53
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java52
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java45
-rw-r--r--tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java45
9 files changed, 496 insertions, 0 deletions
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java
new file mode 100644
index 0000000000..517e5579a4
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.sca.event.Event;
+import org.apache.tuscany.sca.event.EventFilter;
+import org.apache.tuscany.sca.event.EventPublisher;
+import org.apache.tuscany.sca.event.RuntimeEventListener;
+import org.apache.tuscany.sca.event.TrueFilter;
+
+/**
+ * Base implementation of an <code>EventPublisher</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseEventPublisher implements EventPublisher {
+ protected static final EventFilter TRUE_FILTER = new TrueFilter();
+ protected Map<EventFilter, List<RuntimeEventListener>> listeners;
+
+ public void addListener(RuntimeEventListener listener) {
+ addListener(TRUE_FILTER, listener);
+ }
+
+ public void removeListener(RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ for (List<RuntimeEventListener> currentList : getListeners().values()) {
+ for (RuntimeEventListener current : currentList) {
+ if (current == listener) {
+ currentList.remove(current);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ List<RuntimeEventListener> list = getListeners().get(filter);
+ if (list == null) {
+ list = new CopyOnWriteArrayList<RuntimeEventListener>();
+ listeners.put(filter, list);
+ }
+ list.add(listener);
+ }
+ }
+
+ public void publish(Event event) {
+ assert event != null : "Event object was null";
+ for (Map.Entry<EventFilter, List<RuntimeEventListener>> entry : getListeners().entrySet()) {
+ if (entry.getKey().match(event)) {
+ for (RuntimeEventListener listener : entry.getValue()) {
+ listener.onEvent(event);
+ }
+ }
+ }
+ }
+
+ protected Map<EventFilter, List<RuntimeEventListener>> getListeners() {
+ if (listeners == null) {
+ listeners = new ConcurrentHashMap<EventFilter, List<RuntimeEventListener>>();
+ }
+ return listeners;
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java
new file mode 100644
index 0000000000..45eab7da1b
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.event.Event;
+
+/**
+ * Propagated when a component starts
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentStart implements Event {
+
+ private Object source;
+ private URI uri;
+
+ /**
+ * Creates a component start event
+ *
+ * @param source the source of the event
+ * @param componentURI the URI of the component being started
+ */
+ public ComponentStart(Object source, URI componentURI) {
+ this.source = source;
+ this.uri = componentURI;
+ }
+
+ public URI getComponentURI() {
+ return uri;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java
new file mode 100644
index 0000000000..4dc79c3844
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.event.Event;
+
+/**
+ * Propagated when a component stops
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentStop implements Event {
+
+ private Object source;
+ private URI uri;
+
+ /**
+ * Creates a component stop event
+ *
+ * @param source the source of the event
+ * @param componentUri the composite component associated the component being stopped
+ */
+ public ComponentStop(Object source, URI componentUri) {
+ this.source = source;
+ this.uri = componentUri;
+ }
+
+ public URI getComponentURI() {
+ return uri;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java
new file mode 100644
index 0000000000..d3106c7052
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import org.apache.tuscany.sca.event.Event;
+
+
+
+/**
+ * Propagated when a conversation is expired
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConversationEnd implements Event {
+
+ private Object source;
+ private Object id;
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the conversation being ended
+ */
+ public ConversationEnd(Object source, Object id) {
+ this.source = source;
+ this.id = id;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ public Object getConversationID() {
+ return id;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java
new file mode 100644
index 0000000000..123400fbdd
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import org.apache.tuscany.sca.event.Event;
+
+
+/**
+ * Propagated when a conversation has started
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConversationStart implements Event {
+
+ private Object source;
+ private Object id;
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the conversation being started
+ */
+ public ConversationStart(Object source, Object id) {
+ this.source = source;
+ this.id = id;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ public Object getConversationID() {
+ return id;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java
new file mode 100644
index 0000000000..68cb5c2966
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import org.apache.tuscany.sca.event.Event;
+
+
+
+/**
+ * Propagated when an HTTP-based session is expired
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpSessionEnd implements Event {
+
+ private Object source;
+ private Object id;
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the HTTP session being ended
+ */
+ public HttpSessionEnd(Object source, Object id) {
+ this.source = source;
+ this.id = id;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ public Object getSessionID() {
+ return id;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java
new file mode 100644
index 0000000000..38a4fb10d6
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import org.apache.tuscany.sca.event.Event;
+
+
+/**
+ * Propagated when an HTTP-based session has started
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpSessionStart implements Event {
+
+ private Object source;
+ private Object id;
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the HTTP session being started
+ */
+ public HttpSessionStart(Object source, Object id) {
+ this.source = source;
+ this.id = id;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ public Object getSessionID() {
+ return id;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java
new file mode 100644
index 0000000000..d7e797bbb9
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import org.apache.tuscany.sca.event.Event;
+
+/**
+ * Propagated when a request completes or is ended
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestEnd implements Event {
+
+ private Object source;
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ */
+ public RequestEnd(Object source) {
+ this.source = source;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java
new file mode 100644
index 0000000000..7530156b11
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.event;
+
+import org.apache.tuscany.sca.event.Event;
+
+/**
+ * Propagated when a request is started in the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestStart implements Event {
+
+ private Object source;
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ */
+ public RequestStart(Object source) {
+ this.source = source;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+}