camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1040056 - in /camel/trunk/components/camel-spring-integration/src: main/java/org/apache/camel/component/spring/integration/ main/java/org/apache/camel/component/spring/integration/adapter/ main/java/org/apache/camel/component/spring/integr...
Date Mon, 29 Nov 2010 10:28:32 GMT
Author: davsclaus
Date: Mon Nov 29 10:28:31 2010
New Revision: 1040056

URL: http://svn.apache.org/viewvc?rev=1040056&view=rev
Log:
CAMEL-3377: Improved validation of configured endpoint for spring-integration component.

Added:
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java   (contents, props changed)
      - copied, changed from r1040041, camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdpaterParser.java
Removed:
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationHelper.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdpaterParser.java
Modified:
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationBinding.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationComponent.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationConsumer.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationMessage.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationProducer.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/AbstractCamelAdapter.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapter.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelTargetAdapter.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/AbstractCamelContextBeanDefinitionParaser.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelTargetAdapterParser.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/NamespaceHandler.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java
    camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/HelloWorldService.java
    camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationChannelConverterTest.java
    camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationOneWayConsumerTest.java
    camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationTwoWayConsumerTest.java
    camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml
    camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml
    camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/oneWayConsumer.xml
    camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/producer.xml
    camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/springChannelConverter.xml
    camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/twoWayConsumer.xml

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationBinding.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationBinding.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationBinding.java Mon Nov 29 10:28:31 2010
@@ -21,10 +21,9 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.springframework.integration.message.GenericMessage;
 
