camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1151762 [1/4] - in /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/component/bean/ camel-core/src/main/java/org/apache/camel/component/da...
Date Thu, 28 Jul 2011 08:40:15 GMT
Author: cschneider
Date: Thu Jul 28 08:39:35 2011
New Revision: 1151762

URL: http://svn.apache.org/viewvc?rev=1151762&view=rev
Log:
CAMEL-4244 refactored ExecutorServiceStrategy

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java   (contents, props changed)
      - copied, changed from r1148261, camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java   (contents, props changed)
      - copied, changed from r1147828, camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ThreadPoolFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/CamelThreadFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ThreadHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceManagerTest.java   (contents, props changed)
      - copied, changed from r1149056, camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java
Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/concurrent/ExecutorServiceHelperTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/CamelInvocationHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThreadPoolProfileSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSendProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/DataFormatDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnCompletionDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadPoolProfileDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottleDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/InterceptorToAsyncProcessorBridge.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StreamResequencer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/resequencer/ResequencerEngine.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ThreadPoolProfile.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/AsyncProcessorHelper.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/SubmitOrderedCompletionService.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/view/RouteDotGenerator.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ThreadPoolBuilderTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAttachmentAnnotationTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/SendingToAlotOfDifferentDirectEndpointTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDeleteAndMoveFailedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveNoopTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceAppendTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/XPathToFileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOnlyChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutBigChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutChainedWithOnCompletionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaMultipleConsumersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/stream/FileInputStreamCacheTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelCustomDefaultThreadPoolProfileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/InflightRepositoryRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/NeilSplitterTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/SplitWithCustomAggregationStrategyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/XPathSplitStreamTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/DualManagedThreadPoolProfileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThreadPoolProfileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListNoMethodNameTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BreadcrumbTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FlipRoutePolicy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionAsyncTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionUseOriginalBodyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipeientListWithSimpleExpressionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListIgnoreInvalidEndpointsTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListParallelAggregateThreadPoolIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetBodyProcessorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetHeaderTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownSedaAndDirectEndpointTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimulatorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterNoAggregationStrategyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterStreamingUoWIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterUoWIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateExpressionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateShutdownThreadPoolTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateThreadPoolProfileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AlbertoAggregatorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/SplitRouteNumberOfProcessorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncDeadLetterChannelExecutorServiceRefTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncDefaultErrorHandlerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRecipientList4Test.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncProducer.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWhenNoStopTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWhenTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWhenWithChoiceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorFactoryCreatesHandlerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/DefaultTimeoutMapTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SSLContextParametersTest.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java
    camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
    camel/trunk/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsProducer.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteRequestReplyTest.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/async/MyAsyncProducer.java
    camel/trunk/components/camel-kestrel/src/main/java/org/apache/camel/component/kestrel/KestrelComponent.java
    camel/trunk/components/camel-kestrel/src/main/java/org/apache/camel/component/kestrel/KestrelConsumer.java
    camel/trunk/components/camel-kestrel/src/main/java/org/apache/camel/component/kestrel/KestrelEndpoint.java
    camel/trunk/components/camel-kestrel/src/main/java/org/apache/camel/component/kestrel/KestrelProducer.java
    camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
    camel/trunk/components/camel-nagios/src/main/java/org/apache/camel/component/nagios/NagiosProducer.java
    camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
    camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
    camel/trunk/components/camel-routebox/src/main/java/org/apache/camel/component/routebox/direct/RouteboxDirectConsumer.java
    camel/trunk/components/camel-routebox/src/main/java/org/apache/camel/component/routebox/seda/RouteboxSedaConsumer.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelThreadPoolFactoryBean.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltReferenceParameterTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ConsumerTemplateHasTwoTemplatesTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ConsumerTemplateMaximumCacheSizeTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategy.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DefaultPackageResolverConfigureTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomDefaultThreadPoolProfileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionHandledAndRollbackTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/CamelRouteRefInjectionIssueTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/MyInjectionRouteBuilder.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRecipientListIgnoreInvalidEndpointsTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalMessageTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/ProduceTemplateTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java
    camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/jaxrs/testbean/CustomerServiceResource.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Thu Jul 28 08:39:35 2011
@@ -32,7 +32,7 @@ import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.DataFormatResolver;
 import org.apache.camel.spi.Debugger;
 import org.apache.camel.spi.EndpointStrategy;
-import org.apache.camel.spi.ExecutorServiceStrategy;
+import org.apache.camel.spi.ExecutorServiceManager;
 import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.FactoryFinderResolver;
 import org.apache.camel.spi.InflightRepository;
@@ -914,14 +914,14 @@ public interface CamelContext extends Su
      *
      * @return the strategy
      */
-    ExecutorServiceStrategy getExecutorServiceStrategy();
+    ExecutorServiceManager getExecutorServiceManager();
 
     /**
      * Sets a custom {@link org.apache.camel.spi.ExecutorServiceStrategy}
      *
      * @param executorServiceStrategy the custom strategy
      */
-    void setExecutorServiceStrategy(ExecutorServiceStrategy executorServiceStrategy);
+    void setExecutorServiceManager(ExecutorServiceManager executorServiceStrategy);
 
     /**
      * Gets the current {@link org.apache.camel.spi.ProcessorFactory}
@@ -1007,6 +1007,4 @@ public interface CamelContext extends Su
      */
     void setUseBreadcrumb(Boolean useBreadcrumb);
 
-
-
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java Thu Jul 28 08:39:35 2011
@@ -20,7 +20,6 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.NoSuchEndpointException;
-import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.DeadLetterChannel;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java Thu Jul 28 08:39:35 2011
@@ -24,9 +24,7 @@ import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.DefaultErrorHandler;
-import org.apache.camel.processor.ErrorHandlerSupport;
 import org.apache.camel.processor.RedeliveryPolicy;
-import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.RouteContext;
 import org.slf4j.LoggerFactory;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java Thu Jul 28 08:39:35 2011
