activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r520036 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/ main/java/org/apache/camel/queue/ main/java/org/apache/camel/seda/ main/resources/META-INF/services/org/apache/camel/EndpointResolver/ test/java/org/apache/camel/
Date Mon, 19 Mar 2007 18:26:10 GMT
Author: chirino
Date: Mon Mar 19 11:26:09 2007
New Revision: 520036

URL: http://svn.apache.org/viewvc?view=rev&rev=520036
Log:
renamed the seda component to queue

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/
      - copied from r520020, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/
    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-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/queue
      - copied, changed from r520020, activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/seda
Removed:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/SedaEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/SedaEndpointResolver.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/
    activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/seda
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.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=520036&r1=520035&r2=520036
==============================================================================
--- 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 11:26:09 2007
@@ -17,6 +17,10 @@
  */
 package org.apache.camel;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.impl.DefaultEndpointResolver;
 import org.apache.camel.impl.DefaultExchangeConverter;
 
@@ -26,8 +30,10 @@
  * @version $Revision$
  */
 public class CamelContainer<E> {
+	
     private EndpointResolver<E> endpointResolver;
     private ExchangeConverter exchangeConverter;
+    private Map<String, Object> components = (Map<String, Object>)Collections.synchronizedMap(new
HashMap<String, Object>());
 
     public EndpointResolver<E> getEndpointResolver() {
         if (endpointResolver == null) {
@@ -63,4 +69,11 @@
     protected ExchangeConverter createExchangeConverter() {
         return new DefaultExchangeConverter();
     }
+
+	public Map<String, Object> getComponents() {
+		return components;
+	}
+	public void setComponents(Map<String, Object> components) {
+		this.components = Collections.synchronizedMap(components);
+	}
 }

Added: 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=auto&rev=520036
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
Mon Mar 19 11:26:09 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.camel.queue;
+
+import java.util.HashMap;
+import java.util.Queue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+/**
+ * Represents the component that manages {@link QueueEndpoint}.  It holds the 
+ * list of named queues that queue endpoints reference.
+ *
+ * @version $Revision: 519973 $
+ */
+public class QueueComponent<E> {
+	
+    private HashMap<String, Queue<E>> registry = new HashMap<String, Queue<E>>();
+
+	synchronized public Queue<E> getOrCreateQueue(String uri) {
+		Queue<E> queue = registry.get(uri);
+		if( queue == null ) {
+			queue = createQueue();
+			registry.put(uri, queue);
+		}
+		return queue;
+	}
+
+	private Queue<E> createQueue() {
+		return new LinkedBlockingQueue<E>();
+	}
+    
+}

Added: 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=auto&rev=520036
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpoint.java
Mon Mar 19 11:26:09 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.camel.queue;
+
+import java.util.Queue;
+
+import org.apache.camel.CamelContainer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.impl.DefaultExchange;
+
+/**
+ * Represents a queue endpoint that uses a {@link Queue}
+ * object to process inbound exchanges.
+ *
+ * @version $Revision: 519973 $
+ */
+public class QueueEndpoint<E> extends DefaultEndpoint<E> {
+    private Queue<E> queue;
+
+    public QueueEndpoint(String uri, CamelContainer container, Queue<E> queue) {
+        super(uri, container);
+        this.queue = queue;
+    }
+
+    public void send(E exchange) {
+        queue.add(exchange);
+    }
+
+    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. 
+        return (E) new DefaultExchange();
+    }
+
+    public Queue<E> getQueue() {
+        return queue;
+    }
+}

Added: 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=auto&rev=520036
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueEndpointResolver.java
Mon Mar 19 11:26:09 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.camel.queue;
+
+import java.util.Queue;
+
+import org.apache.camel.CamelContainer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointResolver;
+
+/**
+ * An implementation of {@link EndpointResolver} that creates 
+ * {@link QueueEndpoint} objects.
+ *
+ * @version $Revision: 519901 $
+ */
+public class QueueEndpointResolver<E> implements EndpointResolver<E> {
+	
+	static QueueComponent defaultComponent = new QueueComponent();
+	
+    public Endpoint<E> resolve(CamelContainer container, String uri) {
+        
+    	// TODO: we could look at the uri scheme to look for a named
+    	// component registered on the container
+    	QueueComponent<E> component = defaultComponent;
+        
+        Queue<E> queue = component.getOrCreateQueue(uri);
+		return new QueueEndpoint<E>(uri, container, queue);
+    }
+
+}

Copied: activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/queue
(from r520020, activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/seda)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/queue?view=diff&rev=520036&p1=activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/seda&r1=520020&p2=activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/queue&r2=520036
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/seda
(original)
+++ activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/queue
Mon Mar 19 11:26:09 2007
@@ -1 +1 @@
-class=org.apache.camel.seda.SedaEndpointResolver
+class=org.apache.camel.queue.QueueEndpointResolver

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java?view=diff&rev=520036&r1=520035&r2=520036
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java Mon
Mar 19 11:26:09 2007
@@ -16,14 +16,14 @@
  */
 package org.apache.camel;
 
-import junit.framework.TestCase;
-import org.apache.camel.builder.RouteBuilder;
-
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Collection;
-import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version $Revision$
@@ -44,7 +44,7 @@
         // START SNIPPET: e1
         RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
             public void configure() {
-                from("seda:a").to("seda:b");
+                from("queue:a").to("queue:b");
             }
         };
         // END SNIPPET: e1
@@ -54,12 +54,12 @@
         assertEquals("Number routes created", 1, routes.size());
         for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
             Endpoint<Exchange> key = route.getKey();
