activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r523772 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/component/queue/ camel-mina/src/main/java/org/apache/camel/component/mina/
Date Thu, 29 Mar 2007 17:21:35 GMT
Author: jstrachan
Date: Thu Mar 29 10:21:34 2007
New Revision: 523772

URL: http://svn.apache.org/viewvc?view=rev&rev=523772
Log:
tidied up the code a little to remove some unnecessary maps

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointResolver.java
    activemq/camel/trunk/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueComponent.java?view=diff&rev=523772&r1=523771&r2=523772
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueComponent.java
Thu Mar 29 10:21:34 2007
@@ -32,23 +32,13 @@
  */
 public class QueueComponent<E> implements Component<E> {
 	
-    private HashMap<String, BlockingQueue<E>> registry = new HashMap<String,
BlockingQueue<E>>();
     private CamelContext container;
 
     public void setCamelContext(CamelContext container) {
         this.container = container;
     }
 
-	synchronized public BlockingQueue<E> getOrCreateQueue(String uri) {
-		BlockingQueue<E> queue = registry.get(uri);
-		if( queue == null ) {
-			queue = createQueue();
-			registry.put(uri, queue);
-		}
-		return queue;
-	}
-
-	protected BlockingQueue<E> createQueue() {
+	public BlockingQueue<E> createQueue() {
 		return new LinkedBlockingQueue<E>();
 	}
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointResolver.java?view=diff&rev=523772&r1=523771&r2=523772
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointResolver.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointResolver.java
Thu Mar 29 10:21:34 2007
@@ -62,7 +62,7 @@
 	public Endpoint<E> resolveEndpoint(CamelContext container, String uri) {
 		String id[] = getEndpointId(uri);        
     	QueueComponent<E> component = resolveQueueComponent(container, id[0]);  
-    	BlockingQueue<E> queue = component.getOrCreateQueue(id[1]);
+    	BlockingQueue<E> queue = component.createQueue();
 		return new QueueEndpoint<E>(uri, container, queue);
     }
 

Modified: activemq/camel/trunk/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java?view=diff&rev=523772&r1=523771&r2=523772
==============================================================================
--- activemq/camel/trunk/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
(original)
+++ activemq/camel/trunk/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
Thu Mar 29 10:21:34 2007
@@ -21,15 +21,14 @@
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
 import org.apache.mina.transport.socket.nio.DatagramAcceptor;
 import org.apache.mina.transport.socket.nio.DatagramConnector;
+import org.apache.mina.transport.socket.nio.DatagramConnectorConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
-import org.apache.mina.transport.socket.nio.DatagramConnectorConfig;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAddress;
 import org.apache.mina.transport.vmpipe.VmPipeConnector;
@@ -39,15 +38,11 @@
 import java.net.SocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * @version $Revision$
  */
 public class MinaComponent extends DefaultComponent<MinaExchange> {
-    private Map<String, MinaEndpoint> map = new HashMap<String, MinaEndpoint>();
-
     public MinaComponent() {
     }
 
@@ -56,28 +51,22 @@
     }
 
     public synchronized MinaEndpoint createEndpoint(String uri, String[] urlParts) throws
IOException, URISyntaxException {
-        MinaEndpoint endpoint = map.get(uri);
-        if (endpoint == null) {
-            String remainingUrl = uri.substring("mina:".length());
-            URI u = new URI(remainingUrl);
+        String remainingUrl = uri.substring("mina:".length());
+        URI u = new URI(remainingUrl);
 
-            String protocol = u.getScheme();
-            if (protocol.equals("tcp")) {
-                endpoint = createSocketEndpoint(uri, u);
-            }
-            else if (protocol.equals("udp") || protocol.equals("mcast") || protocol.equals("multicast"))
{
-                endpoint = createDatagramEndpoint(uri, u);
-            }
-            else if (protocol.equals("vm")) {
-                endpoint = createVmEndpoint(uri, u);
-            }
-            else {
-                throw new IOException("Unrecognised MINA protocol: " + protocol + " for uri:
" + uri);
-            }
-            map.put(uri, endpoint);
+        String protocol = u.getScheme();
+        if (protocol.equals("tcp")) {
+            return createSocketEndpoint(uri, u);
+        }
+        else if (protocol.equals("udp") || protocol.equals("mcast") || protocol.equals("multicast"))
{
+            return createDatagramEndpoint(uri, u);
+        }
+        else if (protocol.equals("vm")) {
+            return createVmEndpoint(uri, u);
+        }
+        else {
+            throw new IOException("Unrecognised MINA protocol: " + protocol + " for uri:
" + uri);
         }
-
-        return endpoint;
     }
 
     protected MinaEndpoint createVmEndpoint(String uri, URI connectUri) {



Mime
View raw message