diff options
author | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-06 16:45:57 +0000 |
---|---|---|
committer | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-06 16:45:57 +0000 |
commit | 70a68422b6a3ea7a211c46d802307571e98a8a31 (patch) | |
tree | b0f14712576a383740c7938436b52e4d79d4a6a9 /sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConsumerImpl.java | |
parent | 374f54d3f32e33e59ae74e7d2f4a48c2d6e4f86a (diff) |
Changes to enable consumers and producers to be connected via binding.sca
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711904 13f79535-47bb-0310-9956-ffa450edef68
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.java | 41 |
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 |