activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r519973 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/seda/ camel-jms/src/...
Date Mon, 19 Mar 2007 15:35:29 GMT
Author: jstrachan
Date: Mon Mar 19 08:35:28 2007
New Revision: 519973

URL: http://svn.apache.org/viewvc?view=rev&rev=519973
Log:
added a CamelContainer to act as the provider of the various polciies (resolvers, converters
etc)

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java   (with
props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointResolver.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/SedaEndpoint.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java

Added: 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=auto&rev=519973
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java Mon
Mar 19 08:35:28 2007
@@ -0,0 +1,66 @@
+/**
+ *
+ * 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;
+
+import org.apache.camel.impl.DefaultEndpointResolver;
+import org.apache.camel.impl.DefaultExchangeConverter;
+
+/**
+ * Represents the container used to configure routes and the policies to use.
+ *
+ * @version $Revision$
+ */
+public class CamelContainer<E> {
+    private EndpointResolver<E> endpointResolver;
+    private ExchangeConverter exchangeConverter;
+
+    public EndpointResolver<E> getEndpointResolver() {
+        if (endpointResolver == null) {
+            endpointResolver = createEndpointResolver();
+        }
+        return endpointResolver;
+    }
+
+    public void setEndpointResolver(EndpointResolver<E> endpointResolver) {
+        this.endpointResolver = endpointResolver;
+    }
+
+    public ExchangeConverter getExchangeConverter() {
+        if (exchangeConverter == null) {
+            exchangeConverter = createExchangeConverter();
+        }
+        return exchangeConverter;
+    }
+
+    public void setExchangeConverter(ExchangeConverter exchangeConverter) {
+        this.exchangeConverter = exchangeConverter;
+    }
+
+    // Implementation methods
+    //-----------------------------------------------------------------------
+    protected EndpointResolver<E> createEndpointResolver() {
+        return new DefaultEndpointResolver<E>(this);
+    }
+
+    /**
+     * Lazily create a default exchange converter implementation
+     */
+    protected ExchangeConverter createExchangeConverter() {
+        return new DefaultExchangeConverter();
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?view=diff&rev=519973&r1=519972&r2=519973
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
Mon Mar 19 08:35:28 2007
@@ -21,6 +21,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
+import org.apache.camel.CamelContainer;
 import org.apache.camel.impl.DefaultEndpointResolver;
 import org.apache.camel.util.ObjectHelper;
 
@@ -36,7 +37,7 @@
  * @version $Revision$
  */
 public abstract class RouteBuilder<E extends Exchange> {
-    private EndpointResolver<E> endpointResolver;
+    private CamelContainer<E> container;
     private List<DestinationBuilder<E>> destinationBuilders = new ArrayList<DestinationBuilder<E>>();
     private AtomicBoolean initalized = new AtomicBoolean(false);
     private Map<Endpoint<E>, Processor<E>> routeMap = new HashMap<Endpoint<E>,
Processor<E>>();
@@ -50,7 +51,7 @@
      * Resolves the given URI to an endpoint
      */
     public Endpoint<E> endpoint(String uri) {
-        return getEndpointResolver().resolve(uri);
+        return getContainer().getEndpointResolver().resolve(uri);
     }
 
     public DestinationBuilder<E> from(String uri) {
@@ -81,6 +82,17 @@
     // Properties
     //-----------------------------------------------------------------------
 
+    public CamelContainer<E> getContainer() {
+        if (container == null) {
+            container = createContainer();
+        }
+        return container;
+    }
+
+    public void setContainer(CamelContainer<E> container) {
+        this.container = container;
+    }
+
     /**
      * Returns the routing map from inbound endpoints to processors
      */
@@ -97,23 +109,9 @@
         return destinationBuilders;
     }
 
-    public EndpointResolver<E> getEndpointResolver() {
-        if (endpointResolver == null) {
-            endpointResolver = createEndpointResolver();
-        }
-        return endpointResolver;
-    }
-
-    public void setEndpointResolver(EndpointResolver<E> endpointResolver) {
-        this.endpointResolver = endpointResolver;
-    }
 
     // Implementation methods
     //-----------------------------------------------------------------------
-    protected EndpointResolver<E> createEndpointResolver() {
-        return new DefaultEndpointResolver<E>();
-    }
-
     protected void checkInitialized() {
         if (initalized.compareAndSet(false, true)) {
             configure();
@@ -131,4 +129,9 @@
             routeMap.put(from, processor);
         }
     }
+
+    protected CamelContainer<E> createContainer() {
+        return new CamelContainer<E>();
+    }
+
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java?view=diff&rev=519973&r1=519972&r2=519973
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
Mon Mar 19 08:35:28 2007
@@ -19,6 +19,7 @@
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangeConverter;
+import org.apache.camel.CamelContainer;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -26,11 +27,11 @@
  */
 public abstract class DefaultEndpoint<E> implements Endpoint<E> {
     private String endpointUri;
-    private ExchangeConverter exchangeConverter;
+    private CamelContainer container;
 
-    protected DefaultEndpoint(String endpointUri, ExchangeConverter exchangeConverter) {
+    protected DefaultEndpoint(String endpointUri, CamelContainer container) {
         this.endpointUri = endpointUri;
-        this.exchangeConverter = exchangeConverter;
+        this.container = container;
     }
 
     public int hashCode() {
@@ -55,8 +56,8 @@
         return endpointUri;
     }
 
-    public ExchangeConverter getExchangeConverter() {
-        return exchangeConverter;
+    public CamelContainer getContainer() {
+        return container;
     }
 
     /**
@@ -67,7 +68,7 @@
         if (type.isInstance(exchange)) {
             return type.cast(exchange);
         }
-        return getExchangeConverter().convertTo(type, exchange);
+        return getContainer().getExchangeConverter().convertTo(type, exchange);
     }
 
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointResolver.java?view=diff&rev=519973&r1=519972&r2=519973
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointResolver.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointResolver.java
Mon Mar 19 08:35:28 2007
@@ -19,6 +19,7 @@
 import org.apache.camel.EndpointResolver;
 import org.apache.camel.Endpoint;
 import org.apache.camel.ExchangeConverter;
+import org.apache.camel.CamelContainer;
 import org.apache.camel.seda.SedaEndpoint;
 
 /**
@@ -27,35 +28,16 @@
  * @version $Revision$
  */
 public class DefaultEndpointResolver<E> implements EndpointResolver<E> {
-    private ExchangeConverter exchangeConverter;
+    private final CamelContainer container;
 
-    public DefaultEndpointResolver() {
+    public DefaultEndpointResolver(CamelContainer container) {
+        this.container = container;
     }
 
-    public DefaultEndpointResolver(ExchangeConverter exchangeConverter) {
-        this.exchangeConverter = exchangeConverter;
-    }
     public Endpoint<E> resolve(String uri) {
         // TODO we may want to cache them?
-        return new SedaEndpoint<E>(uri, getExchangeConverter());
-    }
-
-    public ExchangeConverter getExchangeConverter() {
-        if (exchangeConverter == null) {
-            exchangeConverter =           createExchangeConverter();
-        }
-        return exchangeConverter;
+        return new SedaEndpoint<E>(uri, container);
     }
 
-    public void setExchangeConverter(ExchangeConverter exchangeConverter) {
-        this.exchangeConverter = exchangeConverter;
-    }
-
-    /**
-     * Lazily create a default exchange converter implementation
-     */
-    protected ExchangeConverter createExchangeConverter() {
-        return new DefaultExchangeConverter();
-    }
 
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/SedaEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/SedaEndpoint.java?view=diff&rev=519973&r1=519972&r2=519973
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/SedaEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/seda/SedaEndpoint.java
Mon Mar 19 08:35:28 2007
@@ -19,6 +19,7 @@
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.ExchangeConverter;
+import org.apache.camel.CamelContainer;
 
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -32,12 +33,12 @@
 public class SedaEndpoint<E> extends DefaultEndpoint<E> {
     private Queue queue;
 
-    public SedaEndpoint(String uri, ExchangeConverter exchangeConverter) {
-        this(uri, exchangeConverter, new ConcurrentLinkedQueue());
+    public SedaEndpoint(String uri, CamelContainer container) {
+        this(uri, container, new ConcurrentLinkedQueue());
     }
 
-    public SedaEndpoint(String uri, ExchangeConverter exchangeConverter, Queue queue) {
-        super(uri, exchangeConverter);
+    public SedaEndpoint(String uri, CamelContainer container, Queue queue) {
+        super(uri, container);
         this.queue = queue;
     }
 

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java?view=diff&rev=519973&r1=519972&r2=519973
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java Mon
Mar 19 08:35:28 2007
@@ -18,6 +18,7 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangeConverter;
+import org.apache.camel.CamelContainer;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.springframework.jms.core.JmsOperations;
 import org.springframework.jms.core.MessageCreator;
@@ -36,8 +37,8 @@
     private Destination destination;
 
 
-    public JmsEndpoint(String uri, ExchangeConverter exchangeConverter, Destination destination,
JmsOperations template) {
-        super(uri, exchangeConverter);
+    public JmsEndpoint(String uri, CamelContainer container, Destination destination, JmsOperations
template) {
+        super(uri, container);
         this.destination = destination;
         this.template = template;
     }



Mime
View raw message