camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r627338 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
Date Wed, 13 Feb 2008 10:09:53 GMT
Author: jstrachan
Date: Wed Feb 13 02:09:51 2008
New Revision: 627338

URL: http://svn.apache.org/viewvc?rev=627338&view=rev
Log:
fix for https://issues.apache.org/activemq/browse/CAMEL-334

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=627338&r1=627337&r2=627338&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Wed Feb 13 02:09:51 2008
@@ -49,7 +49,7 @@
 import org.apache.camel.util.FactoryFinder;
 import org.apache.camel.util.NoFactoryAvailableException;
 import org.apache.camel.util.ObjectHelper;
-
+import org.apache.camel.util.ServiceHelper;
 import static org.apache.camel.util.ServiceHelper.startServices;
 import static org.apache.camel.util.ServiceHelper.stopServices;
 import org.apache.commons.logging.Log;
@@ -270,10 +270,15 @@
                     }
 
                     // If it's a singleton then auto register it.
-                    if (answer != null && answer.isSingleton()) {
-                        startServices(answer);
-                        endpoints.put(uri, answer);
-                    	lifecycleStrategy.onEndpointAdd(answer);
+                    if (answer != null) {
+                        addService(answer);
+
+                        if (answer.isSingleton()) {
+                            endpoints.put(uri, answer);
+
+                            // TODO we should support non-singletons in the lifecycle
+                            lifecycleStrategy.onEndpointAdd(answer);
+                        }
                     }
                 } catch (Exception e) {
                     LOG.debug("Failed to resolve endpoint " + uri + ". Reason: " + e, e);
@@ -284,6 +289,7 @@
         return answer;
     }
 
+
     public <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType)
{
         Endpoint endpoint = getEndpoint(name);
         if (endpointType.isInstance(endpoint)) {
@@ -332,9 +338,13 @@
 
     }
 
-    public void addServiceToClose(Object object) {
+    /**
+     * Adds a service, starting it so that it will be stopped with this context
+     */
+    public void addService(Object object) throws Exception {
         if (object instanceof Service) {
             Service service = (Service) object;
+            service.start();
             servicesToClose.add(service);
         }
     }
@@ -472,8 +482,9 @@
         if (routeList != null) {
             for (Route<Exchange> route : routeList) {
                 List<Service> services = route.getServicesForRoute();
-                servicesToClose.addAll(services);
-                startServices(services);
+                for (Service service : services) {
+                    addService(service);
+                }
             }
         }
     }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java?rev=627338&r1=627337&r2=627338&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
Wed Feb 13 02:09:51 2008
@@ -17,7 +17,6 @@
 package org.apache.camel.spring;
 
 import org.apache.camel.*;
-import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.component.bean.BeanProcessor;
 import org.apache.camel.spring.util.ReflectionUtils;
 import org.apache.camel.util.ObjectHelper;
@@ -184,8 +183,7 @@
     }
 
     protected void startService(Service service) throws Exception {
-        service.start();
-        camelContext.addServiceToClose(service);
+        camelContext.addService(service);
     }
 
     /**



Mime
View raw message