@@ -19,7 +19,6 @@ package org.apache.camel.builder;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java Thu Jul 28 08:39:35 2011
@@ -17,13 +17,11 @@
 package org.apache.camel.builder;
 
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionHandler;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ThreadPoolRejectedPolicy;
-import org.apache.camel.model.ThreadPoolProfileDefinition;
-import org.apache.camel.util.CamelContextHelper;
+import org.apache.camel.spi.ThreadPoolProfile;
 
 /**
  * A builder to create thread pools.
@@ -32,75 +30,136 @@ import org.apache.camel.util.CamelContex
  */
 public final class ThreadPoolBuilder {
 
-    private final CamelContext camelContext;
-    private ThreadPoolProfileDefinition threadPoolDefinition;
+    private ThreadPoolProfile profile;
+    
+    @Deprecated
+    private CamelContext context;
 
-    public ThreadPoolBuilder(CamelContext camelContext) {
-        this.camelContext = camelContext;
-        // use the default thread profile as the base
-        this.threadPoolDefinition = new ThreadPoolProfileDefinition(camelContext.getExecutorServiceStrategy().getDefaultThreadPoolProfile());
+    @Deprecated
+    public ThreadPoolBuilder(CamelContext context) {
+        this.context = context;
+        this.profile = new ThreadPoolProfile();
+    }
+    
+    public ThreadPoolBuilder(String name) {
+        this.profile = new ThreadPoolProfile(name);
+    }
+    
+    public ThreadPoolBuilder defaultProfile(Boolean defaultProfile) {
+        profile.setDefaultProfile(defaultProfile);
+        return this;
     }
 
-    public ThreadPoolBuilder poolSize(int poolSize) {
-        threadPoolDefinition.poolSize(poolSize);
+    public ThreadPoolBuilder poolSize(Integer poolSize) {
+        profile.setPoolSize(poolSize);
         return this;
     }
 
-    public ThreadPoolBuilder maxPoolSize(int maxPoolSize) {
-        threadPoolDefinition.maxPoolSize(maxPoolSize);
+    public ThreadPoolBuilder maxPoolSize(Integer maxPoolSize) {
+        profile.setMaxPoolSize(maxPoolSize);
+        return this;
+    }
+    
+    public ThreadPoolBuilder keepAliveTime(Integer keepAliveTime) {
+        profile.setKeepAliveTime(keepAliveTime.longValue());
         return this;
     }
 
-    public ThreadPoolBuilder keepAliveTime(long keepAliveTime) {
-        threadPoolDefinition.keepAliveTime(keepAliveTime);
+    public ThreadPoolBuilder keepAliveTime(Long keepAliveTime) {
+        profile.setKeepAliveTime(keepAliveTime);
+        return this;
+    }
+    
+    public ThreadPoolBuilder keepAliveTime(Integer keepAliveTime, TimeUnit timeUnit) {
+        if (keepAliveTime != null) {
+            profile.setKeepAliveTime(keepAliveTime.longValue());
+        }
+        profile.setTimeUnit(timeUnit);
+        return this;
+    }
+    
+    public ThreadPoolBuilder keepAliveTime(Long keepAliveTime, TimeUnit timeUnit) {
+        profile.setKeepAliveTime(keepAliveTime);
+        profile.setTimeUnit(timeUnit);
         return this;
     }
 
     public ThreadPoolBuilder timeUnit(TimeUnit timeUnit) {
-        threadPoolDefinition.timeUnit(timeUnit);
+        profile.setTimeUnit(timeUnit);
         return this;
     }
 
-    public ThreadPoolBuilder maxQueueSize(int maxQueueSize) {
-        threadPoolDefinition.maxQueueSize(maxQueueSize);
+    public ThreadPoolBuilder maxQueueSize(Integer maxQueueSize) {
+        profile.setMaxQueueSize(maxQueueSize);
         return this;
     }
 
     public ThreadPoolBuilder rejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) {
-        threadPoolDefinition.rejectedPolicy(rejectedPolicy);
+        profile.setRejectedPolicy(rejectedPolicy);
+        return this;
+    }
+    
+    public ThreadPoolBuilder daemon() {
+        profile.setDaemon(true);
+        return this;
+    }
+    
+    public ThreadPoolBuilder daemon(Boolean daemon) {
+        profile.setDaemon(daemon);
+        return this;
+    }
+    
+
+    public ThreadPoolBuilder threadName(String name) {
+        profile.setThreadName(name);
         return this;
     }
 
+
+    public ThreadPoolProfile build() {
+        return this.profile;
+    }
+
     /**
      * Builds the new thread pool
+     * @deprecated use build instead and fetch the ExecutorService from the ExecutorServiceManager 
      *
      * @param name name which is appended to the thread name
      * @return the created thread pool
      * @throws Exception is thrown if error building the thread pool
      */
+    @Deprecated
     public ExecutorService build(String name) throws Exception {
         return build(null, name);
     }
 
     /**
      * Builds the new thread pool
+     * @deprecated use build instead and fetch the ExecutorService from the ExecutorServiceManager
      *
      * @param source the source object, usually it should be <tt>this</tt> passed in as parameter
      * @param name   name which is appended to the thread name
      * @return the created thread pool
      * @throws Exception is thrown if error building the thread pool
      */
+    @Deprecated
     public ExecutorService build(Object source, String name) throws Exception {
-        int size = CamelContextHelper.parseInteger(camelContext, threadPoolDefinition.getPoolSize());
-        int max = CamelContextHelper.parseInteger(camelContext, threadPoolDefinition.getMaxPoolSize());
-        long keepAlive = CamelContextHelper.parseLong(camelContext, threadPoolDefinition.getKeepAliveTime());
-        int queueSize = CamelContextHelper.parseInteger(camelContext, threadPoolDefinition.getMaxQueueSize());
-        TimeUnit unit = threadPoolDefinition.getTimeUnit();
-        RejectedExecutionHandler handler = threadPoolDefinition.getRejectedExecutionHandler();
-
-        ExecutorService answer = camelContext.getExecutorServiceStrategy().newThreadPool(source, name,
-                size, max, keepAlive, unit, queueSize, handler, true);
-        return answer;
+        profile.setId(name);
+        return context.getExecutorServiceManager().getExecutorService(profile, source);
+
+    }
+
+
+    public static ThreadPoolProfile singleThreadExecutor(String id) {
+        return new ThreadPoolBuilder(id).poolSize(1).maxPoolSize(1).build();
+    }
+    
+    public static ThreadPoolProfile fixedThreadExecutor(String id, int poolSize) {
+        return new ThreadPoolBuilder(id)
+            .poolSize(poolSize)
+            .maxPoolSize(poolSize)
+            .keepAliveTime(0L, TimeUnit.MILLISECONDS)
+            .build();
     }
 
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java Thu Jul 28 08:39:35 2011
@@ -28,7 +28,6 @@ import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.util.AsyncProcessorHelper;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/CamelInvocationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/CamelInvocationHandler.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/CamelInvocationHandler.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/CamelInvocationHandler.java Thu Jul 28 08:39:35 2011
@@ -222,11 +222,7 @@ public class CamelInvocationHandler impl
         // CamelContext will shutdown thread pool when it shutdown so we can lazy create it on demand
         // but in case of hot-deploy or the likes we need to be able to re-create it (its a shared static instance)
         if (executorService == null || executorService.isTerminated() || executorService.isShutdown()) {
-            // try to lookup a pool first based on id/profile
-            executorService = context.getExecutorServiceStrategy().lookup(CamelInvocationHandler.class, "CamelInvocationHandler", "CamelInvocationHandler");
-            if (executorService == null) {
-                executorService = context.getExecutorServiceStrategy().newDefaultThreadPool(CamelInvocationHandler.class, "CamelInvocationHandler");
-            }
+            executorService = context.getExecutorServiceManager().getDefaultExecutorService("CamelInvocationHandler", CamelInvocationHandler.class);
         }
         return executorService;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java Thu Jul 28 08:39:35 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.bean;
 
+import static org.apache.camel.util.ObjectHelper.asString;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.AnnotatedElement;
@@ -50,8 +52,6 @@ import org.apache.camel.util.StringHelpe
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.util.ObjectHelper.asString;
-
 /**
  * Information about a method to be used for invocation.
  *
@@ -158,13 +158,13 @@ public class MethodInfo {
             recipientList.setShareUnitOfWork(annotation.shareUnitOfWork());
 
             if (ObjectHelper.isNotEmpty(annotation.executorServiceRef())) {
-                ExecutorService executor = CamelContextHelper.mandatoryLookup(camelContext, annotation.executorServiceRef(), ExecutorService.class);
+                ExecutorService executor = camelContext.getExecutorServiceManager().getDefaultExecutorService(annotation.executorServiceRef(), this);
                 recipientList.setExecutorService(executor);
             }
 
             if (annotation.parallelProcessing() && recipientList.getExecutorService() == null) {
                 // we are running in parallel so we need a thread pool
-                ExecutorService executor = camelContext.getExecutorServiceStrategy().newDefaultThreadPool(this, "@RecipientList");
+                ExecutorService executor = camelContext.getExecutorServiceManager().getDefaultExecutorService("@RecipientList", this);
                 recipientList.setExecutorService(executor);
             }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java Thu Jul 28 08:39:35 2011
@@ -21,8 +21,10 @@ import java.util.concurrent.ExecutorServ
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ThreadPoolBuilder;
 import org.apache.camel.impl.DefaultConsumer;
 import org.apache.camel.processor.ThroughputLogger;
+import org.apache.camel.spi.ThreadPoolProfile;
 
 /**
  * DataSet consumer.
@@ -52,9 +54,8 @@ public class DataSetConsumer extends Def
         final long preloadSize = endpoint.getPreloadSize();
 
         sendMessages(0, preloadSize);
-
-        executorService = camelContext.getExecutorServiceStrategy()
-                .newSingleThreadExecutor(this, endpoint.getEndpointUri());
+        ThreadPoolProfile profile = ThreadPoolBuilder.singleThreadExecutor(endpoint.getEndpointUri());
+        executorService = camelContext.getExecutorServiceManager().getExecutorService(profile, this);
 
         executorService.execute(new Runnable() {
             public void run() {
@@ -77,7 +78,7 @@ public class DataSetConsumer extends Def
         super.doStop();
 
         if (executorService != null) {
-            camelContext.getExecutorServiceStrategy().shutdownNow(executorService);
+            camelContext.getExecutorServiceManager().shutdownNow(executorService);
             executorService = null;
         }
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java Thu Jul 28 08:39:35 2011
@@ -21,7 +21,6 @@ import java.io.FileNotFoundException;
 
 import org.apache.camel.Component;
 import org.apache.camel.Exchange;
-import org.apache.camel.FailedToCreateConsumerException;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java Thu Jul 28 08:39:35 2011
@@ -30,12 +30,14 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.ShutdownRunningTask;
 import org.apache.camel.SuspendableService;
+import org.apache.camel.builder.ThreadPoolBuilder;
 import org.apache.camel.impl.LoggingExceptionHandler;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
 import org.apache.camel.processor.MulticastProcessor;
 import org.apache.camel.spi.ExceptionHandler;
 import org.apache.camel.spi.ShutdownAware;
+import org.apache.camel.spi.ThreadPoolProfile;
 import org.apache.camel.util.AsyncProcessorHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -248,7 +250,7 @@ public class SedaConsumer extends Servic
     protected void doShutdown() throws Exception {
         // only shutdown thread pool when we shutdown
         if (executor != null) {
-            endpoint.getCamelContext().getExecutorServiceStrategy().shutdownNow(executor);
+            endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor);
             executor = null;
         }
     }
@@ -261,8 +263,8 @@ public class SedaConsumer extends Servic
 
         // create thread pool if needed
         if (executor == null) {
-            executor = endpoint.getCamelContext().getExecutorServiceStrategy()
-                    .newFixedThreadPool(this, endpoint.getEndpointUri(), poolSize);
+            ThreadPoolProfile profile = ThreadPoolBuilder.fixedThreadExecutor(endpoint.getEndpointUri(), poolSize);
+            executor = endpoint.getCamelContext().getExecutorServiceManager().getExecutorService(profile, this);
         }
 
         // submit needed number of tasks

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java Thu Jul 28 08:39:35 2011
@@ -118,13 +118,13 @@ public class SedaEndpoint extends Defaul
         int size = getConsumers().size();
         if (size == 0 && multicastExecutor != null) {
             // stop the multicast executor as its not needed anymore when size is zero
-            getCamelContext().getExecutorServiceStrategy().shutdown(multicastExecutor);
+            getCamelContext().getExecutorServiceManager().shutdown(multicastExecutor);
             multicastExecutor = null;
         }
         if (size > 1) {
             if (multicastExecutor == null) {
                 // create multicast executor as we need it when we have more than 1 processor
-                multicastExecutor = getCamelContext().getExecutorServiceStrategy().newDefaultThreadPool(this, getEndpointUri() + "(multicast)");
+                multicastExecutor = getCamelContext().getExecutorServiceManager().getDefaultExecutorService(getEndpointUri() + "(multicast)", this);
             }
             // create list of consumers to multicast to
             List<Processor> processors = new ArrayList<Processor>(size);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Thu Jul 28 08:39:35 2011
@@ -34,6 +34,7 @@ import java.util.TreeMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.naming.Context;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
@@ -91,7 +92,7 @@ import org.apache.camel.spi.DataFormatRe
 import org.apache.camel.spi.Debugger;
 import org.apache.camel.spi.EndpointStrategy;
 import org.apache.camel.spi.EventNotifier;
-import org.apache.camel.spi.ExecutorServiceStrategy;
+import org.apache.camel.spi.ExecutorServiceManager;
 import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.FactoryFinderResolver;
 import org.apache.camel.spi.InflightRepository;
@@ -193,7 +194,7 @@ public class DefaultCamelContext extends
     private ShutdownStrategy shutdownStrategy = new DefaultShutdownStrategy(this);
     private ShutdownRoute shutdownRoute = ShutdownRoute.Default;
     private ShutdownRunningTask shutdownRunningTask = ShutdownRunningTask.CompleteCurrentTaskOnly;
-    private ExecutorServiceStrategy executorServiceStrategy = new DefaultExecutorServiceStrategy(this);
+    private ExecutorServiceManager executorServiceManager;
     private Debugger debugger;
     private UuidGenerator uuidGenerator = createDefaultUuidGenerator();
     private final StopWatch stopWatch = new StopWatch(false);
@@ -201,6 +202,7 @@ public class DefaultCamelContext extends
 
     public DefaultCamelContext() {
         super();
+        this.executorServiceManager = new DefaultExecutorServiceManager(this, new DefaultThreadPoolFactory());
 
         // create endpoint registry at first since end users may access endpoints before CamelContext is started
         this.endpoints = new EndpointRegistry(this);
@@ -1436,7 +1438,7 @@ 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(executorServiceStrategy);
+        addService(executorServiceManager);
         addService(producerServicePool);
         addService(inflightRepository);
         addService(shutdownStrategy);
@@ -2254,12 +2256,12 @@ public class DefaultCamelContext extends
         this.shutdownRunningTask = shutdownRunningTask;
     }
 
-    public ExecutorServiceStrategy getExecutorServiceStrategy() {
-        return executorServiceStrategy;
+    public ExecutorServiceManager getExecutorServiceManager() {
+        return this.executorServiceManager;
     }
 
-    public void setExecutorServiceStrategy(ExecutorServiceStrategy executorServiceStrategy) {
-        this.executorServiceStrategy = executorServiceStrategy;
+    public void setExecutorServiceManager(ExecutorServiceManager executorServiceManager) {
+        this.executorServiceManager = executorServiceManager;
     }
 
     public ProcessorFactory getProcessorFactory() {

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java (from r1148261, camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java&r1=1148261&r2=1151762&rev=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java Thu Jul 28 08:39:35 2011
@@ -22,52 +22,54 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.ThreadPoolRejectedPolicy;
+import org.apache.camel.builder.ThreadPoolBuilder;
 import org.apache.camel.model.OptionalIdentifiedDefinition;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.ProcessorDefinitionHelper;
 import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.spi.ExecutorServiceStrategy;
+import org.apache.camel.spi.ExecutorServiceManager;
 import org.apache.camel.spi.LifecycleStrategy;
+import org.apache.camel.spi.ThreadPoolFactory;
 import org.apache.camel.spi.ThreadPoolProfile;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.concurrent.ExecutorServiceHelper;
+import org.apache.camel.util.concurrent.CamelThreadFactory;
+import org.apache.camel.util.concurrent.SynchronousExecutorService;
+import org.apache.camel.util.concurrent.ThreadHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * @version 
  */
-public class DefaultExecutorServiceStrategy extends ServiceSupport implements ExecutorServiceStrategy {
-
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultExecutorServiceStrategy.class);
+public class DefaultExecutorServiceManager extends ServiceSupport implements ExecutorServiceManager {
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultExecutorServiceManager.class);
+    
     private final List<ExecutorService> executorServices = new ArrayList<ExecutorService>();
-    private final CamelContext camelContext;
     private String threadNamePattern;
-    private String defaultThreadPoolProfileId;
     private final Map<String, ThreadPoolProfile> threadPoolProfiles = new HashMap<String, ThreadPoolProfile>();
+    private ThreadPoolProfile defaultProfile;
+    private CamelContext camelContext;
+    private ThreadPoolFactory threadPoolFactory;
 
-    public DefaultExecutorServiceStrategy(CamelContext camelContext) {
+    public DefaultExecutorServiceManager(CamelContext camelContext, ThreadPoolFactory threadPoolFactory) {
         this.camelContext = camelContext;
-
-        // create and register the default profile
-        this.defaultThreadPoolProfileId = "defaultThreadPoolProfile";
-        ThreadPoolProfile defaultProfile = new ThreadPoolProfileSupport(defaultThreadPoolProfileId);
-        // the default profile has the following values
-        defaultProfile.setDefaultProfile(true);
-        defaultProfile.setPoolSize(10);
-        defaultProfile.setMaxPoolSize(20);
-        defaultProfile.setKeepAliveTime(60L);
-        defaultProfile.setTimeUnit(TimeUnit.SECONDS);
-        defaultProfile.setMaxQueueSize(1000);
-        defaultProfile.setRejectedPolicy(ThreadPoolRejectedPolicy.CallerRuns);
-        registerThreadPoolProfile(defaultProfile);
+        this.threadPoolFactory = threadPoolFactory;
+        this.defaultProfile = new ThreadPoolBuilder("defaultThreadPoolProfile")
+            .poolSize(10)
+            .maxPoolSize(20)
+            .keepAliveTime(60L, TimeUnit.SECONDS)
+            .maxQueueSize(1000)
+            .rejectedPolicy(ThreadPoolRejectedPolicy.CallerRuns)
+            .build();
     }
 
     public void registerThreadPoolProfile(ThreadPoolProfile profile) {
@@ -79,56 +81,14 @@ public class DefaultExecutorServiceStrat
     }
 
     public ThreadPoolProfile getDefaultThreadPoolProfile() {
-        return getThreadPoolProfile(defaultThreadPoolProfileId);
+        return defaultProfile;
     }
 
     public void setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile) {
-        ThreadPoolProfile oldProfile = threadPoolProfiles.remove(defaultThreadPoolProfileId);
-        if (oldProfile != null) {
-            // the old is no longer default
-            oldProfile.setDefaultProfile(false);
-
-            // fallback and use old default values for new default profile if absent (convention over configuration)
-            if (defaultThreadPoolProfile.getKeepAliveTime() == null) {
-                defaultThreadPoolProfile.setKeepAliveTime(oldProfile.getKeepAliveTime());
-            }
-            if (defaultThreadPoolProfile.getMaxPoolSize() == null) {
-                defaultThreadPoolProfile.setMaxPoolSize(oldProfile.getMaxPoolSize());
-            }
-            if (defaultThreadPoolProfile.getRejectedPolicy() == null) {
-                defaultThreadPoolProfile.setRejectedPolicy(oldProfile.getRejectedPolicy());
-            }
-            if (defaultThreadPoolProfile.getMaxQueueSize() == null) {
-                defaultThreadPoolProfile.setMaxQueueSize(oldProfile.getMaxQueueSize());
-            }
-            if (defaultThreadPoolProfile.getPoolSize() == null) {
-                defaultThreadPoolProfile.setPoolSize(oldProfile.getPoolSize());
-            }
-            if (defaultThreadPoolProfile.getTimeUnit() == null) {
-                defaultThreadPoolProfile.setTimeUnit(oldProfile.getTimeUnit());
-            }
-        }
-
-        // validate that all options has been given as its mandatory for a default thread pool profile
-        // as it is used as fallback for other profiles if they do not have that particular value
-        ObjectHelper.notEmpty(defaultThreadPoolProfile.getId(), "id", defaultThreadPoolProfile);
-        ObjectHelper.notNull(defaultThreadPoolProfile.getKeepAliveTime(), "keepAliveTime", defaultThreadPoolProfile);
-        ObjectHelper.notNull(defaultThreadPoolProfile.getMaxPoolSize(), "maxPoolSize", defaultThreadPoolProfile);
-        ObjectHelper.notNull(defaultThreadPoolProfile.getMaxQueueSize(), "maxQueueSize", defaultThreadPoolProfile);
-        ObjectHelper.notNull(defaultThreadPoolProfile.getPoolSize(), "poolSize", defaultThreadPoolProfile);
-        ObjectHelper.notNull(defaultThreadPoolProfile.getTimeUnit(), "timeUnit", defaultThreadPoolProfile);
-
+        defaultThreadPoolProfile.addDefaults(this.defaultProfile);
+        this.defaultProfile = defaultThreadPoolProfile;
+        this.defaultProfile.setDefaultProfile(true);
         LOG.info("Using custom DefaultThreadPoolProfile: " + defaultThreadPoolProfile);
-
-        // and replace with the new default profile
-        this.defaultThreadPoolProfileId = defaultThreadPoolProfile.getId();
-        // and mark the new profile as default
-        defaultThreadPoolProfile.setDefaultProfile(true);
-        registerThreadPoolProfile(defaultThreadPoolProfile);
-    }
-
-    public String getThreadName(String name) {
-        return ExecutorServiceHelper.getThreadName(threadNamePattern, name);
     }
 
     public String getThreadNamePattern() {
@@ -137,83 +97,17 @@ public class DefaultExecutorServiceStrat
 
     public void setThreadNamePattern(String threadNamePattern) {
         // must set camel id here in the pattern and let the other placeholders be resolved by ExecutorServiceHelper
-        String name = threadNamePattern.replaceFirst("\\$\\{camelId\\}", camelContext.getName());
+        String name = threadNamePattern.replaceFirst("\\$\\{camelId\\}", this.camelContext.getName());
         this.threadNamePattern = name;
     }
-
-    public ExecutorService lookup(Object source, String name, String executorServiceRef) {
-        ExecutorService answer = camelContext.getRegistry().lookup(executorServiceRef, ExecutorService.class);
-        if (answer != null) {
-            LOG.debug("Looking up ExecutorService with ref: {} and found it from Registry: {}", executorServiceRef, answer);
-        }
-
-        if (answer == null) {
-            // try to see if we got a thread pool profile with that id
-            answer = newThreadPool(source, name, executorServiceRef);
-            if (answer != null) {
-                LOG.debug("Looking up ExecutorService with ref: {} and found a matching ThreadPoolProfile to create the ExecutorService: {}",
-                        executorServiceRef, answer);
-            }
-        }
-
-        return answer;
-    }
-
-    public ScheduledExecutorService lookupScheduled(Object source, String name, String executorServiceRef) {
-        ScheduledExecutorService answer = camelContext.getRegistry().lookup(executorServiceRef, ScheduledExecutorService.class);
-        if (answer != null) {
-            LOG.debug("Looking up ScheduledExecutorService with ref: {} and found it from Registry: {}", executorServiceRef, answer);
-        }
-
-        if (answer == null) {
-            ThreadPoolProfile profile = getThreadPoolProfile(executorServiceRef);
-            if (profile != null) {
-                Integer poolSize = profile.getPoolSize();
-                if (poolSize == null) {
-                    poolSize = getDefaultThreadPoolProfile().getPoolSize();
-                }
-                answer = newScheduledThreadPool(source, name, poolSize);
-                if (answer != null) {
-                    LOG.debug("Looking up ScheduledExecutorService with ref: {} and found a matching ThreadPoolProfile to create the ScheduledExecutorService: {}",
-                            executorServiceRef, answer);
-                }
-            }
-        }
-
-        return answer;
-    }
-
-    public ExecutorService newDefaultThreadPool(Object source, String name) {
-        ThreadPoolProfile profile = getDefaultThreadPoolProfile();
-        ObjectHelper.notNull(profile, "DefaultThreadPoolProfile");
-
-        return newThreadPool(source, name,
-            profile.getPoolSize(), profile.getMaxPoolSize(),
-            profile.getKeepAliveTime(), profile.getTimeUnit(),
-            profile.getMaxQueueSize(), profile.getRejectedExecutionHandler(), false);
-    }
-
-    public ExecutorService newThreadPool(Object source, String name, String threadPoolProfileId) {
-        ThreadPoolProfile defaultProfile = getDefaultThreadPoolProfile();
-        ThreadPoolProfile profile = getThreadPoolProfile(threadPoolProfileId);
-        if (profile != null) {
-            // fallback to use values from default profile if not specified
-            Integer poolSize = profile.getPoolSize() != null ? profile.getPoolSize() : defaultProfile.getPoolSize();
-            Integer maxPoolSize = profile.getMaxPoolSize() != null ? profile.getMaxPoolSize() : defaultProfile.getMaxPoolSize();
-            Long keepAliveTime = profile.getKeepAliveTime() != null ? profile.getKeepAliveTime() : defaultProfile.getKeepAliveTime();
-            TimeUnit timeUnit = profile.getTimeUnit() != null ? profile.getTimeUnit() : defaultProfile.getTimeUnit();
-            Integer maxQueueSize = profile.getMaxQueueSize() != null ? profile.getMaxQueueSize() : defaultProfile.getMaxQueueSize();
-            RejectedExecutionHandler handler = profile.getRejectedExecutionHandler() != null ? profile.getRejectedExecutionHandler() : defaultProfile.getRejectedExecutionHandler();
-            // create the pool
-            return newThreadPool(threadPoolProfileId, source, name, poolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, handler, false);
-        } else {
-            // no profile with that id
-            return null;
-        }
+    
+    @Override
+    public String resolveThreadName(String name) {
+        return ThreadHelper.resolveThreadName(threadNamePattern, name);
     }
 
     public ExecutorService newCachedThreadPool(Object source, String name) {
-        ExecutorService answer = ExecutorServiceHelper.newCachedThreadPool(threadNamePattern, name, true);
+        ExecutorService answer = Executors.newCachedThreadPool(new CamelThreadFactory(threadNamePattern , name, true));
         onThreadPoolCreated(answer, source, null);
 
         if (LOG.isDebugEnabled()) {
@@ -222,105 +116,6 @@ public class DefaultExecutorServiceStrat
         return answer;
     }
 
-    public ScheduledExecutorService newScheduledThreadPool(Object source, String name) {
-        int poolSize = getDefaultThreadPoolProfile().getPoolSize();
-        return newScheduledThreadPool(source, name, poolSize);
-    }
-
-    public ScheduledExecutorService newScheduledThreadPool(Object source, String name, int poolSize) {
-        ScheduledExecutorService answer = ExecutorServiceHelper.newScheduledThreadPool(poolSize, threadNamePattern, name, true);
-        onThreadPoolCreated(answer, source, null);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new scheduled thread pool for source: {} with name: {}. [poolSize={}]. -> {}", new Object[]{source, name, poolSize, answer});
-        }
-        return answer;
-    }
-
-    public ExecutorService newFixedThreadPool(Object source, String name, int poolSize) {
-        ExecutorService answer = ExecutorServiceHelper.newFixedThreadPool(poolSize, threadNamePattern, name, true);
-        onThreadPoolCreated(answer, source, null);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new fixed thread pool for source: {} with name: {}. [poolSize={}]. -> {}", new Object[]{source, name, poolSize, answer});
-        }
-        return answer;
-    }
-
-    public ExecutorService newSingleThreadExecutor(Object source, String name) {
-        ExecutorService answer = ExecutorServiceHelper.newSingleThreadExecutor(threadNamePattern, name, true);
-        onThreadPoolCreated(answer, source, null);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new single thread pool for source: {} with name: {}. -> {}", new Object[]{source, name, answer});
-        }
-        return answer;
-    }
-
-    public ExecutorService newSynchronousThreadPool(Object source, String name) {
-        ExecutorService answer = ExecutorServiceHelper.newSynchronousThreadPool();
-        onThreadPoolCreated(answer, source, null);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new synchronous thread pool for source: {} with name: {}. -> {}", new Object[]{source, name, answer});
-        }
-        return answer;
-    }
-
-    public ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize) {
-        ExecutorService answer = ExecutorServiceHelper.newThreadPool(threadNamePattern, name, corePoolSize, maxPoolSize);
-        onThreadPoolCreated(answer, source, null);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new thread pool for source: {} with name: {}. [poolSize={}, maxPoolSize={}] -> {}",
-                    new Object[]{source, name, corePoolSize, maxPoolSize, answer});
-        }
-        return answer;
-    }
-
-    public ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize, int maxQueueSize) {
-        ExecutorService answer = ExecutorServiceHelper.newThreadPool(threadNamePattern, name, corePoolSize, maxPoolSize, maxQueueSize);
-        onThreadPoolCreated(answer, source, null);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new thread pool for source: {} with name: {}. [poolSize={}, maxPoolSize={}, maxQueueSize={}] -> {}",
-                    new Object[]{source, name, corePoolSize, maxPoolSize, maxQueueSize, answer});
-        }
-        return answer;
-    }
-
-    private ExecutorService newThreadPool(String threadPoolProfileId, Object source, String name, int corePoolSize, int maxPoolSize, long keepAliveTime,
-                                         TimeUnit timeUnit, int maxQueueSize, RejectedExecutionHandler rejectedExecutionHandler,
-                                         boolean daemon) {
-
-        // the thread name must not be null
-        ObjectHelper.notNull(name, "ThreadName");
-
-        // If we set the corePoolSize to be 0, the whole camel application will hang in JDK5
-        // just add a check here to throw the IllegalArgumentException
-        if (corePoolSize < 1) {
-            throw new IllegalArgumentException("The corePoolSize can't be lower than 1");
-        }
-
-        ExecutorService answer = ExecutorServiceHelper.newThreadPool(threadNamePattern, name, corePoolSize, maxPoolSize, keepAliveTime,
-                                                                     timeUnit, maxQueueSize, rejectedExecutionHandler, daemon);
-        onThreadPoolCreated(answer, source, threadPoolProfileId);
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Created new thread pool for source: {} with name: {}. [poolSize={}, maxPoolSize={}, keepAliveTime={} {}, maxQueueSize={}, "
-                    + "rejectedExecutionHandler={}, daemon={}] -> {}",
-                    new Object[]{source, name, corePoolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, rejectedExecutionHandler, daemon, answer});
-        }
-        return answer;
-    }
-
-
-    public ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize, long keepAliveTime,
-                                         TimeUnit timeUnit, int maxQueueSize, RejectedExecutionHandler rejectedExecutionHandler,
-                                         boolean daemon) {
-        return newThreadPool(null, source, name, corePoolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, rejectedExecutionHandler, daemon);
-    }
-
     public void shutdown(ExecutorService executorService) {
         ObjectHelper.notNull(executorService, "executorService");
 
@@ -357,7 +152,7 @@ public class DefaultExecutorServiceStrat
      * @param source          the source to use the thread pool
      * @param threadPoolProfileId profile id, if the thread pool was created from a thread pool profile
      */
-    protected void onThreadPoolCreated(ExecutorService executorService, Object source, String threadPoolProfileId) {
+    private void onThreadPoolCreated(ExecutorService executorService, Object source, String threadPoolProfileId) {
         // add to internal list of thread pools
         executorServices.add(executorService);
 
@@ -367,7 +162,7 @@ public class DefaultExecutorServiceStrat
 
         // extract id from source
         if (source instanceof OptionalIdentifiedDefinition) {
-            id = ((OptionalIdentifiedDefinition) source).idOrCreate(camelContext.getNodeIdFactory());
+            id = ((OptionalIdentifiedDefinition) source).idOrCreate(this.camelContext.getNodeIdFactory());
             // and let source be the short name of the pattern
             sourceId = ((OptionalIdentifiedDefinition) source).getShortName();
         } else if (source instanceof String) {
@@ -387,7 +182,7 @@ public class DefaultExecutorServiceStrat
         if (source instanceof ProcessorDefinition) {
             RouteDefinition route = ProcessorDefinitionHelper.getRoute((ProcessorDefinition) source);
             if (route != null) {
-                routeId = route.idOrCreate(camelContext.getNodeIdFactory());
+                routeId = route.idOrCreate(this.camelContext.getNodeIdFactory());
             }
         }
 
@@ -409,7 +204,6 @@ public class DefaultExecutorServiceStrat
      * @param executorService the created {@link java.util.concurrent.ExecutorService} 
      */
     protected void onNewExecutorService(ExecutorService executorService) {
-        // noop
     }
 
     @Override
@@ -448,5 +242,83 @@ public class DefaultExecutorServiceStrat
             }
         }
     }
+    
+    @Override
+    public ExecutorService getDefaultExecutorService(String ref, Object source) {
+        ThreadPoolProfile profile = new ThreadPoolProfile(ref);
+        return getExecutorService(profile, source);
+    }
+    
+    @Override
+    public ExecutorService createExecutorService(ThreadPoolProfile profile, Object source) {
+        ThreadPoolProfile namedProfile = threadPoolProfiles.get(profile.getId());
+        if (namedProfile != null) {
+            profile.addDefaults(namedProfile);
+        }
+        
+        profile.addDefaults(this.defaultProfile);
+        
+        ThreadFactory threadFactory = createThreadFactory(profile);
+        ExecutorService executorService = threadPoolFactory.newThreadPool(profile, threadFactory);
+        onThreadPoolCreated(executorService, source, profile.getId());
+        return executorService;
+    }
+    
+    @Override
+    public ExecutorService getExecutorService(ThreadPoolProfile profile, Object source) {
+        if (profile.getId() != null) {
+            try {
+                ExecutorService answer = camelContext.getRegistry().lookup(profile.getId(), ExecutorService.class);
+                if (answer != null) {
+                    LOG.debug("Looking up ExecutorService with ref: {} and found it from Registry: {}", profile.getId(), answer);
+                    return answer;
+                }
+            } catch (NoSuchBeanException e) {
+                // Jndi registry may throw this. In this case we want to continue with the profile
+            }
+        }
+        return createExecutorService(profile, source);
+    }
+
+    private ThreadFactory createThreadFactory(ThreadPoolProfile profile) {
+        // the thread name must not be null
+        //ObjectHelper.notNull(profile.getThreadName(), "ThreadName");
+        ThreadFactory threadFactory = new CamelThreadFactory(threadNamePattern, profile.getThreadName(), profile.isDaemon());
+        return threadFactory;
+    }
+
+    @Override
+    public ScheduledExecutorService getScheduledExecutorService(String ref, Object source) {
+        ThreadPoolProfile profile = threadPoolProfiles.get(ref);
+        if (profile == null) {
+            profile = new ThreadPoolProfile(ref);
+        }
+        
+        return getScheduledExecutorService(profile, source);
+    }
+
+    @Override
+    public ScheduledExecutorService getScheduledExecutorService(ThreadPoolProfile profile, Object source) {
+        if (profile.getId() != null) {
+            ScheduledExecutorService answer = camelContext.getRegistry().lookup(profile.getId(), ScheduledExecutorService.class);
+            if (answer != null) {
+                LOG.debug("Looking up ExecutorService with ref: {} and found it from Registry: {}", profile.getId(), answer);
+                return answer;
+            }
+        }
+        
+        profile.addDefaults(this.defaultProfile);
+        ThreadFactory threadFactory = createThreadFactory(profile);
+        ScheduledExecutorService executorService = threadPoolFactory.newScheduledThreadPool(profile, threadFactory); 
+        onThreadPoolCreated(executorService, source, profile.getId());
+        return executorService;
+    }
+
+    @Override
+    public ExecutorService newSynchronousExecutorService(String string, Object source) {
+        ExecutorService executorService = new SynchronousExecutorService();
+        onThreadPoolCreated(executorService, this, "Aggregator");
+        return executorService;
+    }
 
 }

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

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java Thu Jul 28 08:39:35 2011
@@ -690,7 +690,7 @@ public class DefaultProducerTemplate ext
             if (executor != null) {
                 return executor;
             }