-            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = route.getValue();
 
             assertTrue("Processor should be a SendProcessor but was: " + processor + " with
type: " + processor.getClass().getName(), processor instanceof SendProcessor);
             SendProcessor sendProcessor = (SendProcessor) processor;
-            assertEquals("Endpoint URI", "seda:b", sendProcessor.getDestination().getEndpointUri());
+            assertEquals("Endpoint URI", "queue:b", sendProcessor.getDestination().getEndpointUri());
         }
     }
 
@@ -67,7 +67,7 @@
         // START SNIPPET: e2
         RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
             public void configure() {
-                from("seda:a").filter(headerEquals("foo", "bar")).to("seda:b");
+                from("queue:a").filter(headerEquals("foo", "bar")).to("queue:b");
             }
         };
         // END SNIPPET: e2
@@ -79,14 +79,14 @@
         assertEquals("Number routes created", 1, routes.size());
         for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
             Endpoint<Exchange> key = route.getKey();
-            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = route.getValue();
 
             assertTrue("Processor should be a FilterProcessor but was: " + processor + "
with type: " + processor.getClass().getName(), processor instanceof FilterProcessor);
             FilterProcessor filterProcessor = (FilterProcessor) processor;
 
             SendProcessor sendProcessor = (SendProcessor) filterProcessor.getProcessor();
-            assertEquals("Endpoint URI", "seda:b", sendProcessor.getDestination().getEndpointUri());
+            assertEquals("Endpoint URI", "queue:b", sendProcessor.getDestination().getEndpointUri());
         }
     }
 
@@ -94,10 +94,10 @@
         // START SNIPPET: e3
         RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
             public void configure() {
-                from("seda:a").choice()
-                        .when(headerEquals("foo", "bar")).to("seda:b")
-                        .when(headerEquals("foo", "cheese")).to("seda:c")
-                        .otherwise().to("seda:d");
+                from("queue:a").choice()
+                        .when(headerEquals("foo", "bar")).to("queue:b")
+                        .when(headerEquals("foo", "cheese")).to("queue:c")
+                        .otherwise().to("queue:d");
             }
         };
         // END SNIPPET: e3
@@ -109,7 +109,7 @@
         assertEquals("Number routes created", 1, routes.size());
         for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
             Endpoint<Exchange> key = route.getKey();
-            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = route.getValue();
 
             assertTrue("Processor should be a ChoiceProcessor but was: " + processor + "
with type: " + processor.getClass().getName(), processor instanceof ChoiceProcessor);
@@ -119,12 +119,12 @@
             assertEquals("Should be two when clauses", 2, filters.size());
 
             FilterProcessor<Exchange> filter1 = filters.get(0);
-            assertSendTo(filter1.getProcessor(), "seda:b");
+            assertSendTo(filter1.getProcessor(), "queue:b");
 
             FilterProcessor<Exchange> filter2 = filters.get(1);
-            assertSendTo(filter2.getProcessor(), "seda:c");
+            assertSendTo(filter2.getProcessor(), "queue:c");
 
-            assertSendTo(choiceProcessor.getOtherwise(), "seda:d");
+            assertSendTo(choiceProcessor.getOtherwise(), "queue:d");
         }
     }
 
@@ -138,7 +138,7 @@
 
         RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
             public void configure() {
-                from("seda:a").process(myProcessor);
+                from("queue:a").process(myProcessor);
             }
         };
         // END SNIPPET: e4
@@ -149,7 +149,7 @@
         assertEquals("Number routes created", 1, routes.size());
         for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
             Endpoint<Exchange> key = route.getKey();
-            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = route.getValue();
 
             assertEquals("Should be called with my processor", myProcessor, processor);
@@ -160,7 +160,7 @@
         // START SNIPPET: e5
         RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
             public void configure() {
-                from("seda:a").filter(headerEquals("foo", "bar")).process(myProcessor);
+                from("queue:a").filter(headerEquals("foo", "bar")).process(myProcessor);
             }
         };
         // END SNIPPET: e5
@@ -172,7 +172,7 @@
         assertEquals("Number routes created", 1, routes.size());
         for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
             Endpoint<Exchange> key = route.getKey();
-            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = route.getValue();
 
             assertTrue("Processor should be a FilterProcessor but was: " + processor + "
with type: " + processor.getClass().getName(), processor instanceof FilterProcessor);
@@ -185,7 +185,7 @@
         // START SNIPPET: e6
         RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
             public void configure() {
-                from("seda:a").to("seda:tap", "seda:b");
+                from("queue:a").to("queue:tap", "queue:b");
             }
         };
         // END SNIPPET: e6
@@ -197,7 +197,7 @@
         assertEquals("Number routes created", 1, routes.size());
         for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
             Endpoint<Exchange> key = route.getKey();
-            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = route.getValue();
 
             assertTrue("Processor should be a CompositeProcessor but was: " + processor +
" with type: " + processor.getClass().getName(), processor instanceof CompositeProcessor);
@@ -205,8 +205,8 @@
             List<Processor<Exchange>> processors = new ArrayList<Processor<Exchange>>(compositeProcessor.getProcessors());
             assertEquals("Should have 2 processors", 2, processors.size());
 
-            assertSendTo(processors.get(0), "seda:tap");
-            assertSendTo(processors.get(1), "seda:b");
+            assertSendTo(processors.get(0), "queue:tap");
+            assertSendTo(processors.get(1), "queue:b");
         }
     }
 



Mime
View raw message