activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r523434 - in /activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms: JmsComponent.java JmsEndpoint.java JmsEndpointResolver.java
Date Wed, 28 Mar 2007 18:34:35 GMT
Author: jstrachan
Date: Wed Mar 28 11:34:34 2007
New Revision: 523434

URL: http://svn.apache.org/viewvc?view=rev&rev=523434
Log:
added URI customization using URI query parameters

Modified:
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpointResolver.java

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java?view=diff&rev=523434&r1=523433&r2=523434
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
Wed Mar 28 11:34:34 2007
@@ -21,9 +21,14 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
 
 import javax.jms.ConnectionFactory;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
 
 /**
  * @version $Revision:520964 $
@@ -77,14 +82,14 @@
         this.configuration = new JmsConfiguration();
     }
 
-    public JmsEndpoint createEndpoint(Uri uri) {
+    public JmsEndpoint createEndpoint(Uri uri) throws URISyntaxException {
         // lets figure out from the URI whether its a queue, topic etc
 
         String path = uri.getPath();
         return createEndpoint(uri.toString(), path);
     }
 
-    public JmsEndpoint createEndpoint(String uri, String path) {
+    public JmsEndpoint createEndpoint(String uri, String path) throws URISyntaxException
{
         ObjectHelper.notNull(getContext(), "container");
 
         boolean pubSubDomain = false;
@@ -99,16 +104,17 @@
 
         final String subject = convertPathToActualDestination(path);
 
-        /*
-        Destination destination = (Destination) template.execute(new SessionCallback() {
-            public Object doInJms(Session session) throws JMSException {
-                return template.getDestinationResolver().resolveDestinationName(session,
subject, template.isPubSubDomain());
-            }
-        });
-        */
+        // lets make sure we copy the configuration as each endpoint can customize its own
version
+        JmsEndpoint endpoint = new JmsEndpoint(uri, getContext(), subject, pubSubDomain,
getConfiguration().copy());
 
-        // TODO configure endpoint configuration and selector using URI properties
-        return new JmsEndpoint(uri, getContext(), subject, pubSubDomain, getConfiguration().copy());
+        URI u = new URI(uri);
+        Map options = URISupport.parseParamters(u);
+        String selector = (String) options.remove("selector");
+        if (selector != null) {
+            endpoint.setSelector(selector);
+        }
+        IntrospectionSupport.setProperties(endpoint.getConfiguration(), options);
+        return endpoint;
     }
 
     public JmsConfiguration getConfiguration() {

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java?view=diff&rev=523434&r1=523433&r2=523434
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
Wed Mar 28 11:34:34 2007
@@ -20,12 +20,16 @@
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.util.URISupport;
+import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.springframework.jms.core.JmsOperations;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.listener.AbstractMessageListenerContainer;
 
 import javax.jms.Message;
+import java.net.URI;
+import java.util.Map;
 
 /**
  * @version $Revision:520964 $
@@ -77,10 +81,9 @@
     public Consumer<JmsExchange> createConsumer(Processor<JmsExchange> processor,
AbstractMessageListenerContainer listenerContainer) throws Exception {
         listenerContainer.setDestinationName(destination);
         listenerContainer.setPubSubDomain(pubSubDomain);
-
-        // TODO support optional parameters
-        // selector
-
+        if (selector != null) {
+            listenerContainer.setMessageSelector(selector);
+        }
         return startService(new JmsConsumer(this, processor, listenerContainer));
     }
 

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpointResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpointResolver.java?view=diff&rev=523434&r1=523433&r2=523434
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpointResolver.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpointResolver.java
Wed Mar 28 11:34:34 2007
@@ -23,6 +23,7 @@
 import org.apache.camel.util.ObjectHelper;
 
 import java.util.concurrent.Callable;
+import java.net.URISyntaxException;
 
 /**
  * An implementation of {@link EndpointResolver} that creates
@@ -52,7 +53,7 @@
      * Finds the {@see QueueEndpoint} specified by the uri.  If the {@see QueueEndpoint}
or it's associated
      * {@see QueueComponent} object do not exist, they will be created.
      */
-    public JmsEndpoint resolveEndpoint(CamelContext container, String uri) {
+    public JmsEndpoint resolveEndpoint(CamelContext container, String uri) throws URISyntaxException
{
         String id[] = getEndpointId(uri);
         JmsComponent component = resolveJmsComponent(container, id[0]);
         return component.createEndpoint(uri, id[1]);



Mime
View raw message