-
 /**
- * The helper class for Mapping between the Spring Integration message and
- * the Camel Message
+ * The helper class for Mapping between the Spring Integration message and the Camel Message.
+ *
  * @version $Revision$
  */
 public final class SpringIntegrationBinding {

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationComponent.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationComponent.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationComponent.java Mon Nov 29 10:28:31 2010
@@ -21,8 +21,7 @@ import java.util.Map;
 import org.apache.camel.impl.DefaultComponent;
 
 /**
- * Represents the component that manages {@link SpringIntegrationEndpoint}. It holds the
- * list of named direct endpoints.
+ * Represents the component that manages {@link SpringIntegrationEndpoint}.
  *
  * @version $Revision$
  */

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationConsumer.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationConsumer.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationConsumer.java Mon Nov 29 10:28:31 2010
@@ -17,15 +17,13 @@
 package org.apache.camel.component.spring.integration;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
-import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultConsumer;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.ObjectHelper;
 import org.springframework.integration.channel.BeanFactoryChannelResolver;
 import org.springframework.integration.channel.ChannelResolver;
-import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.channel.SubscribableChannel;
 import org.springframework.integration.core.MessageChannel;
 import org.springframework.integration.message.MessageHandler;
 
@@ -38,42 +36,22 @@ import org.springframework.integration.m
  * @version $Revision$
  */
 public class SpringIntegrationConsumer  extends DefaultConsumer implements MessageHandler {
-    private SpringCamelContext context;
-    private DirectChannel inputChannel;
+    private final SpringCamelContext context;
+    private final ChannelResolver channelResolver;
+    private SubscribableChannel inputChannel;
     private MessageChannel outputChannel;
-    private String inputChannelName;
-    private ChannelResolver channelResolver;
-    private SpringIntegrationEndpoint endpoint;
 
     public SpringIntegrationConsumer(SpringIntegrationEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
-        this.endpoint = endpoint;
-        context = (SpringCamelContext) endpoint.getCamelContext();
-        if (context != null && endpoint.getMessageChannel() == null) {
-            channelResolver = new BeanFactoryChannelResolver(context.getApplicationContext());
-            inputChannelName = endpoint.getDefaultChannel();
-            if (ObjectHelper.isEmpty(inputChannelName)) {
-                inputChannelName = endpoint.getInputChannel();
-            }
-            if (!ObjectHelper.isEmpty(inputChannelName)) {
-                inputChannel = (DirectChannel) channelResolver.resolveChannelName(inputChannelName);
-                ObjectHelper.notNull(inputChannel, "The inputChannel with the name [" + inputChannelName + "]");
-            } else {
-                throw new RuntimeCamelException("Can't find the right inputChannelName, please check your configuration.");
-            }
-        } else {
-            if (endpoint.getMessageChannel() != null) {
-                inputChannel = (DirectChannel)endpoint.getMessageChannel();
-            } else {
-                throw new RuntimeCamelException("Can't find the right message channel, please check your configuration.");
-            }
-        }
-        if (endpoint.isInOut()) {
-            endpoint.setExchangePattern(ExchangePattern.InOut);
-        }
+        this.context = (SpringCamelContext) endpoint.getCamelContext();
+        this.channelResolver = new BeanFactoryChannelResolver(context.getApplicationContext());
+    }
 
+    @Override
+    public SpringIntegrationEndpoint getEndpoint() {
+        return (SpringIntegrationEndpoint) super.getEndpoint();
     }
-    
+
     protected void doStop() throws Exception {
         inputChannel.unsubscribe(this);
         super.doStop();
@@ -81,46 +59,84 @@ public class SpringIntegrationConsumer  
 
     protected void doStart() throws Exception {
         super.doStart();
+
+        if (getEndpoint().getMessageChannel() == null) {
+            String inputChannelName = getEndpoint().getDefaultChannel();
+            if (ObjectHelper.isEmpty(inputChannelName)) {
+                inputChannelName = getEndpoint().getInputChannel();
+            }
+
+            ObjectHelper.notEmpty(inputChannelName, "inputChannelName", getEndpoint());
+            inputChannel = (SubscribableChannel) channelResolver.resolveChannelName(inputChannelName);
+        } else {
+            inputChannel = (SubscribableChannel) getEndpoint().getMessageChannel();
+        }
+
+        if (inputChannel == null) {
+            throw new IllegalArgumentException("Cannot resolve InputChannel on " + getEndpoint());
+        }
+
+        // if we do in-out we need to setup the input channel as well
+        if (getEndpoint().isInOut()) {
+            // we need to setup right inputChannel for further processing
+            ObjectHelper.notEmpty(getEndpoint().getOutputChannel(), "OutputChannel", getEndpoint());
+            outputChannel = channelResolver.resolveChannelName(getEndpoint().getOutputChannel());
+
+            if (outputChannel == null) {
+                throw new IllegalArgumentException("Cannot resolve OutputChannel on " + getEndpoint());
+            }
+        }
+
         inputChannel.subscribe(this);
     }
     
-    public void handleMessage(org.springframework.integration.core.Message<?> siInMessage) {        
-        Exchange  exchange = getEndpoint().createExchange();
+    public void handleMessage(org.springframework.integration.core.Message<?> siInMessage) {
+        // we received a message from spring integration
+        // wrap that in a Camel Exchange and process it
+        Exchange exchange = getEndpoint().createExchange();
         exchange.setIn(new SpringIntegrationMessage(siInMessage));
+
+        // process the exchange
         try {
             getProcessor().process(exchange);
         } catch (Exception e) {
-            //TODO need to find a way to deal with this exception
-            throw ObjectHelper.wrapRuntimeCamelException(e);
+            getExceptionHandler().handleException("Error processing exchange" , exchange, e);
+            return;
         }
-        if (endpoint.isInOut()) {
-            // get the output channel from message header
-            Object returnAddress = siInMessage.getHeaders().getReplyChannel();
+
+        // reply logic
+        if (getEndpoint().isInOut()) {
             MessageChannel reply = null;
 
+            // get the output channel from message header
+            Object returnAddress = siInMessage.getHeaders().getReplyChannel();
             if (returnAddress != null) {
                 if (returnAddress instanceof String) {
-                    reply = (MessageChannel)context.getApplicationContext().getBean((String)returnAddress);
+                    reply = (MessageChannel) context.getApplicationContext().getBean((String)returnAddress);
                 } else if (returnAddress instanceof MessageChannel) {
                     reply = (MessageChannel) returnAddress;
                 }
             } else {
-                if (outputChannel != null) {
-                    // using the outputChannel
-                    reply = outputChannel;
-                } else {
-                    if (ObjectHelper.isEmpty(endpoint.getOutputChannel())) {
-                        outputChannel = (MessageChannel) channelResolver.resolveChannelName(endpoint.getOutputChannel());
-                        ObjectHelper.notNull(inputChannel, "The outputChannel with the name [" + endpoint.getOutputChannel() + "]");
-                        reply = outputChannel;
-                    } else {
-                        throw new RuntimeCamelException("Can't find the right outputChannelName");
-                    }
+                reply = outputChannel;
+
+                // we want to do in-out so the inputChannel is mandatory (used to receive reply from spring integration)
+                if (reply == null) {
+                    throw new IllegalArgumentException("OutputChannel has not been configured on " + getEndpoint());
                 }
             }
+
+            if (reply == null) {
+                throw new IllegalArgumentException("Cannot resolve ReplyChannel from message: " + siInMessage);
+            }
+
             // put the message back the outputChannel if we need
             org.springframework.integration.core.Message siOutMessage =
                 SpringIntegrationBinding.storeToSpringIntegrationMessage(exchange.getOut());
+
+            // send the message to spring integration
+            if (log.isDebugEnabled()) {
+                log.debug("Sending " + siOutMessage + " to ReplyChannel: " + reply);
+            }
             reply.send(siOutMessage);
         }        
     }   

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java Mon Nov 29 10:28:31 2010
@@ -20,15 +20,16 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.impl.ScheduledPollEndpoint;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spring.SpringCamelContext;
 import org.springframework.integration.core.MessageChannel;
 
 /**
- * Defines the <a href="http://camel.apache.org/springIntergration.html">Spring Intergration Endpoint</a>
+ * Defines the <a href="http://camel.apache.org/springIntergration.html">Spring Integration Endpoint</a>
  *
  * @version $Revision$
  */
-public class SpringIntegrationEndpoint extends ScheduledPollEndpoint {
+public class SpringIntegrationEndpoint extends DefaultEndpoint {
     private String inputChannel;
     private String outputChannel;
     private String defaultChannel;
@@ -37,12 +38,12 @@ public class SpringIntegrationEndpoint e
 
     public SpringIntegrationEndpoint(String uri, String channel, SpringIntegrationComponent component) {
         super(uri, component);
-        defaultChannel = channel;
+        this.defaultChannel = channel;
     }
 
     public SpringIntegrationEndpoint(String uri, MessageChannel channel, CamelContext context) {
         super(uri, context);
-        messageChannel = channel;
+        this.messageChannel = channel;
     }
 
     public SpringIntegrationEndpoint(String endpointUri, MessageChannel messageChannel) {
@@ -51,7 +52,7 @@ public class SpringIntegrationEndpoint e
     }
 
     public Producer createProducer() throws Exception {
-        return new SpringIntegrationProducer(this);
+        return new SpringIntegrationProducer((SpringCamelContext) getCamelContext(), this);
     }
 
     public Consumer createConsumer(Processor processor) throws Exception {

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationMessage.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationMessage.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationMessage.java Mon Nov 29 10:28:31 2010
@@ -29,16 +29,15 @@ import org.apache.camel.impl.DefaultMess
 public class SpringIntegrationMessage extends DefaultMessage {
     private org.springframework.integration.core.Message siMessage;
 
-    public SpringIntegrationMessage(org.springframework.integration.core.Message message) {
-        siMessage = message;
-    }
-
     public SpringIntegrationMessage() {
+    }
 
+    public SpringIntegrationMessage(org.springframework.integration.core.Message message) {
+        this.siMessage = message;
     }
 
     public void setMessage(org.springframework.integration.core.Message message) {
-        siMessage = message;
+        this.siMessage = message;
     }
 
     public org.springframework.integration.core.Message getMessage() {

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationProducer.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationProducer.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationProducer.java Mon Nov 29 10:28:31 2010
@@ -17,9 +17,7 @@
 package org.apache.camel.component.spring.integration;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
-import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.ObjectHelper;
@@ -39,59 +37,77 @@ import org.springframework.integration.m
  * @version $Revision$
  */
 public class SpringIntegrationProducer extends DefaultProducer implements Processor {    
-
-    private SpringCamelContext context;
+    private final ChannelResolver channelResolver;
     private DirectChannel inputChannel;
     private MessageChannel outputChannel;
-    private String outputChannelName;
-    private ChannelResolver channelResolver;
-
 
-    public SpringIntegrationProducer(SpringIntegrationEndpoint endpoint) {
+    public SpringIntegrationProducer(SpringCamelContext context, SpringIntegrationEndpoint endpoint) {
         super(endpoint);
-        context = (SpringCamelContext) endpoint.getCamelContext();
-        if (context != null && endpoint.getMessageChannel() == null) {
-            outputChannelName = endpoint.getDefaultChannel();
-            channelResolver = new BeanFactoryChannelResolver(context.getApplicationContext());
-            if (ObjectHelper.isEmpty(outputChannelName)) {
-                outputChannelName = endpoint.getInputChannel();
-            }
+        this.channelResolver = new BeanFactoryChannelResolver(context.getApplicationContext());
+    }
+
+    @Override
+    public SpringIntegrationEndpoint getEndpoint() {
+        return (SpringIntegrationEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        if (getEndpoint().getMessageChannel() == null) {
+            String outputChannelName = getEndpoint().getDefaultChannel();
             if (ObjectHelper.isEmpty(outputChannelName)) {
-                throw new RuntimeCamelException("Cannot find outputChannelName, please check the endpoint uri outputChannel part!");
-            } else {
-                outputChannel = channelResolver.resolveChannelName(outputChannelName);
+                outputChannelName = getEndpoint().getInputChannel();
             }
+
+            ObjectHelper.notEmpty(outputChannelName, "OutputChannelName", getEndpoint());
+            outputChannel = channelResolver.resolveChannelName(outputChannelName);
         } else {
-            if (endpoint.getMessageChannel() != null) {
-                outputChannel = endpoint.getMessageChannel();
-            } else {
-                throw new RuntimeCamelException("Cannot find message channel, please check your configuration.");
-            }
+            outputChannel = getEndpoint().getMessageChannel();
         }
-        if (endpoint.isInOut()) {
-            endpoint.setExchangePattern(ExchangePattern.InOut);
+
+        if (outputChannel == null) {
+            throw new IllegalArgumentException("Cannot resolve OutputChannel on " + getEndpoint());
+        }
+
+        // if we do in-out we need to setup the input channel as well
+        if (getEndpoint().isInOut()) {
             // we need to setup right inputChannel for further processing
-            if (ObjectHelper.isEmpty(endpoint.getInputChannel())) {
-                throw new RuntimeCamelException("Cannot find inputChannel, please check the endpoint uri inputChannel part!");
-            } else {
-                inputChannel = (DirectChannel)channelResolver.resolveChannelName(endpoint.getInputChannel());
+            ObjectHelper.notEmpty(getEndpoint().getInputChannel(), "InputChannel", getEndpoint());
+            inputChannel = (DirectChannel)channelResolver.resolveChannelName(getEndpoint().getInputChannel());
+
+            if (inputChannel == null) {
+                throw new IllegalArgumentException("Cannot resolve InputChannel on " + getEndpoint());
             }
-        } else {
-            endpoint.setExchangePattern(ExchangePattern.InOnly);
         }
     }
 
     public void process(final Exchange exchange) throws Exception {
         if (exchange.getPattern().isOutCapable()) {
+
+            // we want to do in-out so the inputChannel is mandatory (used to receive reply from spring integration)
+            if (inputChannel == null) {
+                throw new IllegalArgumentException("InputChannel has not been configured on " + getEndpoint());
+            }
             exchange.getIn().getHeaders().put(MessageHeaders.REPLY_CHANNEL , inputChannel);
+
+            // subscribe so we can receive the reply from spring integration
             inputChannel.subscribe(new MessageHandler() {
                 public void handleMessage(Message<?> message) {                    
+                    if (log.isDebugEnabled()) {
+                        log.debug("Received " + message + " from InputChannel: " + inputChannel);
+                    }
                     SpringIntegrationBinding.storeToCamelMessage(message, exchange.getOut());
                 }
             });
         }
         org.springframework.integration.core.Message siOutmessage = SpringIntegrationBinding.createSpringIntegrationMessage(exchange);
-        
+
+        // send the message to spring integration
+        if (log.isDebugEnabled()) {
+            log.debug("Sending " + siOutmessage + " to OutputChannel: " + outputChannel);
+        }
         outputChannel.send(siOutmessage);
     }
 

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/AbstractCamelAdapter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/AbstractCamelAdapter.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/AbstractCamelAdapter.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/AbstractCamelAdapter.java Mon Nov 29 10:28:31 2010
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.spring.integration.adapter;
 
 import org.apache.camel.CamelContext;
@@ -53,5 +52,4 @@ public abstract class AbstractCamelAdapt
         return expectReply;
     }
 
-
 }

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapter.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapter.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapter.java Mon Nov 29 10:28:31 2010
@@ -46,8 +46,7 @@ public class CamelSourceAdapter extends 
     private Endpoint camelEndpoint;
     private MessageChannel requestChannel;
     private DirectChannel replyChannel;
-    
-    private AtomicBoolean initialized = new AtomicBoolean();
+    private final AtomicBoolean initialized = new AtomicBoolean();
 
     public void setRequestChannel(MessageChannel channel) {
         requestChannel = channel;        
@@ -62,16 +61,21 @@ public class CamelSourceAdapter extends 
     }
 
     protected class ConsumerProcessor implements Processor {
-
         public void process(final Exchange exchange) throws Exception {
             org.springframework.integration.core.Message request = SpringIntegrationBinding.createSpringIntegrationMessage(exchange);
 
             if (exchange.getPattern().isOutCapable()) {
                 exchange.getIn().getHeaders().put(MessageHeaders.REPLY_CHANNEL , replyChannel);
+
+                // we want to do in-out so the inputChannel is mandatory (used to receive reply from spring integration)
+                if (replyChannel == null) {
+                    throw new IllegalArgumentException("ReplyChannel has not been configured on: " + this);
+                }
+
                 replyChannel.subscribe(new MessageHandler() {
                     public void handleMessage(Message<?> message) {
                         if (LOG.isDebugEnabled()) {
-                            LOG.debug("set the out message with the SI response message");
+                            LOG.debug("Received " + message + " from ReplyChannel: " + replyChannel);
                         }
                         //TODO set the corralationID
                         SpringIntegrationBinding.storeToCamelMessage(message, exchange.getOut());

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelTargetAdapter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelTargetAdapter.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelTargetAdapter.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/CamelTargetAdapter.java Mon Nov 29 10:28:31 2010
@@ -40,9 +40,8 @@ public class CamelTargetAdapter extends 
     private ProducerTemplate camelTemplate;
     private MessageChannel replyChannel;
 
-
     public void setReplyChannel(MessageChannel channel) {
-        replyChannel = channel;
+        this.replyChannel = channel;
     }
 
     public MessageChannel getReplyChannel() {
@@ -53,6 +52,7 @@ public class CamelTargetAdapter extends 
         if (camelTemplate == null) {
             CamelContext ctx = getCamelContext();
             if (ctx == null) {
+                // TODO: This doesnt look good to create a new CamelContext out of the blue
                 ctx = new DefaultCamelContext();
             }
             camelTemplate = ctx.createProducerTemplate();
@@ -61,20 +61,23 @@ public class CamelTargetAdapter extends 
     }
 
     public boolean send(Message<?> message) throws Exception {
-        ExchangePattern pattern;
         boolean result = false;
+
+        ExchangePattern pattern;
         if (isExpectReply()) {
             pattern = ExchangePattern.InOut;
         } else {
             pattern = ExchangePattern.InOnly;
         }
+
         Exchange inExchange = new DefaultExchange(getCamelContext(), pattern);
         SpringIntegrationBinding.storeToCamelMessage(message, inExchange.getIn());
         Exchange outExchange = getCamelTemplate().send(getCamelEndpointUri(), inExchange);
         if (outExchange.getOut() != null && outExchange.getOut().isFault()) {
             result = true;
         }
-        Message response = null;
+
+        Message response;
         if (isExpectReply()) {
             //Check the message header for the return address
             response = SpringIntegrationBinding.storeToSpringIntegrationMessage(outExchange.getOut());
@@ -83,12 +86,13 @@ public class CamelTargetAdapter extends 
                 if (messageReplyChannel != null) {
                     result = messageReplyChannel.send(response);
                 } else {
-                    throw new MessageDeliveryException(response, "Can't find reply channel from the CamelTargetAdapter or MessageHeaders");
+                    throw new MessageDeliveryException(response, "Cannot resolve ReplyChannel from message: " + message);
                 }
             } else {
                 result = replyChannel.send(response);
             }
         }
+
         return result;
     }
 

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/AbstractCamelContextBeanDefinitionParaser.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/AbstractCamelContextBeanDefinitionParaser.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/AbstractCamelContextBeanDefinitionParaser.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/AbstractCamelContextBeanDefinitionParaser.java Mon Nov 29 10:28:31 2010
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.spring.integration.adapter.config;
 
 import org.w3c.dom.Attr;
@@ -31,7 +30,7 @@ import org.springframework.beans.factory
 import org.springframework.util.StringUtils;
 
 /**
- * This BeanDefinition paraser help to inject the camel context into the beans
+ * This BeanDefinition parser help to inject the camel context into the beans
  *
  * @version $Revision$
  */

Copied: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java (from r1040041, camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdpaterParser.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java?p2=camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java&p1=camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdpaterParser.java&r1=1040041&r2=1040056&rev=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdpaterParser.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java Mon Nov 29 10:28:31 2010
@@ -19,13 +19,13 @@ package org.apache.camel.component.sprin
 import org.w3c.dom.Element;
 import org.apache.camel.component.spring.integration.adapter.CamelSourceAdapter;
 
-
 /**
  * Parser for the &lt;camelSource/&gt; element
  *
  * @version $Revision$
  */
-public class CamelSourceAdpaterParser extends AbstractCamelContextBeanDefinitionParaser {
+public class CamelSourceAdapterParser extends AbstractCamelContextBeanDefinitionParaser {
+
     @Override
     protected Class<?> getBeanClass(Element element) {
         return CamelSourceAdapter.class;

Propchange: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelSourceAdapterParser.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelTargetAdapterParser.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelTargetAdapterParser.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelTargetAdapterParser.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/CamelTargetAdapterParser.java Mon Nov 29 10:28:31 2010
@@ -15,17 +15,17 @@
  * limitations under the License.
  */
 package org.apache.camel.component.spring.integration.adapter.config;
+
 import org.w3c.dom.Element;
 import org.apache.camel.component.spring.integration.adapter.CamelTargetAdapter;
 
-
 /**
  * Parser for the &lt;camelTarget/&gt; element
  *
  * @version $Revision$
  */
-
 public class CamelTargetAdapterParser extends AbstractCamelContextBeanDefinitionParaser {
+
     @Override
     protected Class<?> getBeanClass(Element element) {
         return CamelTargetAdapter.class;

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/NamespaceHandler.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/NamespaceHandler.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/adapter/config/NamespaceHandler.java Mon Nov 29 10:28:31 2010
@@ -24,8 +24,9 @@ import org.springframework.beans.factory
  * @version $Revision$
  */
 public class NamespaceHandler extends NamespaceHandlerSupport {
+
     public void init() {
-        registerBeanDefinitionParser("camelSource", new CamelSourceAdpaterParser());
+        registerBeanDefinitionParser("camelSource", new CamelSourceAdapterParser());
         registerBeanDefinitionParser("camelTarget", new CamelTargetAdapterParser());
     }
 }

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java (original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java Mon Nov 29 10:28:31 2010
@@ -37,22 +37,12 @@ public final class SpringIntegrationConv
         // Helper class
     }
 
-    /**
-     * @param Spring Integration MessageChannel
-     * @return an Camel Endpoint
-     * @throws Exception
-     */
     @Converter
     public static Endpoint toEndpoint(final MessageChannel channel) throws Exception {
-        if (channel == null) {
-            throw new IllegalArgumentException("The MessageChannel is null");
-        }
-        Endpoint answer = new SpringIntegrationEndpoint("URL", channel, null);
-        // check the channel
+        Endpoint answer = new SpringIntegrationEndpoint("spring-integration://" + channel.getName(), channel, null);
         return answer;
     }
 
-
     @SuppressWarnings("unchecked")
     @Converter
     public static org.springframework.integration.core.Message toSpringMessage(final org.apache.camel.Message camelMessage) throws Exception {
@@ -74,6 +64,4 @@ public final class SpringIntegrationConv
         return new SpringIntegrationMessage(springMessage);
     }
 
-
-
 }

Modified: camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/HelloWorldService.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/HelloWorldService.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/HelloWorldService.java (original)
+++ camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/HelloWorldService.java Mon Nov 29 10:28:31 2010
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.spring.integration;
 
 /**

Modified: camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationChannelConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationChannelConverterTest.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationChannelConverterTest.java (original)
+++ camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationChannelConverterTest.java Mon Nov 29 10:28:31 2010
@@ -14,13 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.spring.integration;
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-
 public class SpringIntegrationChannelConverterTest extends SpringIntegrationOneWayConsumerTest {
+
     public ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/spring/integration/springChannelConverter.xml");
     }

Modified: camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationOneWayConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationOneWayConsumerTest.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationOneWayConsumerTest.java (original)
+++ camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationOneWayConsumerTest.java Mon Nov 29 10:28:31 2010
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.spring.integration;
 
 import org.apache.camel.component.mock.MockEndpoint;
@@ -24,7 +23,6 @@ import org.springframework.context.suppo
 import org.springframework.integration.core.MessageChannel;
 import org.springframework.integration.message.StringMessage;
 
-
 public class SpringIntegrationOneWayConsumerTest extends CamelSpringTestSupport {
     private static final String MESSAGE_BODY = "hello world";
 
@@ -32,8 +30,10 @@ public class SpringIntegrationOneWayCons
     public void testSendingOneWayMessage() throws Exception {
         MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
         resultEndpoint.expectedBodiesReceived(MESSAGE_BODY);
+
         MessageChannel outputChannel = (MessageChannel) applicationContext.getBean("outputChannel");
         outputChannel.send(new StringMessage(MESSAGE_BODY));
+
         resultEndpoint.assertIsSatisfied();
     }
 
@@ -41,5 +41,4 @@ public class SpringIntegrationOneWayCons
         return new ClassPathXmlApplicationContext("org/apache/camel/component/spring/integration/oneWayConsumer.xml");
     }
 
-
 }

Modified: camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationTwoWayConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationTwoWayConsumerTest.java?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationTwoWayConsumerTest.java (original)
+++ camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/SpringIntegrationTwoWayConsumerTest.java Mon Nov 29 10:28:31 2010
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.spring.integration;
 
 import java.util.HashMap;
@@ -30,17 +29,17 @@ import org.springframework.integration.c
 import org.springframework.integration.message.GenericMessage;
 import org.springframework.integration.message.MessageHandler;
 
-
 public class SpringIntegrationTwoWayConsumerTest extends CamelSpringTestSupport {
     private static final String MESSAGE_BODY = "Request message";    
 
     @Test
     public void testSendingTwoWayMessage() throws Exception {
-        
         MessageChannel requestChannel = (MessageChannel) applicationContext.getBean("requestChannel");
         Map<String, Object> maps = new HashMap<String, Object>();
         maps.put(MessageHeaders.REPLY_CHANNEL, "responseChannel");
+
         Message<String> message = new GenericMessage<String>(MESSAGE_BODY, maps);
+
         DirectChannel responseChannel = (DirectChannel) applicationContext.getBean("responseChannel");
         responseChannel.subscribe(new MessageHandler() {
             public void handleMessage(Message<?> message) {
@@ -48,13 +47,11 @@ public class SpringIntegrationTwoWayCons
                 assertEquals("Get the wrong result", MESSAGE_BODY + " is processed",  result);                
             }             
         });
-        requestChannel.send(message);        
-        
+        requestChannel.send(message);
     }
 
     public ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/spring/integration/twoWayConsumer.xml");
     }
 
-
 }

Modified: camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml (original)
+++ camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml Mon Nov 29 10:28:31 2010
@@ -16,53 +16,53 @@
     limitations under the License.
 -->
 <beans:beans xmlns="http://www.springframework.org/schema/integration"
-       xmlns:beans="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:camel-si="http://camel.apache.org/schema/spring/integration"
-       xsi:schemaLocation="
+             xmlns:beans="http://www.springframework.org/schema/beans"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xmlns:camel-si="http://camel.apache.org/schema/spring/integration"
+             xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
-       http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/spring/integration http://camel.apache.org/schema/spring/integration/camel-spring-integration.xsd
     ">
 
-   	<channel id="channelA"/>
-   	<channel id="channelB"/>
-   	<channel id="channelC"/>
-
-	<service-activator input-channel="channelB"
-	          output-channel="channelC"
-	          ref="helloService"
-	          method="sayHello"/>
-
-   <beans:bean id="helloService" class="org.apache.camel.component.spring.integration.HelloWorldService"/>
-
-   <!-- START SNIPPET: example -->
-   <camelContext id="camelSourceContext" xmlns="http://camel.apache.org/schema/spring">
-       <route>
-           <from uri="direct:OneWay"/>
-           <to uri="direct:EndpointB" />
-       </route>
-       <route>
-       	   <from uri="direct:TwoWay"/>
-           <to uri="direct:EndpointC" />
-       </route>
-   </camelContext>
-
-   <!-- camelSource will redirect the message coming for direct:EndpointB to the spring requestChannel channelA -->
-
-   <camel-si:camelSource id="camelSourceA" camelEndpointUri="direct:EndpointB" requestChannel="channelA" expectReply="false">
-       <camel-si:camelContextRef>camelSourceContext</camel-si:camelContextRef>
-   </camel-si:camelSource>
-
-   <!-- camelSource will redirect the message coming for direct:EndpointC to the spring requestChannel channelB
-    then it will pull the response from channelC and put the response message back to direct:EndpointC -->
-
-   <camel-si:camelSource id="camelSourceB" camelEndpointUri="direct:EndpointC" requestChannel="channelB" replyChannel="channelC" expectReply="true">
-       <camel-si:camelContextRef>camelSourceContext</camel-si:camelContextRef>
-   </camel-si:camelSource>
-   <!-- END SNIPPET: example -->
+    <!-- START SNIPPET: example -->
+    <!-- spring integration channels -->
+    <channel id="channelA"/>
+    <channel id="channelB"/>
+    <channel id="channelC"/>
+
+    <!-- spring integration service activator -->
+    <service-activator input-channel="channelB" output-channel="channelC" ref="helloService" method="sayHello"/>
+
+    <!-- custom bean -->
+    <beans:bean id="helloService" class="org.apache.camel.component.spring.integration.HelloWorldService"/>
+
+    <camelContext id="camelSourceContext" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:OneWay"/>
+            <to uri="direct:EndpointB"/>
+        </route>
+        <route>
+            <from uri="direct:TwoWay"/>
+            <to uri="direct:EndpointC"/>
+        </route>
+    </camelContext>
+
+    <!-- camelSource will redirect the message coming for direct:EndpointB to the spring requestChannel channelA -->
+    <camel-si:camelSource id="camelSourceA" camelEndpointUri="direct:EndpointB"
+                          requestChannel="channelA" expectReply="false">
+        <camel-si:camelContextRef>camelSourceContext</camel-si:camelContextRef>
+    </camel-si:camelSource>
+
+    <!-- camelSource will redirect the message coming for direct:EndpointC to the spring requestChannel channelB
+         then it will pull the response from channelC and put the response message back to direct:EndpointC -->
+
+    <camel-si:camelSource id="camelSourceB" camelEndpointUri="direct:EndpointC"
+                          requestChannel="channelB" replyChannel="channelC" expectReply="true">
+        <camel-si:camelContextRef>camelSourceContext</camel-si:camelContextRef>
+    </camel-si:camelSource>
+    <!-- END SNIPPET: example -->
 
 </beans:beans>
 

Modified: camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml (original)
+++ camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml Mon Nov 29 10:28:31 2010
@@ -31,11 +31,13 @@
        http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
  <!-- END SNIPPET: header -->
-  
+
+    <!-- spring integration channels -->
     <outbound-channel-adapter id="channelA" ref="camelTargetA"/>
    	<outbound-channel-adapter id="channelB" ref="camelTargetB"/>
     <channel id="channelC"/>
     <outbound-channel-adapter id="channelD" ref="camelTargetD"/>
+
    <!-- START SNIPPET: example -->
    <!-- Create the camel context here -->
    <camelContext id="camelTargetContext" xmlns="http://camel.apache.org/schema/spring">

Modified: camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/oneWayConsumer.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/oneWayConsumer.xml?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/oneWayConsumer.xml (original)
+++ camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/oneWayConsumer.xml Mon Nov 29 10:28:31 2010
@@ -16,22 +16,23 @@
     limitations under the License.
 -->
 <beans:beans xmlns="http://www.springframework.org/schema/integration"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:beans="http://www.springframework.org/schema/beans"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xmlns:beans="http://www.springframework.org/schema/beans"
+             xsi:schemaLocation="http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans/spring-beans.xsd
 			http://www.springframework.org/schema/integration
 			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
 			http://camel.apache.org/schema/spring
 			http://camel.apache.org/schema/spring/camel-spring.xsd">
-	
+
+    <!-- spring integration channel -->
     <channel id="outputChannel"/>
 
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-      <route>
-        <!-- Using the &amp; as the separator of & -->
-        <from uri="spring-integration://outputChannel"/>
-        <to uri="mock:result"/>
-      </route>
+        <route>
+            <from uri="spring-integration://outputChannel"/>
+            <to uri="mock:result"/>
+        </route>
     </camelContext>
+
 </beans:beans>

Modified: camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/producer.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/producer.xml?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/producer.xml (original)
+++ camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/producer.xml Mon Nov 29 10:28:31 2010
@@ -17,40 +17,38 @@
 -->
 <!-- START SNIPPET: example -->
 <beans:beans xmlns="http://www.springframework.org/schema/integration"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:beans="http://www.springframework.org/schema/beans"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xmlns:beans="http://www.springframework.org/schema/beans"
+             xsi:schemaLocation="http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans/spring-beans.xsd
 			http://www.springframework.org/schema/integration
 			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
 			http://camel.apache.org/schema/spring
 			http://camel.apache.org/schema/spring/camel-spring.xsd">
-	
-	<channel id="inputChannel"/>
-   	<channel id="outputChannel"/>
-   	<channel id="onewayChannel"/>
 
-	<service-activator input-channel="inputChannel"	          
-	          ref="helloService"
-	          method="sayHello"/>
-	          	      
-	<service-activator input-channel="onewayChannel"	          
-	          ref="helloService"
-	          method="greet"/>
-	          
-	<beans:bean id="helloService" class="org.apache.camel.component.spring.integration.HelloWorldService"/>
-    
+    <!-- spring integration channels -->
+    <channel id="inputChannel"/>
+    <channel id="outputChannel"/>
+    <channel id="onewayChannel"/>
+
+    <!-- spring integration service activators -->
+    <service-activator input-channel="inputChannel" ref="helloService" method="sayHello"/>
+    <service-activator input-channel="onewayChannel" ref="helloService" method="greet"/>
+
+    <!-- custom bean -->
+    <beans:bean id="helloService" class="org.apache.camel.component.spring.integration.HelloWorldService"/>
+
     <!-- START SNIPPET: example -->
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-      <route>
-        <from uri="direct:twowayMessage"/>
-        <!-- Using the &amp; as the separator of & -->
-        <to uri="spring-integration:inputChannel?inOut=true&amp;inputChannel=outputChannel"/>
-      </route>
-      <route>      
-        <from uri="direct:onewayMessage"/>
-        <to uri="spring-integration:onewayChannel?inOut=false"/>
-      </route>
+        <route>
+            <from uri="direct:twowayMessage"/>
+            <to uri="spring-integration:inputChannel?inOut=true&amp;inputChannel=outputChannel"/>
+        </route>
+        <route>
+            <from uri="direct:onewayMessage"/>
+            <to uri="spring-integration:onewayChannel?inOut=false"/>
+        </route>
     </camelContext>
     <!-- END SNIPPET: example -->
+
 </beans:beans>

Modified: camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/springChannelConverter.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/springChannelConverter.xml?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/springChannelConverter.xml (original)
+++ camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/springChannelConverter.xml Mon Nov 29 10:28:31 2010
@@ -17,23 +17,25 @@
 -->
 <!-- START SNIPPET: example -->
 <beans:beans xmlns="http://www.springframework.org/schema/integration"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:beans="http://www.springframework.org/schema/beans"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xmlns:beans="http://www.springframework.org/schema/beans"
+             xsi:schemaLocation="http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans/spring-beans.xsd
 			http://www.springframework.org/schema/integration
 			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
 			http://camel.apache.org/schema/spring
 			http://camel.apache.org/schema/spring/camel-spring.xsd">
+
     <!-- START SNIPPET: example -->
-	<channel id="outputChannel"/>
+    <!-- spring integration channel -->
+    <channel id="outputChannel"/>
 
-    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-      <route>
-        <!-- camel will create a spring integration endpoint automatically -->
-        <from uri="outputChannel"/>
-        <to uri="mock:result"/>
-      </route>
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="outputChannel"/>
+            <to uri="mock:result"/>
+        </route>
     </camelContext>
     <!-- END SNIPPET: example -->
+
 </beans:beans>

Modified: camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/twoWayConsumer.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/twoWayConsumer.xml?rev=1040056&r1=1040055&r2=1040056&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/twoWayConsumer.xml (original)
+++ camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/twoWayConsumer.xml Mon Nov 29 10:28:31 2010
@@ -17,27 +17,31 @@
 -->
 
 <beans:beans xmlns="http://www.springframework.org/schema/integration"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:beans="http://www.springframework.org/schema/beans"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xmlns:beans="http://www.springframework.org/schema/beans"
+             xsi:schemaLocation="http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans/spring-beans.xsd
 			http://www.springframework.org/schema/integration
 			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
 			http://camel.apache.org/schema/spring
 			http://camel.apache.org/schema/spring/camel-spring.xsd">
-    <!-- START SNIPPET: example -->	
+
+    <!-- START SNIPPET: example -->
+    <!-- spring integration channels -->
     <channel id="requestChannel"/>
     <channel id="responseChannel"/>
 
+    <!-- cusom Camel processor -->
     <beans:bean id="myProcessor" class="org.apache.camel.component.spring.integration.MyProcessor"/>
 
-    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-      <route>
-        <!-- Using the &amp; as the separator of & -->
-        <from uri="spring-integration://requestChannel?outputChannel=responseChannel&amp;inOut=true"/>
-        <process ref="myProcessor"/>
-      </route>
+    <!-- Camel route -->
+    <camelContext  xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="spring-integration://requestChannel?outputChannel=responseChannel&amp;inOut=true"/>
+            <process ref="myProcessor"/>
+        </route>
     </camelContext>
     <!-- END SNIPPET: example -->
+
 </beans:beans>
 



Mime
View raw message