activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r520124 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/queue/ camel-jms/src/main/java/org/apache/camel/jms/
Date Mon, 19 Mar 2007 22:22:48 GMT
Author: chirino
Date: Mon Mar 19 15:22:46 2007
New Revision: 520124

URL: http://svn.apache.org/viewvc?view=rev&rev=520124
Log:
Added the activate/deactivate lifecylce methods to the Component interface
and did some other small cleanups

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidHeaderTypeException.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeCamelException.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExchangeSupport.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/DefaultJmsExchange.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpointResolver.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsExchange.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyAcessException.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyNamesAcessException.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/RuntimeJmsException.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java Mon
Mar 19 15:22:46 2007
@@ -70,7 +70,7 @@
         return new DefaultExchangeConverter();
     }
 
-	public Component getOrCreateComponent(String componentName, Callable<Component<E>>
factory) {
+	public Component getOrCreateComponent(String componentName, Callable<Component<E,?
extends  Endpoint<E>>> factory) {
 		synchronized(components) { 
 			Component component = components.get(componentName);
 			if( component == null ) {
@@ -82,6 +82,13 @@
 					throw new IllegalArgumentException("Factory failed to create the "+componentName+" component",
e);
 				}
 			}
+			return component;
+		}
+	}
+	
+	public Component getComponent(String componentName) {
+		synchronized(components) { 
+			Component component = components.get(componentName);
 			return component;
 		}
 	}

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java Mon Mar
19 15:22:46 2007
@@ -21,6 +21,18 @@
  *
  * @version $Revision: 519901 $
  */
