servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r655747 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src: main/java/org/apache/servicemix/camel/ test/java/org/apache/servicemix/camel/ test/java/org/apache/servicemix/camel/su7/ test/resources/o...
Date Tue, 13 May 2008 06:19:52 GMT
Author: ffang
Date: Mon May 12 23:19:52 2008
New Revision: 655747

URL: http://svn.apache.org/viewvc?rev=655747&view=rev
Log:
[SM-1111] apply patch on behalf of Willem Jiang and Kristian Koehler

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java
  (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java
  (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
  (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteTest.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java?rev=655747&r1=655746&r2=655747&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java
Mon May 12 23:19:52 2008
@@ -16,6 +16,9 @@
  */
 package org.apache.servicemix.camel;
 
+import java.net.URISyntaxException;
+import java.util.Map;
+
 import org.apache.camel.Consumer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -23,21 +26,29 @@
 import org.apache.camel.impl.DefaultConsumer;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.URISupport;
 
 /**
  * Represents an {@link org.apache.camel.Endpoint} for interacting with JBI
- * 
+ *
  * @version $Revision: 563665 $
  */
 public class JbiEndpoint extends DefaultEndpoint<Exchange> {
     private Processor toJbiProcessor;
 
+    private String destinationUri;
+
+    private String mep;
+
+    private String operation;
+
     private final CamelJbiComponent jbiComponent;
 
     public JbiEndpoint(CamelJbiComponent jbiComponent, String uri) {
         super(uri, jbiComponent);
         this.jbiComponent = jbiComponent;
-        toJbiProcessor = new ToJbiProcessor(jbiComponent.getBinding(), jbiComponent.getComponentContext(),
uri);
+        parseUri(uri);
+        toJbiProcessor = new ToJbiProcessor(jbiComponent.getBinding(), jbiComponent.getComponentContext(),
this);
     }
 
     public Producer<Exchange> createProducer() throws Exception {
@@ -48,6 +59,48 @@
         };
     }
 
+    private void parseUri(String uri) {
+        destinationUri = uri;
+        try {
+            int idx = destinationUri.indexOf('?');
+            if (idx > 0) {
+                Map params = URISupport.parseQuery(destinationUri.substring(idx + 1));
+                mep = (String) params.get("mep");
+                if (mep != null && !mep.startsWith("http://www.w3.org/ns/wsdl/"))
{
+                    mep = "http://www.w3.org/ns/wsdl/" + mep;
+                }
+                operation = (String) params.get("operation");
+                this.destinationUri = destinationUri.substring(0, idx);
+            }
+        } catch (URISyntaxException e) {
+            throw new JbiException(e);
+        }
+    }
+
+    public void setMep(String str) {
+        mep = str;
+    }
+
+    public void setOperation(String str) {
+        operation = str;
+    }
+
+    public void setDestionationUri(String str) {
+        destinationUri = str;
+    }
+
+    public String getMep() {
+        return mep;
+    }
+
+    public String getOperation() {
+        return operation;
+    }
+
+    public String getDestinationUri() {
+        return destinationUri;
+    }
+
     public Consumer<Exchange> createConsumer(final Processor processor) throws Exception
{
         return new DefaultConsumer<Exchange>(this, processor) {
             CamelJbiEndpoint jbiEndpoint;

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java?rev=655747&r1=655746&r2=655747&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
Mon May 12 23:19:52 2008
@@ -17,7 +17,6 @@
 package org.apache.servicemix.camel;
 
 import java.net.URISyntaxException;
-import java.util.Map;
 import java.util.Set;
 
 import javax.jbi.component.ComponentContext;
@@ -32,7 +31,6 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
-import org.apache.camel.util.URISupport;
 import org.apache.servicemix.jbi.resolver.URIResolver;
 
 /**
@@ -47,30 +45,12 @@
 
     private ComponentContext componentContext;
 
-    private String destinationUri;
+    private JbiEndpoint jbiEndpoint;
 
-    private String mep;
-
-    private String operation;
-
-    public ToJbiProcessor(JbiBinding binding, ComponentContext componentContext, String destinationUri)
{
+    public ToJbiProcessor(JbiBinding binding, ComponentContext componentContext, JbiEndpoint
endpoint) {
         this.binding = binding;
         this.componentContext = componentContext;
-        this.destinationUri = destinationUri;
-        try {
-            int idx = destinationUri.indexOf('?');
-            if (idx > 0) {
-                Map params = URISupport.parseQuery(destinationUri.substring(idx + 1));
-                mep = (String) params.get("mep");
-                if (mep != null && !mep.startsWith("http://www.w3.org/ns/wsdl/"))
{
-                    mep = "http://www.w3.org/ns/wsdl/" + mep;
-                }
-                operation = (String) params.get("operation");
-                this.destinationUri = destinationUri.substring(0, idx);
-            }
-        } catch (URISyntaxException e) {
-            throw new JbiException(e);
-        }
+        jbiEndpoint = endpoint;
     }
 
     private void addHeaders(MessageExchange messageExchange, Exchange camelExchange) {
@@ -93,13 +73,13 @@
         try {
             DeliveryChannel deliveryChannel = componentContext.getDeliveryChannel();
             MessageExchangeFactory exchangeFactory = deliveryChannel.createExchangeFactory();
-            MessageExchange messageExchange = binding.makeJbiMessageExchange(exchange, exchangeFactory,
mep);
+            MessageExchange messageExchange = binding.makeJbiMessageExchange(exchange, exchangeFactory,
jbiEndpoint.getMep());
 
-            if (operation != null) {
-                messageExchange.setOperation(QName.valueOf(operation));
+            if (jbiEndpoint.getOperation() != null) {
+                messageExchange.setOperation(QName.valueOf(jbiEndpoint.getOperation()));
             }
 
-            URIResolver.configureExchange(messageExchange, componentContext, destinationUri);
+            URIResolver.configureExchange(messageExchange, componentContext, jbiEndpoint.getDestinationUri());
             deliveryChannel.sendSync(messageExchange);
 
             if (messageExchange.getStatus() == ExchangeStatus.ERROR) {

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java?rev=655747&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java
(added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java
Mon May 12 23:19:52 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.camel;
+
+import javax.jbi.messaging.MessageExchange;
+
+/**
+ * @version $Revision$
+ */
+public class JavaCamelRouteDslTest extends JbiInOutTest {
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        suName = "su7";
+    }
+
+    @Override
+    protected void checkResult(MessageExchange exchange) {
+        assertNotNull(exchange.getMessage("out"));
+        assertNotNull(exchange.getMessage("out").getProperty("operation"));
+        assertEquals(exchange.getMessage("out").getProperty("operation").toString(), "{http://test}echo");
+    }
+}
\ No newline at end of file

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteDslTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteTest.java?rev=655747&r1=655746&r2=655747&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JavaCamelRouteTest.java
Mon May 12 23:19:52 2008
@@ -35,5 +35,6 @@
     protected void checkResult(MessageExchange exchange) {
         assertNotNull(exchange.getMessage("out"));
         assertNotNull(exchange.getMessage("out").getProperty("operation"));
+        assertEquals(exchange.getMessage("out").getProperty("operation").toString(), "{http://hello}echo");
     }
 }
\ No newline at end of file

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java?rev=655747&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java
(added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java
Mon May 12 23:19:52 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.camel.su7;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.servicemix.camel.JbiEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class MyRouter extends RouteBuilder {
+    String toUri = "jbi:service:namespace:echo?mep=in-out";
+
+    public void configure() throws Exception {
+        // Set the operation from Camel DSL
+        org.apache.camel.Endpoint endpoint = getContext().getEndpoint(toUri);
+        if (endpoint instanceof JbiEndpoint) {
+            JbiEndpoint jbiEndpoint = (JbiEndpoint) endpoint;
+            jbiEndpoint.setOperation("{http://test}echo");
+        }
+
+        from("jbi:name:cheese").to(toUri);
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/su7/MyRouter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml?rev=655747&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
(added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
Mon May 12 23:19:52 2008
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<!-- START SNIPPET: camel -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+    <package>org.apache.servicemix.camel.su7</package>
+  </camelContext>
+
+</beans>
+<!-- END SNIPPET: camel -->

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su7-src/camel-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message