servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r394227 [1/3] - in /incubator/servicemix/trunk: ./ servicemix-assembly/ servicemix-common/src/main/java/org/apache/servicemix/common/ servicemix-core/src/main/java/org/apache/servicemix/ servicemix-core/src/main/java/org/apache/servicemix/e...
Date Fri, 14 Apr 2006 23:38:46 GMT
Author: gnodet
Date: Fri Apr 14 16:38:22 2006
New Revision: 394227

URL: http://svn.apache.org/viewcvs?rev=394227&view=rev
Log:
SM-401: Create a new servicemix-eip component for standard Enterprise Integration Patterns
This includes a number of enhancements:
  * servicemix-common derived components can send stateless jms clustered messages
  * Store / StoreFactory interfaces define a clusterable / persistent kind of maps (need to add transactions)
  * Add boolean / nodeset support on jaxp expressions

Added:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/Store.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/StoreFactory.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/ExchangeCompletedListener.java
    incubator/servicemix/trunk/servicemix-eip/   (with props)
    incubator/servicemix/trunk/servicemix-eip/maven.xml
    incubator/servicemix/trunk/servicemix-eip/project.properties
    incubator/servicemix/trunk/servicemix-eip/project.xml
    incubator/servicemix/trunk/servicemix-eip/src/
    incubator/servicemix/trunk/servicemix-eip/src/main/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPBootstrap.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPComponent.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPDeployer.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPEndpoint.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPLifeCycle.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPSpringComponent.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/StaticRecipientList.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/StaticRoutingSlip.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/WireTap.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/XPathSplitter.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/AbstractSplitter.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/ExchangeTarget.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/MessageUtil.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/Predicate.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/RoutingRule.java
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/support/XPathPredicate.java
    incubator/servicemix/trunk/servicemix-eip/src/main/resources/
    incubator/servicemix/trunk/servicemix-eip/src/main/resources/org/
    incubator/servicemix/trunk/servicemix-eip/src/main/resources/org/apache/
    incubator/servicemix/trunk/servicemix-eip/src/main/resources/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-eip/src/main/resources/org/apache/servicemix/eip/
    incubator/servicemix/trunk/servicemix-eip/src/test/
    incubator/servicemix/trunk/servicemix-eip/src/test/java/
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/AbstractEIPTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/ContentBasedRouterTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/PipelineTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/SpringConfigurationTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/StaticRecipientListTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/StaticRoutingSlipTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/VMEIPTests.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/WireTapJmsFlowTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/WireTapTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/java/org/apache/servicemix/eip/XPathSplitterTest.java
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/log4j-tests.properties
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/log4j.properties
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/
    incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml
Modified:
    incubator/servicemix/trunk/project.properties
    incubator/servicemix/trunk/servicemix-assembly/project.xml
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/JbiConstants.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/JMSFlow.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/config/SpringConfigTest.java

Modified: incubator/servicemix/trunk/project.properties
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/project.properties?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/project.properties (original)
+++ incubator/servicemix/trunk/project.properties Fri Apr 14 16:38:22 2006
@@ -93,6 +93,7 @@
   servicemix-lwcontainer/project.xml,\
   servicemix-bpe/project.xml,\
   servicemix-wsn2005/project.xml,\
+  servicemix-eip/project.xml,\
   servicemix-assembly/project.xml,\
   tooling/maven-eclipse-plugin-plugin/project.xml,\
   tooling/servicemix-packaging-descriptors/project.xml,\

Modified: incubator/servicemix/trunk/servicemix-assembly/project.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/project.xml?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/project.xml (original)
+++ incubator/servicemix/trunk/servicemix-assembly/project.xml Fri Apr 14 16:38:22 2006
@@ -154,6 +154,16 @@
     </dependency>
     <dependency>
       <groupId>${pom.groupId}</groupId>
+      <artifactId>servicemix-eip</artifactId>
+      <version>${pom.currentVersion}</version>
+      <type>zip</type>
+      <properties>
+        <eclipse.dependency>true</eclipse.dependency>
+        <component>true</component>
+      </properties>
+    </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
       <artifactId>servicemix-gbean</artifactId>
       <version>${pom.currentVersion}</version>
       <properties>

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java Fri Apr 14 16:38:22 2006
@@ -35,6 +35,7 @@
 import javax.transaction.TransactionManager;
 
 import org.apache.commons.logging.Log;
+import org.apache.servicemix.JbiConstants;
 
 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
@@ -373,7 +374,16 @@
             }
             processor.process(exchange);
         } else {
-            ExchangeProcessor processor = (ExchangeProcessor) processors.remove(exchange.getExchangeId());
+            ExchangeProcessor processor = null;
+            if (exchange.getProperty(JbiConstants.SENDER_ENDPOINT) != null) {
+                String key = exchange.getProperty(JbiConstants.SENDER_ENDPOINT).toString();
+                Endpoint ep = (Endpoint) this.component.getRegistry().getEndpoint(key);
+                if (ep != null) {
+                    processor = ep.getProcessor();
+                }
+            } else {
+                processor = (ExchangeProcessor) processors.remove(exchange.getExchangeId());
+            }
             if (processor == null) {
                 throw new IllegalStateException("No processor found for: " + exchange.getExchangeId());
             }
@@ -381,11 +391,31 @@
         }
     }
 