-            executor = context.getExecutorServiceStrategy().newDefaultThreadPool(this, "ProducerTemplate");
+            executor = context.getExecutorServiceManager().getDefaultExecutorService("ProducerTemplate", this);
         }
 
         ObjectHelper.notNull(executor, "ExecutorService");
@@ -713,7 +713,7 @@ public class DefaultProducerTemplate ext
         producerCache = null;
 
         if (executor != null) {
-            context.getExecutorServiceStrategy().shutdownNow(executor);
+            context.getExecutorServiceManager().shutdownNow(executor);
             executor = null;
         }
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java Thu Jul 28 08:39:35 2011
@@ -33,6 +33,7 @@ import org.apache.camel.Route;
 import org.apache.camel.ShutdownRoute;
 import org.apache.camel.ShutdownRunningTask;
 import org.apache.camel.SuspendableService;
+import org.apache.camel.builder.ThreadPoolBuilder;
 import org.apache.camel.spi.RouteStartupOrder;
 import org.apache.camel.spi.ShutdownAware;
 import org.apache.camel.spi.ShutdownStrategy;
@@ -275,7 +276,8 @@ public class DefaultShutdownStrategy ext
 
     private ExecutorService getExecutorService() {
         if (executor == null) {
-            executor = camelContext.getExecutorServiceStrategy().newSingleThreadExecutor(this, "ShutdownTask");
+            executor = camelContext.getExecutorServiceManager()
+                .getExecutorService(ThreadPoolBuilder.singleThreadExecutor("ShutdownTask") , this);
         }
         return executor;
     }
