summaryrefslogtreecommitdiffstats
path: root/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java')
-rw-r--r--sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java
index b2bf9f5059..cd8cc9c961 100644
--- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java
+++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java
@@ -20,6 +20,10 @@ package org.apache.tuscany.sca.assembly.impl;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Map.Entry;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
@@ -38,6 +42,7 @@ public class ConsumerImpl extends ContractImpl implements Consumer {
private String name;
private String theOperationName;
+ private Map< String, String > operations = new HashMap< String, String >();
private EventTypes theEventTypes = new EventTypesImpl();
private ArrayList<Binding> bindings = new ArrayList<Binding>();
private ArrayList<EventSource> sourceList = new ArrayList<EventSource>();
@@ -73,6 +78,42 @@ public class ConsumerImpl extends ContractImpl implements Consumer {
return theEventTypes;
} // end getEventType
+ // Operation related methods...
+ /**
+ * Adds an operation to the Consumer, with a list of the accepted event types
+ */
+ public void addOperation( String operationName, String eventTypes ) {
+ operations.put(operationName, eventTypes);
+ } // end addOperation
+
+ /**
+ * Returns the set of operations for this consumer
+ */
+ public Set<String> getOperations() {
+ return operations.keySet();
+ } // add operation
+
+ /**
+ * Gets the name of the operation which handles a specific event type.
+ * Returns null if no operation handles the specified event type.
+ * eventType = null implies "handles any event type"
+ */
+ public String getOperationByEventType( String eventType ) {
+ String anyOperation = null;
+ for( Entry<String, String> entry : operations.entrySet() ) {
+ String value = entry.getValue();
+ if( value == null ) {
+ if( eventType == null ) return entry.getKey();
+ // If the operation is marked as handling "any" event type, use this UNLESS there is another
+ // operation which specifically takes the requested event type...
+ anyOperation = entry.getKey();
+ } else if( eventType != null ){
+ if (value.contains(eventType)) return entry.getKey();
+ } // end if
+ } //
+ return anyOperation;
+ } // end getOperationByEventType
+
public void setOperationName( String operationName ) {
theOperationName = operationName;
} // end setOperationName