+    /**
+     * 
+     * @param exchange
+     * @param processor
+     * @throws MessagingException
+     * @deprecated use sendConsumerExchange(MessageExchange, Endpoint) instead
+     */
     public void sendConsumerExchange(MessageExchange exchange, ExchangeProcessor processor) throws MessagingException {
-        // If this is a DONE status, no answer is expected
-        if (exchange.getStatus() != ExchangeStatus.DONE) {
+        // If the exchange is not ACTIVE, no answer is expected
+        if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
             processors.put(exchange.getExchangeId(), processor);
         }
+        channel.send(exchange);
+    }
+    
+    /**
+     * This method allows the component to keep no state in memory so that
+     * components can be clustered and provide fail-over and load-balancing.
+     * @param exchange
+     * @param endpoint
+     * @throws MessagingException
+     */
+    public void sendConsumerExchange(MessageExchange exchange, Endpoint endpoint) throws MessagingException {
+        String key = EndpointSupport.getKey(endpoint);
+        exchange.setProperty(JbiConstants.SENDER_ENDPOINT, key);
         channel.send(exchange);
     }
 

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java Fri Apr 14 16:38:22 2006
@@ -18,17 +18,11 @@
 import javax.jbi.servicedesc.ServiceEndpoint;
 import javax.xml.namespace.QName;
 