@@ -293,7 +295,7 @@ public class DefaultShutdownStrategy ext
     @Override
     protected void doShutdown() throws Exception {
         if (executor != null) {
-            camelContext.getExecutorServiceStrategy().shutdownNow(executor);
+            camelContext.getExecutorServiceManager().shutdownNow(executor);
             // should clear executor so we can restart by creating a new thread pool
             executor = null;
         }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java?rev=1151762&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java Thu Jul 28 08:39:35 2011
@@ -0,0 +1,98 @@
+package org.apache.camel.impl;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.spi.ThreadPoolFactory;
+import org.apache.camel.spi.ThreadPoolProfile;
+
+/**
+ * Factory for thread pools that uses the JDK methods for handling thread pools
+ */
+public class DefaultThreadPoolFactory implements ThreadPoolFactory {
+    
+    @Override
+    public ExecutorService newThreadPool(ThreadPoolProfile profile, ThreadFactory factory) {
+        return newThreadPool(profile.getPoolSize(), 
+                             profile.getMaxPoolSize(), 
+                             profile.getKeepAliveTime(),
+                             profile.getTimeUnit(),
+                             profile.getMaxQueueSize(), 
+                             profile.getRejectedExecutionHandler(),
+                             factory);
+    }
+
+    /**
+     * Creates a new custom thread pool
+     *
+     * @param pattern                  pattern of the thread name
+     * @param name                     ${name} in the pattern name
+     * @param corePoolSize             the core pool size
+     * @param maxPoolSize              the maximum pool size
+     * @param keepAliveTime            keep alive time
+     * @param timeUnit                 keep alive time unit
+     * @param maxQueueSize             the maximum number of tasks in the queue, use <tt>Integer.MAX_VALUE</tt> or <tt>-1</tt> to indicate unbounded
+     * @param rejectedExecutionHandler the handler for tasks which cannot be executed by the thread pool.
+     *                                 If <tt>null</tt> is provided then {@link java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy CallerRunsPolicy} is used.
+     * @param daemon                   whether the threads is daemon or not
+     * @return the created pool
+     * @throws IllegalArgumentException if parameters is not valid
+     */
+    private ExecutorService newThreadPool(int corePoolSize, 
+                                          int maxPoolSize,
+                                          long keepAliveTime, 
+                                          TimeUnit timeUnit, 
+                                          int maxQueueSize,
+                                          RejectedExecutionHandler rejectedExecutionHandler, 
+                                          final ThreadFactory factory) {
+
+        // If we set the corePoolSize to be 0, the whole camel application will hang in JDK5
+        // just add a check here to throw the IllegalArgumentException
+        if (corePoolSize < 1) {
+            throw new IllegalArgumentException("The corePoolSize can't be lower than 1");
+        }
+        
+        // validate max >= core
+        if (maxPoolSize < corePoolSize) {
+            throw new IllegalArgumentException("MaxPoolSize must be >= corePoolSize, was " + maxPoolSize + " >= " + corePoolSize);
+        }
+
+        BlockingQueue<Runnable> queue;
+        if (corePoolSize == 0 && maxQueueSize <= 0) {
+            // use a synchronous queue
+            queue = new SynchronousQueue<Runnable>();
+            // and force 1 as pool size to be able to create the thread pool by the JDK
+            corePoolSize = 1;
+            maxPoolSize = 1;
+        } else if (maxQueueSize <= 0) {
+            // unbounded task queue
+            queue = new LinkedBlockingQueue<Runnable>();
+        } else {
+            // bounded task queue
+            queue = new LinkedBlockingQueue<Runnable>(maxQueueSize);
+        }
+        ThreadPoolExecutor answer = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, queue);
+        answer.setThreadFactory(factory);
+        if (rejectedExecutionHandler == null) {
+            rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
+        }
+        answer.setRejectedExecutionHandler(rejectedExecutionHandler);
+        return answer;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.camel.impl.ThreadPoolFactory#newScheduledThreadPool(java.lang.Integer, java.util.concurrent.ThreadFactory)
+     */
+    @Override
+    public ScheduledExecutorService newScheduledThreadPool(ThreadPoolProfile profile, ThreadFactory threadFactory) {
+        return Executors.newScheduledThreadPool(profile.getPoolSize(), threadFactory);
+    }
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java Thu Jul 28 08:39:35 2011
@@ -25,6 +25,7 @@ import org.apache.camel.LoggingLevel;
 import org.apache.camel.PollingConsumerPollingStrategy;
 import org.apache.camel.Processor;
 import org.apache.camel.SuspendableService;
+import org.apache.camel.builder.ThreadPoolBuilder;
 import org.apache.camel.spi.PollingConsumerPollStrategy;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
@@ -54,8 +55,8 @@ public abstract class ScheduledPollConsu
         super(endpoint, processor);
 
         // we only need one thread in the pool to schedule this task
-        this.executor = endpoint.getCamelContext().getExecutorServiceStrategy()
-                            .newScheduledThreadPool(this, endpoint.getEndpointUri(), 1);
+        this.executor = endpoint.getCamelContext().getExecutorServiceManager()
+            .getScheduledExecutorService(ThreadPoolBuilder.singleThreadExecutor(endpoint.getEndpointUri()), this);
         ObjectHelper.notNull(executor, "executor");
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java Thu Jul 28 08:39:35 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.impl;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.LinkedHashSet;
 import java.util.Properties;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThreadPoolProfileSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThreadPoolProfileSupport.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThreadPoolProfileSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThreadPoolProfileSupport.java Thu Jul 28 08:39:35 2011
@@ -1,115 +1,15 @@
-/**
- * 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.impl;
 
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.ThreadPoolRejectedPolicy;
 import org.apache.camel.spi.ThreadPoolProfile;
 
 /**
- * @version 
+ * Use ThreadPoolProfile instead
  */
-public class ThreadPoolProfileSupport implements ThreadPoolProfile {
-
-    private final String id;
-    private Boolean defaultProfile;
-    private Integer poolSize;
-    private Integer maxPoolSize;
-    private Long keepAliveTime;
-    private TimeUnit timeUnit = TimeUnit.SECONDS;
-    private Integer maxQueueSize;
-    private ThreadPoolRejectedPolicy rejectedPolicy;
+@Deprecated
+public class ThreadPoolProfileSupport extends ThreadPoolProfile {
 
     public ThreadPoolProfileSupport(String id) {
-        this.id = id;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public Boolean isDefaultProfile() {
-        return defaultProfile != null && defaultProfile;
-    }
-
-    public void setDefaultProfile(Boolean defaultProfile) {
-        this.defaultProfile = defaultProfile;
+        super(id);
     }
 
-    public Integer getPoolSize() {
-        return poolSize;
-    }
-
-    public void setPoolSize(Integer poolSize) {
-        this.poolSize = poolSize;
-    }
-
-    public Integer getMaxPoolSize() {
-        return maxPoolSize;
-    }
-
-    public void setMaxPoolSize(Integer maxPoolSize) {
-        this.maxPoolSize = maxPoolSize;
-    }
-
-    public Long getKeepAliveTime() {
-        return keepAliveTime;
-    }
-
-    public void setKeepAliveTime(Long keepAliveTime) {
-        this.keepAliveTime = keepAliveTime;
-    }
-
-    public TimeUnit getTimeUnit() {
-        return timeUnit;
-    }
-
-    public void setTimeUnit(TimeUnit timeUnit) {
-        this.timeUnit = timeUnit;
-    }
-
-    public Integer getMaxQueueSize() {
-        return maxQueueSize;
-    }
-
-    public void setMaxQueueSize(Integer maxQueueSize) {
-        this.maxQueueSize = maxQueueSize;
-    }
-
-    public ThreadPoolRejectedPolicy getRejectedPolicy() {
-        return rejectedPolicy;
-    }
-
-    public RejectedExecutionHandler getRejectedExecutionHandler() {
-        if (rejectedPolicy != null) {
-            return rejectedPolicy.asRejectedExecutionHandler();
-        }
-        return null;
-    }
-
-    public void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) {
-        this.rejectedPolicy = rejectedPolicy;
-    }
-
-    @Override
-    public String toString() {
-        return "ThreadPoolProfile[" + id + ", " + defaultProfile + ", " + poolSize + ", " + maxPoolSize + ", "
-                + keepAliveTime + " " + timeUnit + ", " + maxPoolSize + ", " + rejectedPolicy + "]";
-    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java Thu Jul 28 08:39:35 2011
@@ -23,7 +23,6 @@ import org.apache.camel.NoTypeConversion
 import org.apache.camel.Processor;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.processor.DelegateProcessor;
-import org.apache.camel.util.ObjectHelper;
 
 /**
  * A simple converter that can convert any {@link Processor} to an {@link AsyncProcessor}.

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java Thu Jul 28 08:39:35 2011
@@ -17,7 +17,6 @@
 package org.apache.camel.impl.converter;
 
 import java.io.IOException;
-import java.net.URISyntaxException;
 
 /**
  * Will load all type converters from camel-core without classpath scanning, which makes

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java Thu Jul 28 08:39:35 2011
@@ -38,6 +38,7 @@ import javax.management.remote.JMXServic
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
+import org.apache.camel.builder.ThreadPoolBuilder;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.spi.ManagementAgent;
 import org.apache.camel.util.ObjectHelper;
@@ -412,8 +413,9 @@ public class DefaultManagementAgent exte
         cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
 
         if (executorService == null) {
-            // we only need a single for the JMX connector
-            executorService = camelContext.getExecutorServiceStrategy().newSingleThreadExecutor(this, "JMXConnector: " + url);
+            // we only need a single thread for the JMX connector
+            executorService = camelContext.getExecutorServiceManager()
+                .getExecutorService(ThreadPoolBuilder.singleThreadExecutor("JMXConnector: " + url), this);
         }
 
         // execute the JMX connector

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java?rev=1151762&r1=1151761&r2=1151762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java Thu Jul 28 08:39:35 2011
@@ -125,9 +125,8 @@ public class DefaultManagementNamingStra
 
     public ObjectName getObjectNameForErrorHandler(RouteContext routeContext, Processor errorHandler, ErrorHandlerBuilder builder) throws MalformedObjectNameException {
         StringBuilder buffer = new StringBuilder();
-        buffer.append(domainName).append(":");
-        buffer.append(KEY_CONTEXT + "=").append(getContextId(routeContext.getCamelContext())).append(",");
-        buffer.append(KEY_TYPE + "=").append(TYPE_ERRORHANDLER).append(",");
+        buffer.append(domainName + ":" + KEY_CONTEXT + "=" + getContextId(routeContext.getCamelContext()) + ","
+                      + KEY_TYPE + "=" +  TYPE_ERRORHANDLER + ",");
 
         // we want to only register one instance of the various error handler types and thus do some lookup
         // if its a ErrorHandlerBuildRef. We need a bit of work to do that as there are potential indirection.



Mime
View raw message