-public interface Component<E>  {
+public interface Component<E, EP extends Endpoint<E>>  {
 
+	/**
+	 * Asks the component to activate the delivery of {@link Exchange} objects
+	 * from the {@link Endpoint} to the {@link Processor}.
+	 */
+	void activate(EP endpoint, Processor<E> processor);
+
+	/**
+	 * Stops the delivery of messages from a previously activated 
+	 * {@link Endpoint}.
+	 */
+	void deactivate(EP endpoint);
+	
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java Mon Mar 19
15:22:46 2007
@@ -29,7 +29,7 @@
     public String getEndpointUri();
 
     /**
-     * Sends the mesage exchange to this endpoint
+     * Sends the message exchange to this endpoint
      */
     void send(E exchange);
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Mon Mar 19
15:22:46 2007
@@ -23,12 +23,12 @@
  *
  * @version $Revision$
  */
-public interface Exchange<M> {
+public interface Exchange<M,R,F> {
 
     /**
      * Accesses a specific header
      */
-    <T> T getHeader(String name);
+    Object getHeader(String name);
 
     /**
      * Sets a header on the exchange
@@ -48,12 +48,12 @@
     /**
      * Returns the response message
      */
-    M getResponse();
+    R getResponse();
 
     /**
      * Returns the fault message
      */
-    M getFault();
+    F getFault();
 
     /**
      * Returns the exception associated with this exchange

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidHeaderTypeException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidHeaderTypeException.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidHeaderTypeException.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidHeaderTypeException.java
Mon Mar 19 15:22:46 2007
@@ -20,7 +20,9 @@
  * @version $Revision$
  */
 public class InvalidHeaderTypeException extends RuntimeCamelException {
-    private Object headerValue;
+
+	private static final long serialVersionUID = -8417806626073055262L;
+	private Object headerValue;
 
     public InvalidHeaderTypeException(Throwable cause, Object headerValue) {
         super(cause.getMessage() + " headerValue is: " + headerValue + " of type: "

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeCamelException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeCamelException.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeCamelException.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeCamelException.java
Mon Mar 19 15:22:46 2007
@@ -20,9 +20,9 @@
  * @version $Revision$
  */
 public class RuntimeCamelException extends RuntimeException {
+	private static final long serialVersionUID = 8046489554418284257L;
 
-
-    public RuntimeCamelException() {
+	public RuntimeCamelException() {
     }
 
     public RuntimeCamelException(String message) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
Mon Mar 19 15:22:46 2007
@@ -26,7 +26,7 @@
  *
  * @version $Revision$
  */
-public class DefaultExchange<M> extends ExchangeSupport<M> {
+public class DefaultExchange<M,R,F> extends ExchangeSupport<M,R,F> {
     private Map<String,Object> headers;
 
     public Object getHeader(String name) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExchangeSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExchangeSupport.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExchangeSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExchangeSupport.java
Mon Mar 19 15:22:46 2007
@@ -23,10 +23,10 @@
  *
  * @version $Revision$
  */
-public abstract class ExchangeSupport<M> implements Exchange<M> {
+public abstract class ExchangeSupport<M,R,F> implements Exchange<M,R,F> {
     private M request;
-    private M response;
-    private M fault;
+    private R response;
+    private F fault;
     private Exception exception;
 
     public Exception getException() {
@@ -37,11 +37,11 @@
         this.exception = exception;
     }
 
-    public M getFault() {
+    public F getFault() {
         return fault;
     }
 
-    public void setFault(M fault) {
+    public void setFault(F fault) {
         this.fault = fault;
     }
 
@@ -53,11 +53,11 @@
         this.request = request;
     }
 
-    public M getResponse() {
+    public R getResponse() {
         return response;
     }
 
-    public void setResponse(M response) {
+    public void setResponse(R response) {
         this.response = response;
     }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
Mon Mar 19 15:22:46 2007
@@ -19,8 +19,10 @@
 import java.util.HashMap;
 import java.util.Queue;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.camel.Component;
+import org.apache.camel.Processor;
 
 /**
  * Represents the component that manages {@link QueueEndpoint}.  It holds the 
@@ -28,9 +30,37 @@
  *
  * @version $Revision: 519973 $
  */
-public class QueueComponent<E> implements Component<E> {
+public class QueueComponent<E> implements Component<E, QueueEndpoint<E>>
{
 	
     private HashMap<String, Queue<E>> registry = new HashMap<String, Queue<E>>();
+    private HashMap<QueueEndpoint<E>, Activation> activations = new HashMap<QueueEndpoint<E>,
Activation>();
+    
+    class Activation implements Runnable {
+		private final QueueEndpoint<E> endpoint;
+		AtomicBoolean stop = new AtomicBoolean();
+		private Thread thread;
+		
+		public Activation(QueueEndpoint<E> endpoint) {
+			this.endpoint = endpoint;
+		}
+
+		public void run() {
+			while(!stop.get()) {
+				
+			}
+		}
+
+		public void start() {
+			thread = new Thread(this, endpoint.getEndpointUri());
+			thread.setDaemon(true);
+			thread.start();
+		}
+
+		public void stop() throws InterruptedException {
+			stop.set(true);
+			thread.join();
+		}
+    }
 
 	synchronized public Queue<E> getOrCreateQueue(String uri) {
 		Queue<E> queue = registry.get(uri);
@@ -44,5 +74,27 @@
 	private Queue<E> createQueue() {
 		return new LinkedBlockingQueue<E>();
 	}
-    
+
+	public void activate(QueueEndpoint<E> endpoint, Processor<E> processor) {
+		Activation activation = activations.get(endpoint);
+		if( activation!=null ) {
+			throw new IllegalArgumentException("Endpoint "+endpoint.getEndpointUri()+" has already
been activated.");
+		}
+		
+		activation = new Activation(endpoint);
+		activation.start();
+	}
+
+	public void deactivate(QueueEndpoint<E> endpoint) {
+		Activation activation = activations.remove(endpoint);
+		if( activation==null ) {
+			throw new IllegalArgumentException("Endpoint "+endpoint.getEndpointUri()+" is not activate.");
+		}		
+		try {
+			activation.stop();
+		} catch (InterruptedException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java
Mon Mar 19 15:22:46 2007
@@ -42,7 +42,7 @@
 
     public E createExchange() {
     	// How can we create a specific Exchange if we are generic??
-    	// perhaps it would be better if we did not impement this. 
+    	// perhaps it would be better if we did not implement this. 
         return (E) new DefaultExchange();
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java
Mon Mar 19 15:22:46 2007
@@ -29,7 +29,7 @@
  * An implementation of {@link EndpointResolver} that creates 
  * {@link QueueEndpoint} objects.
  *
- * The synatx for a Queue URI looks like:
+ * The syntax for a Queue URI looks like:
  * 
  * <pre><code>queue:[component:]queuename</code></pre>
  * the component is optional, and if it is not specified, the default component name
@@ -48,8 +48,8 @@
 	 * @see org.apache.camel.EndpointResolver#resolveComponent(org.apache.camel.CamelContainer,
java.lang.String)
 	 */
 	public Component resolveComponent(CamelContainer container, String uri) {
-		String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);
-		return resolveQueueComponent(container, splitURI);
+		String id[] = getEndpointId(uri);        
+    	return resolveQueueComponent(container, id[0]);  
 	}
 
 	/**
@@ -59,19 +59,31 @@
 	 * @see org.apache.camel.EndpointResolver#resolveEndpoint(org.apache.camel.CamelContainer,
java.lang.String)
 	 */
 	public Endpoint<E> resolveEndpoint(CamelContainer container, String uri) {
-		String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);        
-    	QueueComponent<E> component = resolveQueueComponent(container, splitURI);    
   
-        Queue<E> queue = component.getOrCreateQueue(uri);
+		String id[] = getEndpointId(uri);        
+    	QueueComponent<E> component = resolveQueueComponent(container, id[0]);  
+        Queue<E> queue = component.getOrCreateQueue(id[1]);
 		return new QueueEndpoint<E>(uri, container, queue);
     }
 
-	private QueueComponent<E> resolveQueueComponent(CamelContainer container, String[]
splitURI) {
-		String componentName = DEFAULT_COMPONENT_NAME;
+	/**
+	 * @return an array that looks like: [componentName,endpointName] 
+	 */
+	private String[] getEndpointId(String uri) {
+		String rc [] = {DEFAULT_COMPONENT_NAME, null};
+		String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);        
     	if( splitURI[2] != null ) {
-    		componentName =  splitURI[1];
+    		rc[0] =  splitURI[1];
+    		rc[0] =  splitURI[2];
+    	} else {
+    		rc[0] =  splitURI[1];
     	}
-    	Component rc = container.getOrCreateComponent(componentName, new Callable<Component<E>>(){
-			public Component<E> call() throws Exception {
+		return rc;
+	}
+	
+	@SuppressWarnings("unchecked")
+	private QueueComponent<E> resolveQueueComponent(CamelContainer container, String componentName)
{
+    	Component rc = container.getOrCreateComponent(componentName, new Callable<Component<E,?
extends Endpoint<E>>>(){
+			public Component<E, ? extends Endpoint<E>> call() throws Exception {
 				return new QueueComponent<E>();
 			}});
     	return (QueueComponent<E>) rc;

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/DefaultJmsExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/DefaultJmsExchange.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/DefaultJmsExchange.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/DefaultJmsExchange.java
Mon Mar 19 15:22:46 2007
@@ -29,7 +29,7 @@
 /**
  * @version $Revision$
  */
-public class DefaultJmsExchange extends ExchangeSupport<Message> implements JmsExchange
{
+public class DefaultJmsExchange extends ExchangeSupport<Message,Message,Message> implements
JmsExchange {
     private Map<String, Object> lazyHeaders;
 
     public DefaultJmsExchange() {
@@ -39,13 +39,13 @@
         setRequest(message);
     }
 
-    public <T> T getHeader(String name) {
+    public Object getHeader(String name) {
         Message request = getRequest();
         if (request != null) {
             try {
                 Object value = request.getObjectProperty(name);
                 try {
-                    return (T) value;
+                    return value;
                 }
                 catch (ClassCastException e) {
                     throw new InvalidHeaderTypeException(e.getMessage(), value);

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java Mon
Mar 19 15:22:46 2007
@@ -17,25 +17,24 @@
  */
 package org.apache.camel.jms;
 
-import org.springframework.jms.core.JmsOperations;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.apache.camel.CamelContainer;
+import org.apache.camel.Component;
+import org.apache.camel.Processor;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.core.SessionCallback;
 import org.springframework.jms.listener.AbstractMessageListenerContainer;
 import org.springframework.jms.listener.DefaultMessageListenerContainer;
-import org.apache.camel.CamelContainer;
-import org.apache.camel.Component;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Session;
-import javax.jms.JMSException;
-import javax.jms.Destination;
 
 import com.sun.jndi.toolkit.url.Uri;
 
 /**
  * @version $Revision$
  */
-public class JmsComponent implements Component<JmsExchange> {
+public class JmsComponent implements Component<JmsExchange, JmsEndpoint> {
     private JmsTemplate template = new JmsTemplate();
     private static final String QUEUE_PREFIX = "queue/";
     private static final String TOPIC_PREFIX = "topic/";
@@ -95,4 +94,11 @@
     protected String convertPathToActualDestination(String path) {
         return path;
     }
+
+	public void activate(JmsEndpoint endpoint, Processor<JmsExchange> processor) {
+		// TODO Auto-generated method stub
+	}
+	public void deactivate(JmsEndpoint endpoint) {
+		// TODO Auto-generated method stub
+	}
 }

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpointResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpointResolver.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpointResolver.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpointResolver.java
Mon Mar 19 15:22:46 2007
@@ -17,23 +17,22 @@
  */
 package org.apache.camel.jms;
 
-import org.apache.camel.EndpointResolver;
+import java.util.concurrent.Callable;
+
+import org.apache.axis.transport.jms.JMSEndpoint;
 import org.apache.camel.CamelContainer;
 import org.apache.camel.Component;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.queue.QueueEndpoint;
+import org.apache.camel.EndpointResolver;
 import org.apache.camel.queue.QueueComponent;
-
-import java.util.Queue;
-import java.util.concurrent.Callable;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * An implementation of {@link EndpointResolver} that creates
- * {@link QueueEndpoint} objects.
+ * {@link JMSEndpoint} objects.
  *
- * The synatx for a Queue URI looks like:
+ * The syntax for a JMS URI looks like:
  *
- * <pre><code>queue:[component:]queuename</code></pre>
+ * <pre><code>jms:[component:]destination</code></pre>
  * the component is optional, and if it is not specified, the default component name
  * is assumed.
  *
@@ -48,8 +47,8 @@
 	 * object do not exist, it will be created.
 	 */
 	public Component resolveComponent(CamelContainer container, String uri) {
-		String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);
-		return resolveJmsComponent(container, splitURI);
+		String id[] = getEndpointId(uri);        
+		return resolveJmsComponent(container, id[0]);
 	}
 
 	/**
@@ -57,22 +56,34 @@
 	 * {@see QueueComponent} object do not exist, they will be created.
 	 */
 	public JmsEndpoint resolveEndpoint(CamelContainer container, String uri) {
-		String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);
-    	JmsComponent component = resolveJmsComponent(container, splitURI);
-
-        return component.createEndpoint(uri, splitURI[2]);
+		String id[] = getEndpointId(uri);        
+    	JmsComponent component = resolveJmsComponent(container, id[0]);
+        return component.createEndpoint(uri, id[1]);
     }
 
-	private JmsComponent resolveJmsComponent(final CamelContainer container, String[] splitURI)
{
-		String componentName = DEFAULT_COMPONENT_NAME;
+	/**
+	 * @return an array that looks like: [componentName,endpointName] 
+	 */
+	private String[] getEndpointId(String uri) {
+		String rc [] = {DEFAULT_COMPONENT_NAME, null};
+		String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);        
     	if( splitURI[2] != null ) {
-    		componentName =  splitURI[1];
+    		rc[0] =  splitURI[1];
+    		rc[0] =  splitURI[2];
+    	} else {
+    		rc[0] =  splitURI[1];
     	}
+		return rc;
+	}
+	
+	@SuppressWarnings("unchecked")
+	private JmsComponent resolveJmsComponent(final CamelContainer container, String componentName)
{
     	Component rc = container.getOrCreateComponent(componentName, new Callable<JmsComponent>(){
 			public JmsComponent call() throws Exception {
 				return new JmsComponent(container);
 			}});
     	return (JmsComponent) rc;
 	}
+
 
 }

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsExchange.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsExchange.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsExchange.java Mon
Mar 19 15:22:46 2007
@@ -25,7 +25,7 @@
 /**
  * @version $Revision$
  */
-public interface JmsExchange extends Exchange<Message> {
+public interface JmsExchange extends Exchange<Message,Message,Message> {
 
     /**
      * Creates the JMS message for this exchange so that it can be sent to

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyAcessException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyAcessException.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyAcessException.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyAcessException.java
Mon Mar 19 15:22:46 2007
@@ -22,7 +22,8 @@
  * @version $Revision$
  */
 public class MessagePropertyAcessException extends RuntimeJmsException {
-    private String propertyName;
+	private static final long serialVersionUID = -3996286386119163309L;
+	private String propertyName;
 
     public MessagePropertyAcessException(String propertyName, JMSException e) {
         super("Error accessing header: " + propertyName, e);

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyNamesAcessException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyNamesAcessException.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyNamesAcessException.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/MessagePropertyNamesAcessException.java
Mon Mar 19 15:22:46 2007
@@ -23,7 +23,9 @@
  */
 public class MessagePropertyNamesAcessException extends RuntimeJmsException {
 
-    public MessagePropertyNamesAcessException(JMSException e) {
+	private static final long serialVersionUID = -6744171518099741324L;
+
+	public MessagePropertyNamesAcessException(JMSException e) {
         super("Failed to acess the JMS message property names", e);
     }
 }

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/RuntimeJmsException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/RuntimeJmsException.java?view=diff&rev=520124&r1=520123&r2=520124
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/RuntimeJmsException.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/RuntimeJmsException.java
Mon Mar 19 15:22:46 2007
@@ -22,7 +22,10 @@
  * @version $Revision$
  */
 public class RuntimeJmsException extends RuntimeException {
-    public RuntimeJmsException(String message, JMSException cause) {
+
+	private static final long serialVersionUID = -2141493732308871761L;
+
+	public RuntimeJmsException(String message, JMSException cause) {
         super(message, cause);
     }
 }



Mime
View raw message