+
 public class EndpointSupport {
 
     public static String getKey(QName service, String endpoint) {
-        StringBuffer sb = new StringBuffer();
-        sb.append("{");
-        sb.append(service.getNamespaceURI());
-        sb.append("}");
-        sb.append(service.getLocalPart());
-        sb.append(":");
-        sb.append(endpoint);
-        return sb.toString();
+        return org.apache.servicemix.jbi.servicedesc.EndpointSupport.getKey(service, endpoint);
     }
     
     public static String getKey(ServiceEndpoint endpoint) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/JbiConstants.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/JbiConstants.java?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/JbiConstants.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/JbiConstants.java Fri Apr 14 16:38:22 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.servicemix;
 
+
 public interface JbiConstants {
 
     String SEND_SYNC = "javax.jbi.messaging.sendSync";
@@ -36,5 +37,7 @@
     String STATELESS_CONSUMER = "org.apache.servicemix.consumer.stateless";
     
     String STATELESS_PROVIDER = "org.apache.servicemix.provider.stateless";
+    
+    String SENDER_ENDPOINT = "org.apache.servicemix.senderEndpoint";
     
 }

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.expression;
+
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+
+/**
+ * Evaluates an XPath expression and coerces the result into a String.
+ *
+ * @version $Revision: 359151 $
+ */
+public class JAXPBooleanXPathExpression extends JAXPXPathExpression {
+
+    public JAXPBooleanXPathExpression() {
+    }
+
+    public JAXPBooleanXPathExpression(String xpath) throws Exception {
+        super(xpath);
+    }
+
+    public Object evaluateXPath(Object object) throws XPathExpressionException {
+        return getXPathExpression().evaluate(object, XPathConstants.BOOLEAN);
+    }
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.expression;
+
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+
+/**
+ * Evaluates an XPath expression and coerces the result into a String.
+ *
+ * @version $Revision: 359151 $
+ */
+public class JAXPNodeSetXPathExpression extends JAXPXPathExpression {
+
+    public JAXPNodeSetXPathExpression() {
+    }
+
+    public JAXPNodeSetXPathExpression(String xpath) throws Exception {
+        super(xpath);
+    }
+
+    public Object evaluateXPath(Object object) throws XPathExpressionException {
+        return getXPathExpression().evaluate(object, XPathConstants.NODESET);
+    }
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java Fri Apr 14 16:38:22 2006
@@ -72,6 +72,7 @@
 import org.apache.servicemix.jbi.messaging.MessageExchangeImpl;
 import org.apache.servicemix.jbi.nmr.Broker;
 import org.apache.servicemix.jbi.nmr.flow.AbstractFlow;
+import org.apache.servicemix.jbi.servicedesc.EndpointSupport;
 import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
 import org.jencks.JCAConnector;
 import org.jencks.SingletonEndpointFactory;
@@ -422,7 +423,7 @@
             return;
         }
         try {
-            String key = event.getEndpoint().getServiceName() + event.getEndpoint().getEndpointName();
+            String key = EndpointSupport.getKey(event.getEndpoint());
             if(!connectorMap.containsKey(key)){
                 ActiveMQActivationSpec ac = new ActiveMQActivationSpec();
                 ac.setDestinationType("javax.jms.Queue");
@@ -447,7 +448,7 @@
     
     public void onInternalEndpointUnregistered(EndpointEvent event, boolean broadcast) {
         try{
-            String key = event.getEndpoint().getServiceName() + event.getEndpoint().getEndpointName();
+            String key = EndpointSupport.getKey(event.getEndpoint());
             JCAConnector connector=(JCAConnector) connectorMap.remove(key);
             if(connector!=null){
                 connector.destroy();
@@ -529,7 +530,7 @@
             String destination;
             if (me.getRole() == Role.PROVIDER) {
                 if (me.getDestinationId() == null) {
-                    destination = INBOUND_PREFIX + me.getEndpoint().getServiceName() + me.getEndpoint().getEndpointName();
+                    destination = INBOUND_PREFIX + EndpointSupport.getKey(me.getEndpoint());
                 } else if (Boolean.TRUE.equals(me.getProperty(JbiConstants.STATELESS_PROVIDER)) && !isSynchronous(me)) {
                     destination = INBOUND_PREFIX + me.getDestinationId().getName();
                 } else {
@@ -539,7 +540,15 @@
                 if (me.getSourceId() == null) {
                     throw new IllegalStateException("No sourceId set on the exchange");
                 } else if (Boolean.TRUE.equals(me.getProperty(JbiConstants.STATELESS_CONSUMER)) && !isSynchronous(me)) {
-                    destination = INBOUND_PREFIX + me.getSourceId().getName();
+                    // If the consumer is stateless and has specified a sender endpoint,
+                    // this exchange will be sent to the given endpoint queue, so that
+                    // This property must have been created using EndpointSupport.getKey
+                    // fail-over and load-balancing can be achieved
+                    if (me.getProperty(JbiConstants.SENDER_ENDPOINT) != null) {
+                        destination = INBOUND_PREFIX + me.getProperty(JbiConstants.SENDER_ENDPOINT);
+                    } else {
+                        destination = INBOUND_PREFIX + me.getSourceId().getName();
+                    }
                 } else {
                     destination = INBOUND_PREFIX + me.getSourceId().getContainerName();
                 }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/JMSFlow.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/JMSFlow.java?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/JMSFlow.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/JMSFlow.java Fri Apr 14 16:38:22 2006
@@ -58,6 +58,7 @@
 import org.apache.servicemix.jbi.messaging.MessageExchangeImpl;
 import org.apache.servicemix.jbi.nmr.Broker;
 import org.apache.servicemix.jbi.nmr.flow.AbstractFlow;
+import org.apache.servicemix.jbi.servicedesc.EndpointSupport;
 import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
 
 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
@@ -376,7 +377,7 @@
             return;
         }
         try {
-            String key = event.getEndpoint().getServiceName() + event.getEndpoint().getEndpointName();
+            String key = EndpointSupport.getKey(event.getEndpoint());
             if (!consumerMap.containsKey(key)) {
                 Queue queue = inboundSession.createQueue(INBOUND_PREFIX + key);
                 MessageConsumer consumer = inboundSession.createConsumer(queue);
@@ -395,7 +396,7 @@
 
     public void onInternalEndpointUnregistered(EndpointEvent event, boolean broadcast) {
         try {
-            String key = event.getEndpoint().getServiceName() + event.getEndpoint().getEndpointName();
+            String key = EndpointSupport.getKey(event.getEndpoint());
             MessageConsumer consumer = (MessageConsumer) consumerMap.remove(key);
             if (consumer != null) {
                 consumer.close();
@@ -471,7 +472,7 @@
             String destination;
             if (me.getRole() == Role.PROVIDER) {
                 if (me.getDestinationId() == null) {
-                    destination = INBOUND_PREFIX + me.getEndpoint().getServiceName() + me.getEndpoint().getEndpointName();
+                    destination = INBOUND_PREFIX + EndpointSupport.getKey(me.getEndpoint());
                 } else if (Boolean.TRUE.equals(me.getProperty(JbiConstants.STATELESS_PROVIDER)) && !isSynchronous(me)) {
                     destination = INBOUND_PREFIX + me.getDestinationId().getName();
                 } else {
@@ -481,7 +482,15 @@
                 if (me.getSourceId() == null) {
                     throw new IllegalStateException("No sourceId set on the exchange");
                 } else if (Boolean.TRUE.equals(me.getProperty(JbiConstants.STATELESS_CONSUMER)) && !isSynchronous(me)) {
-                    destination = INBOUND_PREFIX + me.getSourceId().getName();
+                    // If the consumer is stateless and has specified a sender endpoint,
+                    // this exchange will be sent to the given endpoint queue, so that
+                    // fail-over and load-balancing can be achieved
+                    // This property must have been created using EndpointSupport.getKey
+                    if (me.getProperty(JbiConstants.SENDER_ENDPOINT) != null) {
+                        destination = INBOUND_PREFIX + me.getProperty(JbiConstants.SENDER_ENDPOINT);
+                    } else {
+                        destination = INBOUND_PREFIX + me.getSourceId().getName();
+                    }
                 } else {
                     destination = INBOUND_PREFIX + me.getSourceId().getContainerName();
                 }

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.servicedesc;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.namespace.QName;
+
+
+public class EndpointSupport {
+
+    public static String getKey(QName service, String endpoint) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("{");
+        sb.append(service.getNamespaceURI());
+        sb.append("}");
+        sb.append(service.getLocalPart());
+        sb.append(":");
+        sb.append(endpoint);
+        return sb.toString();
+    }
+    
+    public static String getKey(ServiceEndpoint endpoint) {
+        return getKey(endpoint.getServiceName(), endpoint.getEndpointName());
+    }
+    
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/Store.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/Store.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/Store.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/Store.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.store;
+
+import java.io.IOException;
+
+public interface Store {
+
+    String PERSISTENT = "Persistent";
+    
+    String CLUSTERED = "Clustered";
+    
+    public boolean hasFeature(String name);
+    
+    public void store(String id, Object data) throws IOException;
+    
+    public String store(Object data) throws IOException;
+    
+    public Object load(String id) throws IOException;
+    
+    public void remove(String id) throws IOException;
+    
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/StoreFactory.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/StoreFactory.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/StoreFactory.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/StoreFactory.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.store;
+
+import java.io.IOException;
+
+public interface StoreFactory {
+
+    public Store get(String name) throws IOException;
+    
+    public void release(Store store) throws IOException;
+    
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.store.memory;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.activemq.util.IdGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.store.Store;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
+public class MemoryStore implements Store {
+    
+    private static final Log log = LogFactory.getLog(MemoryStore.class);
+
+    private Map datas = new ConcurrentHashMap();
+    private IdGenerator idGenerator;
+    
+    public MemoryStore(IdGenerator idGenerator) {
+        this.idGenerator = idGenerator;
+    }
+    
+    public boolean hasFeature(String name) {
+        return false;
+    }
+
+    public void store(String id, Object data) throws IOException {
+        log.debug("Storing object with id: " + id);
+        datas.put(id, data);
+    }
+    
+    public String store(Object data) throws IOException {
+        String id = idGenerator.generateId();
+        datas.put(id, data);
+        return id;
+    }
+
+    public Object load(String id) throws IOException {
+        log.debug("Loading object with id: " + id);
+        return datas.get(id);
+    }
+    
+    public void remove(String id) throws IOException {
+        datas.remove(id);
+    }
+
+    
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.store.memory;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.util.IdGenerator;
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+
+public class MemoryStoreFactory implements StoreFactory {
+
+    private IdGenerator idGenerator = new IdGenerator();
+    private Map stores = new HashMap();
+    
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.store.ExchangeStoreFactory#get(java.lang.String)
+     */
+    public synchronized Store get(String name) throws IOException {
+        MemoryStore store = (MemoryStore) stores.get(name);
+        if (store == null) {
+            store = new MemoryStore(idGenerator);
+            stores.put(name, store);
+        }
+        return store;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.store.ExchangeStoreFactory#release(org.apache.servicemix.store.ExchangeStore)
+     */
+    public synchronized void release(Store store) throws IOException {
+        stores.remove(store);
+    }
+    
+
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/ExchangeCompletedListener.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/ExchangeCompletedListener.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/ExchangeCompletedListener.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/ExchangeCompletedListener.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.tck;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+
+import junit.framework.Assert;
+
+import org.apache.servicemix.jbi.event.ExchangeEvent;
+import org.apache.servicemix.jbi.event.ExchangeListener;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
+public class ExchangeCompletedListener extends Assert implements ExchangeListener {
+
+    private Map exchanges = new ConcurrentHashMap();
+    
+    public void exchangeSent(ExchangeEvent event) {
+        exchanges.put(event.getExchange().getExchangeId(), event.getExchange());
+    }
+    
+    public void assertExchangeCompleted() throws Exception {
+        Thread.sleep(50);
+        for (Iterator it = exchanges.values().iterator(); it.hasNext();) {
+            MessageExchange me = (MessageExchange) it.next();
+            assertTrue("Exchange is ACTIVE", me.getStatus() != ExchangeStatus.ACTIVE);
+        }
+    }
+
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/config/SpringConfigTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/config/SpringConfigTest.java?rev=394227&r1=394226&r2=394227&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/config/SpringConfigTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/config/SpringConfigTest.java Fri Apr 14 16:38:22 2006
@@ -1,20 +1,18 @@
-/** 
- * 
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- * 
- * Licensed 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
- * 
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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. 
- * 
- **/
+ * 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.servicemix.jbi.config;
 
 import org.apache.servicemix.examples.AbstractSpringTestSupport;

Propchange: incubator/servicemix/trunk/servicemix-eip/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 14 16:38:22 2006
@@ -0,0 +1,3 @@
+target
+.classpath
+.project

Added: incubator/servicemix/trunk/servicemix-eip/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/maven.xml?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/maven.xml (added)
+++ incubator/servicemix/trunk/servicemix-eip/maven.xml Fri Apr 14 16:38:22 2006
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+
+    Copyright 2005 The Apache Software Foundation
+
+    Licensed 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.
+    
+-->
+
+<project default="default"
+    xmlns:ant="jelly:ant"
+    xmlns:artifact="artifact">
+
+  <postGoal name="java:compile">
+    <attainGoal name="xbean:generate" />
+  </postGoal>
+         
+  <goal name="xbean:generate" description="Generates the XBean XSD, documentation and META-INF/services files.">
+    <path id="test.classpath">
+      <pathelement path="${maven.build.dest}" />
+      <pathelement path="${basedir}/target/classes" />
+      <pathelement path="${basedir}/target/test-classes" />
+      <path refid="maven.dependency.classpath" />
+    </path>
+
+    <taskdef name="xsdGenerate" classname="org.apache.xbean.spring.generator.MappingGeneratorTask">
+      <classpath refid="test.classpath" />
+    </taskdef>
+    <xsdGenerate
+    destFile="${basedir}/target/servicemix-eip-${pom.currentVersion}.xsd" namespace="http://servicemix.apache.org/eip/1.0"
+    		classpathref="test.classpath" srcdir="${basedir}/src/main/java"  metaInfDir="${basedir}/target/generated/"/>
+  	<copy file="${basedir}/target/servicemix-eip-${pom.currentVersion}.xsd" todir="${basedir}/target/generated/"/>
+  	<copy file="${basedir}/target/servicemix-eip-${pom.currentVersion}.xsd" todir="${basedir}/../xdocs"/>    
+    <copy file="${basedir}/target/servicemix-eip-${pom.currentVersion}.xsd.html" todir="${basedir}/../xdocs"/>
+  </goal>
+
+</project>

Added: incubator/servicemix/trunk/servicemix-eip/project.properties
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/project.properties?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/project.properties (added)
+++ incubator/servicemix/trunk/servicemix-eip/project.properties Fri Apr 14 16:38:22 2006
@@ -0,0 +1,28 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2004 The Apache Software Foundation.
+# 
+# Licensed 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.
+# -------------------------------------------------------------------
+# $Rev: 356022 $ $Date: 2005-12-11 12:58:34 -0800 (dim., 11 déc. 2005) $
+# -------------------------------------------------------------------
+# P R O J E C T  P R O P E R T I E S
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jbi
+
+jbi.component.class.name = org.apache.servicemix.eip.EIPComponent
+jbi.bootstrap.class.name = org.apache.servicemix.eip.EIPBootstrap
+jbi.component.type=service-engine
+
+org.apache.commons.attributes.enable=true
+org.apache.commons.attributes.index.enable=true

Added: incubator/servicemix/trunk/servicemix-eip/project.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/project.xml?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/project.xml (added)
+++ incubator/servicemix/trunk/servicemix-eip/project.xml Fri Apr 14 16:38:22 2006
@@ -0,0 +1,333 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+
+    Copyright 2005 The Apache Software Foundation
+
+    Licensed 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.
+    
+-->
+
+<!DOCTYPE project>
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>${basedir}/../etc/project.xml</extend>
+
+    <name>ServiceMix :: EIP Service Engine</name>
+    <id>servicemix-eip</id>
+    <shortDescription>EIP service engine</shortDescription>
+    <description>EIP service engine</description>
+  
+    <package>org.apache.servicemix.eip</package>
+    <packageGroups>
+      <packageGroup>
+        <title>EIP service engine</title>
+        <packages>org.apache.servicemix.eip</packages>
+      </packageGroup>
+    </packageGroups>
+ 
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+    <dependencies>
+    
+      <dependency>
+        <groupId>${pom.groupId}</groupId>
+        <artifactId>maven-jbi-plugin</artifactId>
+        <version>${pom.currentVersion}</version>
+        <type>plugin</type>
+      </dependency>
+    
+      <!-- JBI bundled dependencies -->
+      <dependency>
+        <groupId>${pom.groupId}</groupId>
+        <artifactId>servicemix-common</artifactId>
+        <version>${pom.currentVersion}</version>
+        <properties>
+          <eclipse.dependency>true</eclipse.dependency>
+          <jbi.bundle>true</jbi.bundle>
+          <jbi.bootstrap>true</jbi.bootstrap>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>${commons_logging_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>backport-util-concurrent</groupId>
+        <artifactId>backport-util-concurrent</artifactId>
+        <version>${backport_util_concurrent_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>wsdl4j</groupId>
+        <artifactId>wsdl4j</artifactId>
+        <version>${wsdl4j_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.xfire</groupId>
+        <artifactId>xfire-all</artifactId>
+        <version>${xfire_version}</version>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>stax</groupId>
+        <artifactId>stax-api</artifactId>
+        <version>${stax_api_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>jdom</groupId>
+        <artifactId>jdom</artifactId>
+        <version>${jdom_version}</version>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-spring</artifactId>
+        <version>${xbean_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-server</artifactId>
+        <version>${xbean_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-kernel</artifactId>
+        <version>${xbean_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>springframework</groupId>
+        <artifactId>spring</artifactId>
+        <version>${spring_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>woodstox</groupId>
+        <artifactId>wstx-asl</artifactId>
+        <version>${woodstox_version}</version>
+        <properties>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>xmlbeans</groupId>
+        <artifactId>xbean</artifactId>
+        <version>${xmlbeans_version}</version>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      
+      <!-- Commons attribute -->
+      <dependency>
+        <groupId>commons-attributes</groupId>
+        <artifactId>commons-attributes-api</artifactId>
+        <version>${commons_attributes_version}</version>
+        <url>http://jakarta.apache.org/commons/attributes/</url>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>commons-attributes</groupId>
+        <artifactId>commons-attributes-plugin</artifactId>
+        <version>${commons_attributes_version}</version>
+        <type>plugin</type>
+        <url>http://jakarta.apache.org/commons/attributes/</url>
+      </dependency>
+      
+      <!-- Backport 175 -->
+      <dependency>
+        <groupId>backport175</groupId>
+        <artifactId>backport175</artifactId>
+        <version>${backport175_version}</version>
+        <url>http://backport175.codehaus.org</url>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      
+      <!--  JAXB -->
+      <dependency>
+        <groupId>servicemix</groupId>
+        <artifactId>jaxb-api</artifactId>
+        <version>${jaxb_version}</version>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      
+      <!-- Provided dependencies -->
+      <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+        <version>${geronimo_spec_j2ee_connector_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
+        <version>${geronimo_spec_jta_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>${pom.groupId}</groupId>
+        <artifactId>servicemix-jbi</artifactId>
+        <version>${pom.currentVersion}</version>
+        <properties>
+          <eclipse.dependency>true</eclipse.dependency>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>mx4j</groupId>
+        <artifactId>mx4j</artifactId>
+        <version>${mx4j_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>mx4j</groupId>
+        <artifactId>mx4j-remote</artifactId>
+        <version>${mx4j_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.ws.commons</groupId>
+        <artifactId>XmlSchema</artifactId>
+        <version>${xmlschema_version}</version>
+      </dependency>
+
+      <!-- Testing only -->
+      <dependency>
+        <groupId>${pom.groupId}</groupId>
+        <artifactId>servicemix-core</artifactId>
+        <version>${pom.currentVersion}</version>
+        <properties>
+          <eclipse.dependency>true</eclipse.dependency>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>${pom.groupId}</groupId>
+        <artifactId>servicemix-components</artifactId>
+        <version>${pom.currentVersion}</version>
+        <properties>
+          <eclipse.dependency>true</eclipse.dependency>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>incubator-activemq</groupId>
+        <artifactId>activemq-core</artifactId>
+        <version>${activemq_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>incubator-activemq</groupId>
+        <artifactId>activeio-core</artifactId>
+        <version>${activeio_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>servicemix</groupId>
+        <artifactId>stax-utils</artifactId>
+        <version>${stax_utils_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>jencks</groupId>
+        <artifactId>jencks-all</artifactId>
+        <version>${jencks_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>concurrent</groupId>
+        <artifactId>concurrent</artifactId>
+        <version>${concurrent_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-beanutils</groupId>
+        <artifactId>commons-beanutils</artifactId>
+        <version>${commons_beanutils_version}</version>
+      </dependency>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j_version}</version>
+      </dependency>
+      <dependency>
+	    <groupId>org.apache.geronimo.specs</groupId>
+	    <artifactId>geronimo-activation_1.0.2_spec</artifactId>
+	    <version>${geronimo_spec_activation_version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>annogen</groupId>
+        <artifactId>annogen</artifactId>
+        <version>${annogen_version}</version>
+        <properties>
+          <scope>compile</scope>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>qdox</groupId>
+        <artifactId>qdox</artifactId>
+        <version>${qdox_version}</version>
+        <properties>
+          <scope>compile</scope>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>beehive</groupId>
+        <artifactId>wsm</artifactId>
+        <version>${beehive_wsm_version}</version>
+        <url>http://incubator.apache.org/beehive/</url>
+      </dependency>
+    </dependencies>  
+
+    <build>
+        <unitTest>
+            <includes>
+                <include>**/*Test.*</include>
+            </includes>
+            <excludes>
+            </excludes>
+        </unitTest>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                    <include>**/*.xml</include>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>target/generated</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+    
+</project>

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPBootstrap.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPBootstrap.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPBootstrap.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPBootstrap.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip;
+
+import org.apache.servicemix.common.BaseBootstrap;
+
+/**
+ * @author gnodet
+ * @version $Revision: 376451 $
+ */
+public class EIPBootstrap extends BaseBootstrap {
+
+}

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPComponent.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPComponent.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip;
+
+import org.apache.servicemix.common.BaseComponent;
+
+/**
+ * @author gnodet
+ * @version $Revision: 376451 $
+ */
+public class EIPComponent extends BaseComponent {
+
+}

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPDeployer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPDeployer.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPDeployer.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPDeployer.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip;
+
+import javax.jbi.management.DeploymentException;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.xbean.AbstractXBeanDeployer;
+
+/**
+ * @author gnodet
+ * @version $Revision: 376451 $
+ */
+public class EIPDeployer extends AbstractXBeanDeployer {
+
+    public EIPDeployer(BaseComponent component) {
+        super(component);
+    }
+
+    protected boolean validate(Endpoint endpoint) throws DeploymentException {
+        if (endpoint instanceof EIPEndpoint == false) {
+            throw new DeploymentException("Endpoint should be an EIPEndpoint");
+        }
+        ((EIPEndpoint) endpoint).validate();
+        return true;
+    }
+}

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPEndpoint.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPEndpoint.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPEndpoint.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+import org.apache.servicemix.store.memory.MemoryStoreFactory;
+
+/**
+ * @author gnodet
+ * @version $Revision: 376451 $
+ */
+public abstract class EIPEndpoint extends Endpoint implements ExchangeProcessor {
+
+    private ServiceEndpoint activated;
+    private DeliveryChannel channel;
+    
+    /**
+     * The store to keep pending exchanges
+     */
+    protected Store store;
+    /**
+     * The store factory.
+     */
+    protected StoreFactory storeFactory;
+    /**
+     * The exchange factory
+     */
+    protected MessageExchangeFactory exchangeFactory;
+    
+    /**
+     * @return Returns the exchangeFactory.
+     */
+    public MessageExchangeFactory getExchangeFactory() {
+        return exchangeFactory;
+    }
+    /**
+     * @param exchangeFactory The exchangeFactory to set.
+     */
+    public void setExchangeFactory(MessageExchangeFactory exchangeFactory) {
+        this.exchangeFactory = exchangeFactory;
+    }
+    /**
+     * @return Returns the store.
+     */
+    public Store getStore() {
+        return store;
+    }
+    /**
+     * @param store The store to set.
+     */
+    public void setStore(Store store) {
+        this.store = store;
+    }
+    /**
+     * @return Returns the storeFactory.
+     */
+    public StoreFactory getStoreFactory() {
+        return storeFactory;
+    }
+    /**
+     * @param storeFactory The storeFactory to set.
+     */
+    public void setStoreFactory(StoreFactory storeFactory) {
+        this.storeFactory = storeFactory;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.common.Endpoint#getRole()
+     */
+    public Role getRole() {
+        return Role.PROVIDER;
+    }
+
+    public void activate() throws Exception {
+        logger = this.serviceUnit.getComponent().getLogger();
+        ComponentContext ctx = getContext();
+        channel = ctx.getDeliveryChannel();
+        exchangeFactory = channel.createExchangeFactory();
+        activated = ctx.activateEndpoint(service, endpoint);
+        if (store == null) {
+            if (storeFactory == null) {
+                storeFactory = new MemoryStoreFactory();
+            }
+            store = storeFactory.get(getService().toString() + getEndpoint());
+        }
+        start();
+    }
+
+    public void deactivate() throws Exception {
+        stop();
+        ServiceEndpoint ep = activated;
+        activated = null;
+        ComponentContext ctx = getServiceUnit().getComponent().getComponentContext();
+        ctx.deactivateEndpoint(ep);
+    }
+
+    public ExchangeProcessor getProcessor() {
+        return this;
+    }
+    
+    public void validate() throws DeploymentException {
+    }
+    
+    protected ComponentContext getContext() {
+        return getServiceUnit().getComponent().getComponentContext();
+    }
+    
+    protected void send(MessageExchange me) throws MessagingException {
+        if (me.getRole() == MessageExchange.Role.CONSUMER &&
+            me.getStatus() == ExchangeStatus.ACTIVE) {
+            BaseLifeCycle lf = (BaseLifeCycle) getServiceUnit().getComponent().getLifeCycle();
+            lf.sendConsumerExchange(me, (Endpoint) this);
+        } else {
+            channel.send(me);
+        }
+    }
+    
+    protected void done(MessageExchange me) throws MessagingException {
+        me.setStatus(ExchangeStatus.DONE);
+        send(me);
+    }
+    
+    protected void fail(MessageExchange me, Exception error) throws MessagingException {
+        me.setError(error);
+        send(me);
+    }
+    
+    public void start() throws Exception {
+    }
+    
+    public void stop() {
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPLifeCycle.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPLifeCycle.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPLifeCycle.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+
+/**
+ * @author gnodet
+ * @version $Revision: 376451 $
+ */
+public class EIPLifeCycle extends BaseLifeCycle {
+
+    public EIPLifeCycle(BaseComponent component) {
+        super(component);
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPSpringComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPSpringComponent.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPSpringComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPSpringComponent.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.xbean.XBeanServiceUnit;
+
+/**
+ * 
+ * @author gnodet
+ * @version $Revision: 376451 $
+ * @org.apache.xbean.XBean element="component"
+ *                  description="An EIP component"
+ */
+public class EIPSpringComponent extends BaseComponent {
+
+    private EIPEndpoint[] endpoints;
+
+    /**
+     * @return Returns the endpoints.
+     */
+    public EIPEndpoint[] getEndpoints() {
+        return endpoints;
+    }
+
+    /**
+     * @param endpoints The endpoints to set.
+     */
+    public void setEndpoints(EIPEndpoint[] endpoints) {
+        this.endpoints = endpoints;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.servicemix.common.BaseComponent#createLifeCycle()
+     */
+    protected BaseLifeCycle createLifeCycle() {
+        return new LifeCycle();
+    }
+
+    /**
+     * @author gnodet
+     */
+    public class LifeCycle extends EIPLifeCycle {
+
+        protected ServiceUnit su;
+        
+        public LifeCycle() {
+            super(EIPSpringComponent.this);
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doInit()
+         */
+        protected void doInit() throws Exception {
+            super.doInit();
+            su = new XBeanServiceUnit();
+            su.setComponent(EIPSpringComponent.this);
+            for (int i = 0; i < endpoints.length; i++) {
+                endpoints[i].setServiceUnit(su);
+                endpoints[i].validate();
+                su.addEndpoint(endpoints[i]);
+            }
+            getRegistry().registerServiceUnit(su);
+        }
+
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doStart()
+         */
+        protected void doStart() throws Exception {
+            super.doStart();
+            su.start();
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doStop()
+         */
+        protected void doStop() throws Exception {
+            su.stop();
+            super.doStop();
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doShutDown()
+         */
+        protected void doShutDown() throws Exception {
+            su.shutDown();
+            super.doShutDown();
+        }
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java?rev=394227&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java (added)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java Fri Apr 14 16:38:22 2006
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.eip.patterns;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.JbiConstants;
+import org.apache.servicemix.eip.EIPEndpoint;
+import org.apache.servicemix.eip.support.ExchangeTarget;
+import org.apache.servicemix.eip.support.MessageUtil;
+import org.apache.servicemix.eip.support.RoutingRule;
+import org.apache.servicemix.store.Store;
+
+/**
+ * ContentBasedRouter can be used for all kind of content-based routing.
+ * This component implements the  
+ * <a href="http://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html">Content-Based Router</a> 
+ * pattern.
+ * 
+ * @author gnodet
+ * @version $Revision: 376451 $
+ * @org.apache.xbean.XBean element="content-based-router"
+ *                  description="A Content-Based Router"
+ */
+public class ContentBasedRouter extends EIPEndpoint {
+
+    private static final Log log = LogFactory.getLog(WireTap.class);
+    
+    
+    /**
+     * Routing rules that are evaluated to find the target destination
+     */
+    private RoutingRule[] rules;
+    /**
+     * The correlation property used by this component
+     */
+    private String correlation;
+    
+    /**
+     * @return Returns the rules.
+     */
+    public RoutingRule[] getRules() {
+        return rules;
+    }
+
+    /**
+     * @param rules The rules to set.
+     */
+    public void setRules(RoutingRule[] rules) {
+        this.rules = rules;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.eip.EIPEndpoint#validate()
+     */
+    public void validate() throws DeploymentException {
+        super.validate();
+        // Check rules
+        if (rules == null || rules.length == 0) {
+            throw new IllegalArgumentException("rules should contain at least one RoutingRule");
+        }
+        // Create correlation property
+        correlation = "AbstractContentBasedRouter.Correlation." + getService() + "." + getEndpoint();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.common.ExchangeProcessor#process(javax.jbi.messaging.MessageExchange)
+     */
+    public void process(MessageExchange exchange) throws MessagingException {
+        try {
+            if (exchange.getRole() == MessageExchange.Role.PROVIDER &&
+                exchange.getProperty(correlation) == null) {
+                // Retrieve target
+                ExchangeTarget target = getDestination(exchange);
+                // Create exchange for target
+                MessageExchange tme = exchangeFactory.createExchange(exchange.getPattern());
+                if (store.hasFeature(Store.CLUSTERED)) {
+                    exchange.setProperty(JbiConstants.STATELESS_PROVIDER, Boolean.TRUE);
+                    tme.setProperty(JbiConstants.STATELESS_CONSUMER, Boolean.TRUE);
+                }
+                target.configureTarget(tme, getContext());
+                // Set correlations
+                exchange.setProperty(correlation, tme.getExchangeId());
+                tme.setProperty(correlation, exchange.getExchangeId());
+                // Put exchange to store
+                store.store(exchange.getExchangeId(), exchange);
+                // Send in to listener and target
+                MessageUtil.transferTo(exchange, tme, "in"); 
+                send(tme);
+            // Mimic the exchange on the other side and send to needed listener
+            } else {
+                String id = (String) exchange.getProperty(correlation);
+                if (id == null) {
+                    throw new IllegalStateException(correlation + " property not found");
+                }
+                MessageExchange org = (MessageExchange) store.load(id);
+                if (org == null) {
+                    throw new IllegalStateException("Could not load original exchange with id " + id);
+                }
+                // Reproduce DONE status to the other side
+                if (exchange.getStatus() == ExchangeStatus.DONE) {
+                    done(org);
+                // Reproduce ERROR status to the other side
+                } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+                    fail(org, exchange.getError());
+                // Reproduce faults to the other side and listeners
+                } else if (exchange.getFault() != null) {
+                    store.store(exchange.getExchangeId(), exchange);
+                    MessageUtil.transferTo(exchange, org, "fault"); 
+                    send(org);
+                // Reproduce answers to the other side
+                } else if (exchange.getMessage("out") != null) {
+                    store.store(exchange.getExchangeId(), exchange);
+                    MessageUtil.transferTo(exchange, org, "out"); 
+                    send(org);
+                } else {
+                    throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE + " but has no Out nor Fault message");
+                }
+            }
+        // If an error occurs, log it and report the error back to the sender
+        // if the exchange is still ACTIVE 
+        } catch (Exception e) {
+            log.error("An exception occured while processing exchange", e);
+            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+                fail(exchange, e);
+            }
+        }
+    }
+    
+    /**
+     * Find the target destination for the given JBI exchange
+     * @param exchange
+     * @return the target for the given exchange
+     * @throws Exception
+     */
+    protected ExchangeTarget getDestination(MessageExchange exchange) throws Exception {
+        for (int i = 0; i < rules.length; i++) {
+            if (rules[i].getPredicate() == null ||
+                rules[i].getPredicate().matches(exchange)) {
+                return rules[i].getTarget();
+            }
+        }
+        throw new MessagingException("No matching rule found for exchange");
+    }
+
+}



Mime
View raw message