servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r405365 - in /incubator/servicemix/trunk/servicemix-jms/src: main/java/org/apache/servicemix/jms/ main/java/org/apache/servicemix/jms/multiplexing/ test/java/org/apache/servicemix/jms/
Date Tue, 09 May 2006 09:59:00 GMT
Author: gnodet
Date: Tue May  9 02:58:57 2006
New Revision: 405365

URL: http://svn.apache.org/viewcvs?rev=405365&view=rev
Log:
Add support for URI properties for dynamic jms provider endpoint.
Syntax is:
   jms://{queue|topic}/destinationName[?query]
Ex:
   jms://queue/foo.bar.myqueue?jms.soap=true

Added:
    incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
Modified:
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/AbstractJmsProcessor.java
Tue May  9 02:58:57 2006
@@ -40,15 +40,39 @@
         InitialContext ctx = null;
         ConnectionFactory connectionFactory = null;
         try {
+            // First check configured connectionFactory on the endpoint
             connectionFactory = endpoint.getConnectionFactory();
-            if (connectionFactory == null) {
+            // Then, check for jndi connection factory name on the endpoint
+            if (connectionFactory == null && endpoint.getJndiConnectionFactoryName()
!= null) {
                 Hashtable props = new Hashtable();
                 if (endpoint.getInitialContextFactory() != null && endpoint.getJndiProviderURL()
!= null) {
                     props.put(Context.INITIAL_CONTEXT_FACTORY, endpoint.getInitialContextFactory());
                     props.put(Context.PROVIDER_URL, endpoint.getJndiProviderURL());
+                } else if (endpoint.getConfiguration().getJndiInitialContextFactory() !=
null && 
+                           endpoint.getConfiguration().getJndiProviderUrl() != null) {
+                    props.put(Context.INITIAL_CONTEXT_FACTORY, endpoint.getConfiguration().getJndiInitialContextFactory());
+                    props.put(Context.PROVIDER_URL, endpoint.getConfiguration().getJndiProviderUrl());
                 }
                 ctx = new InitialContext(props);
                 connectionFactory = (ConnectionFactory) ctx.lookup(endpoint.getJndiConnectionFactoryName());
+            }
+            // Check for a configured connectionFactory on the configuration
+            if (connectionFactory == null && endpoint.getConfiguration().getConnectionFactory()
!= null) {
+                connectionFactory = endpoint.getConfiguration().getConnectionFactory();
+            }
+            // Check for jndi connection factory name on the configuration
+            if (connectionFactory == null && endpoint.getConfiguration().getJndiConnectionFactoryName()
!= null) {
+                Hashtable props = new Hashtable();
+                if (endpoint.getInitialContextFactory() != null && endpoint.getJndiProviderURL()
!= null) {
+                    props.put(Context.INITIAL_CONTEXT_FACTORY, endpoint.getInitialContextFactory());
+                    props.put(Context.PROVIDER_URL, endpoint.getJndiProviderURL());
+                } else if (endpoint.getConfiguration().getJndiInitialContextFactory() !=
null && 
+                           endpoint.getConfiguration().getJndiProviderUrl() != null) {
+                    props.put(Context.INITIAL_CONTEXT_FACTORY, endpoint.getConfiguration().getJndiInitialContextFactory());
+                    props.put(Context.PROVIDER_URL, endpoint.getConfiguration().getJndiProviderUrl());
+                }
+                ctx = new InitialContext(props);
+                connectionFactory = (ConnectionFactory) ctx.lookup(endpoint.getConfiguration().getJndiConnectionFactoryName());
             }
             connection = connectionFactory.createConnection();
             connection.start();

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
Tue May  9 02:58:57 2006
@@ -47,18 +47,7 @@
      * @see javax.jbi.component.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
      */
     public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
-        if (epr.getChildNodes().getLength() == 1) {
-            Node child = epr.getFirstChild();
-            if (child instanceof Element) {
-                Element elem = (Element) child;
-                String nsUri = elem.getNamespaceURI();
-                String name = elem.getLocalName();
-                if (JmsResolvedEndpoint.EPR_URI.equals(nsUri) && JmsResolvedEndpoint.EPR_NAME.equals(name))
{
-                    return new JmsResolvedEndpoint(epr, DOMUtil.getElementText(elem));
-                }
-            }
-        }
-        return null;
+        return JmsResolvedEndpoint.resolveEndpoint(epr);
     }
     
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
Tue May  9 02:58:57 2006
@@ -15,8 +15,14 @@
  */
 package org.apache.servicemix.jms;
 
+import javax.jms.ConnectionFactory;
+
 import org.apache.servicemix.common.PersistentConfiguration;
 
+/**
+ * @author gnodet
+ *
+ */
 public class JmsConfiguration extends PersistentConfiguration implements JmsConfigurationMBean
{
 
     private String userName;
@@ -25,6 +31,7 @@
     private String jndiProviderUrl;
     private String jndiConnectionFactoryName;
     private String processorName = "multiplexing";
+    private ConnectionFactory connectionFactory;
     
     /**
      * @return Returns the password.
@@ -104,6 +111,20 @@
         this.processorName = processorName;
         save();
     }
+    /**
+     * @return Returns the connectionFactory.
+     */
+    public ConnectionFactory getConnectionFactory() {
+        return connectionFactory;
+    }
+    /**
+     * Default ConnectionFactory to use in a spring configuration.
+     * @param connectionFactory the connectionFactory to set.
+     */
+    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
     
     public void save() {
         properties.setProperty("userName", userName);
@@ -140,5 +161,4 @@
             return false;
         }
     }
-
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
Tue May  9 02:58:57 2006
@@ -318,5 +318,10 @@
     public void setProcessorName(String processorName) {
         this.processorName = processorName;
     }
+    
+    public JmsConfiguration getConfiguration() {
+        JmsLifeCycle lifeCycle = (JmsLifeCycle) getServiceUnit().getComponent().getLifeCycle();
+        return lifeCycle.getConfiguration();
+    }
 
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
Tue May  9 02:58:57 2006
@@ -15,8 +15,19 @@
  */
 package org.apache.servicemix.jms;
 
+import java.net.URI;
+import java.util.Map;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.namespace.QName;
+
+import org.apache.activemq.util.IntrospectionSupport;
+import org.apache.activemq.util.URISupport;
 import org.apache.servicemix.common.BaseComponent;
 import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ServiceUnit;
 
 public class JmsLifeCycle extends BaseLifeCycle {
 
@@ -55,6 +66,42 @@
      */
     public void setConfiguration(JmsConfiguration configuration) {
         this.configuration = configuration;
+    }
+
+    protected QName getEPRServiceName() {
+        return JmsResolvedEndpoint.EPR_SERVICE;
+    }
+    
+    protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception {
+        // We receive an exchange for an EPR that has not been used yet.
+        // Register a provider endpoint and restart processing.
+        JmsEndpoint jmsEp = new JmsEndpoint();
+        jmsEp.setServiceUnit(new ServiceUnit(component));
+        jmsEp.setService(ep.getServiceName());
+        jmsEp.setEndpoint(ep.getEndpointName());
+        jmsEp.setRole(MessageExchange.Role.PROVIDER);
+        URI uri = new URI(ep.getEndpointName());
+        Map map = URISupport.parseQuery(uri.getQuery());
+        if( IntrospectionSupport.setProperties(jmsEp, map, "jms.") ) {
+            uri = URISupport.createRemainingURI(uri, map);
+        }
+        if (uri.getPath() != null) {
+            String path = uri.getSchemeSpecificPart();
+            while (path.startsWith("/")) {
+                path = path.substring(1);
+            }
+            if (path.startsWith(AbstractJmsProcessor.STYLE_QUEUE + "/")) {
+                jmsEp.setDestinationStyle(AbstractJmsProcessor.STYLE_QUEUE);
+                jmsEp.setJmsProviderDestinationName(path.substring(AbstractJmsProcessor.STYLE_QUEUE.length()
+ 1));
+            } else if (path.startsWith(AbstractJmsProcessor.STYLE_TOPIC + "/")) {
+                jmsEp.setDestinationStyle(AbstractJmsProcessor.STYLE_TOPIC);
+                jmsEp.setJmsProviderDestinationName(path.substring(AbstractJmsProcessor.STYLE_TOPIC.length()
+ 1));
+            }
+        }
+        jmsEp.activateDynamic();
+        // TODO: need to find some usefull syntax for jms
+        // jms://
+        return jmsEp;
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
Tue May  9 02:58:57 2006
@@ -18,11 +18,16 @@
 import javax.jbi.servicedesc.ServiceEndpoint;
 import javax.xml.namespace.QName;
 
+import org.apache.servicemix.jbi.util.DOMUtil;
 import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 public class JmsResolvedEndpoint implements ServiceEndpoint {
 
     public final static String EPR_URI = "urn:servicemix:jms";
+    public final static QName EPR_SERVICE = new QName(EPR_URI, "JmsComponent");
     public final static String EPR_NAME = "epr";
     
     private DocumentFragment reference;
@@ -30,6 +35,7 @@
     
     public JmsResolvedEndpoint(DocumentFragment epr, String epName) {
         this.reference = epr;
+        this.epName = epName;
     }
 
     public DocumentFragment getAsReference(QName operationName) {
@@ -45,7 +51,36 @@
     }
 
     public QName getServiceName() {
-        return new QName("urn:servicemix:jms", "JmsComponent");
+        return EPR_SERVICE;
+    }
+    
+    public static ServiceEndpoint resolveEndpoint(DocumentFragment epr) {
+        if (epr.getChildNodes().getLength() == 1) {
+            Node child = epr.getFirstChild();
+            if (child instanceof Element) {
+                Element elem = (Element) child;
+                String nsUri = elem.getNamespaceURI();
+                String name = elem.getLocalName();
+                // Check simple endpoints
+                if (EPR_URI.equals(nsUri) && EPR_NAME.equals(name)) {
+                    return new JmsResolvedEndpoint(epr, DOMUtil.getElementText(elem));
+                // Check WSA endpoints
+                } else {
+                    NodeList nl = elem.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing",
"Address");
+                    if (nl.getLength() == 1) {
+                        Element address = (Element) nl.item(0);
+                        String uri = DOMUtil.getElementText(address);
+                        if (uri != null) {
+                            uri = uri.trim();
+                            if (uri.startsWith("jms://")) {
+                                return new JmsResolvedEndpoint(epr, uri);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return null;
     }
     
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
Tue May  9 02:58:57 2006
@@ -20,10 +20,7 @@
 import org.apache.servicemix.common.BaseComponent;
 import org.apache.servicemix.common.BaseLifeCycle;
 import org.apache.servicemix.common.ServiceUnit;
-import org.apache.servicemix.jbi.util.DOMUtil;
 import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
 /**
  * 
@@ -47,18 +44,7 @@
      * @see javax.jbi.component.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
      */
     public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
-        if (epr.getChildNodes().getLength() == 1) {
-            Node child = epr.getFirstChild();
-            if (child instanceof Element) {
-                Element elem = (Element) child;
-                String nsUri = elem.getNamespaceURI();
-                String name = elem.getLocalName();
-                if (JmsResolvedEndpoint.EPR_URI.equals(nsUri) && JmsResolvedEndpoint.EPR_NAME.equals(name))
{
-                    return new JmsResolvedEndpoint(epr, DOMUtil.getElementText(elem));
-                }
-            }
-        }
-        return null;
+        return JmsResolvedEndpoint.resolveEndpoint(epr);
     }
     
     public JmsEndpoint[] getEndpoints() {
@@ -84,9 +70,11 @@
             super.doInit();
             su = new ServiceUnit();
             su.setComponent(JmsSpringComponent.this);
-            for (int i = 0; i < endpoints.length; i++) {
-                endpoints[i].setServiceUnit(su);
-                su.addEndpoint(endpoints[i]);
+            if (endpoints != null) {
+                for (int i = 0; i < endpoints.length; i++) {
+                    endpoints[i].setServiceUnit(su);
+                    su.addEndpoint(endpoints[i]);
+                }
             }
             getRegistry().registerServiceUnit(su);
         }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
Tue May  9 02:58:57 2006
@@ -135,7 +135,7 @@
                         //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
                         pendingMessages.put(exchange.getExchangeId(), context);
                         BaseLifeCycle lf = (BaseLifeCycle) endpoint.getServiceUnit().getComponent().getLifeCycle();
-                        lf.sendConsumerExchange(exchange, MultiplexingConsumerProcessor.this);
+                        lf.sendConsumerExchange(exchange, MultiplexingConsumerProcessor.this.endpoint);
                     } catch (Throwable e) {
                         log.error("Error while handling jms message", e);
                     }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java?rev=405365&r1=405364&r2=405365&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java
Tue May  9 02:58:57 2006
@@ -190,6 +190,8 @@
             synchronized (producer) {
                 producer.send(msg);
             }
+            exchange.setStatus(ExchangeStatus.DONE);
+            channel.send(exchange);
         } else if (exchange instanceof InOut) {
             msg.setJMSCorrelationID(exchange.getExchangeId());
             msg.setJMSReplyTo(replyToDestination);

Added: incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java?rev=405365&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
(added)
+++ incubator/servicemix/trunk/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
Tue May  9 02:58:57 2006
@@ -0,0 +1,112 @@
+/*
+ * 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.jms;
+
+import java.util.List;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+import org.apache.servicemix.jbi.resolver.URIResolver;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.springframework.core.io.ClassPathResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+
+public class JmsURITest extends TestCase {
+
+    protected JBIContainer container;
+    protected BrokerService broker;
+    protected ActiveMQConnectionFactory connectionFactory;
+
+    protected void setUp() throws Exception {
+        BrokerFactoryBean bfb = new BrokerFactoryBean(new ClassPathResource("org/apache/servicemix/jms/activemq.xml"));
+        bfb.afterPropertiesSet();
+        broker = bfb.getBroker();
+        broker.start();
+
+        container = new JBIContainer();
+        container.setUseMBeanServer(true);
+        container.setCreateMBeanServer(true);
+        container.setMonitorInstallationDirectory(false);
+        container.init();
+        container.start();
+
+        connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61216");
+    }
+
+    protected void tearDown() throws Exception {
+        if (container != null) {
+            container.shutDown();
+        }
+        if (broker != null) {
+            broker.stop();
+        }
+    }
+
+    public void testResolveEndpoint() throws Exception {
+        JmsSpringComponent jms = new JmsSpringComponent();
+        ((JmsLifeCycle) jms.getLifeCycle()).getConfiguration().setConnectionFactory(connectionFactory);
+        JmsEndpoint ep = new JmsEndpoint();
+        ep.setRole(MessageExchange.Role.CONSUMER);
+        ep.setService(ReceiverComponent.SERVICE);
+        ep.setEndpoint(ReceiverComponent.ENDPOINT);
+        ep.setDefaultMep(MessageExchangeSupport.IN_ONLY);
+        ep.setJmsProviderDestinationName("foo.bar.myqueue");
+        ep.setDestinationStyle(AbstractJmsProcessor.STYLE_QUEUE);
+        jms.setEndpoints(new JmsEndpoint[] { ep });
+        container.activateComponent(jms, "servicemix-jms");
+
+        ReceiverComponent receiver = new ReceiverComponent();
+        container.activateComponent(receiver, "receiver");
+
+        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+        DocumentFragment epr = URIResolver.createWSAEPR("jms://queue/foo.bar.myqueue?jms.soap=true");
+        ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
+        assertNotNull(se);
+
+        InOnly inonly = client.createInOnlyExchange();
+        inonly.setEndpoint(se);
+        inonly.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        client.sendSync(inonly);
+
+        assertEquals(ExchangeStatus.DONE, inonly.getStatus());
+        receiver.getMessageList().assertMessagesReceived(1);
+        List msgs = receiver.getMessageList().flushMessages();
+        NormalizedMessage msg = (NormalizedMessage) msgs.get(0);
+        Document doc = (Document) new SourceTransformer().toDOMNode(msg);
+        assertEquals("http://www.w3.org/2003/05/soap-envelope", doc.getDocumentElement().getNamespaceURI());
+        assertEquals("env:Envelope", doc.getDocumentElement().getNodeName());
+        System.out.println(new SourceTransformer().contentToString(msg));
+
+        // Wait for DONE status
+        Thread.sleep(50);
+    }
+
+}



Mime
View raw message