Author: davsclaus
Date: Fri Sep 28 09:25:55 2012
New Revision: 1391376
URL: http://svn.apache.org/viewvc?rev=1391376&view=rev
Log:
CAMEL-5561: ExecutorServiceManagement should shutdown after services
Modified:
camel/branches/camel-2.9.x/ (props changed)
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1391373
Merged /camel/branches/camel-2.10.x:r1391374
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1391376&r1=1391375&r2=1391376&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Fri Sep 28 09:25:55 2012
@@ -866,7 +866,10 @@ public class DefaultCamelContext extends
}
public void addService(Object object) throws Exception {
+ doAddService(object, true);
+ }
+ private void doAddService(Object object, boolean closeOnShutdown) throws
Exception {
// inject CamelContext
if (object instanceof CamelContextAware) {
CamelContextAware aware = (CamelContextAware) object;
@@ -894,7 +897,7 @@ public class DefaultCamelContext extends
// do not add endpoints as they have their own list
if (singleton && !(service instanceof Endpoint)) {
// only add to list of services to close if its not already
there
- if (!hasService(service)) {
+ if (closeOnShutdown && !hasService(service)) {
servicesToClose.add(service);
}
}
@@ -1512,7 +1515,8 @@ public class DefaultCamelContext extends
// and we needed to create endpoints up-front as it may be accessed
before this context is started
endpoints = new EndpointRegistry(this, endpoints);
addService(endpoints);
- addService(executorServiceManager);
+ // special for executorServiceManager as want to stop it manually
+ doAddService(executorServiceManager, false);
addService(producerServicePool);
addService(inflightRepository);
addService(shutdownStrategy);
@@ -1596,7 +1600,8 @@ public class DefaultCamelContext extends
shutdownServices(notifier);
}
- // shutdown management as the last one
+ // shutdown executor service and management as the last one
+ shutdownServices(executorServiceManager);
shutdownServices(managementStrategy);
shutdownServices(lifecycleStrategies);
// do not clear lifecycleStrategies as we can start Camel again and
get the route back as before