org.apache.camel.spi
Interface ExecutorServiceStrategy

All Superinterfaces:
Service, ShutdownableService
All Known Implementing Classes:
DefaultExecutorServiceStrategy

Deprecated. use ExecutorServiceManager instead, will be removed in a future Camel release

@Deprecated
public interface ExecutorServiceStrategy
extends ShutdownableService

Strategy to create thread pools.

This strategy is pluggable so you can plugin a custom provider, for example if you want to leverage the WorkManager for a J2EE server.

This strategy has fine grained methods for creating various thread pools, however custom strategies do not have to exactly create those kind of pools. Feel free to return a shared or different kind of pool.

However there are two types of pools: regular and scheduled.

If you use the newXXX methods to create thread pools, then Camel will by default take care of shutting down those created pools when CamelContext is shutting down.


Method Summary
 ThreadPoolProfile getDefaultThreadPoolProfile()
          Deprecated. Gets the default thread pool profile
 String getThreadName(String name)
          Deprecated. Creates a full thread name
 String getThreadNamePattern()
          Deprecated. Gets the thread name pattern used for creating the full thread name.
 ThreadPoolProfile getThreadPoolProfile(String id)
          Deprecated. Gets the thread pool profile by the given id
 ExecutorService lookup(Object source, String name, String executorServiceRef)
          Deprecated. Lookup a ExecutorService from the Registry and from known list of ThreadPoolProfile(s).
 ScheduledExecutorService lookupScheduled(Object source, String name, String executorServiceRef)
          Deprecated. Lookup a ScheduledExecutorService from the Registry and from known list of ThreadPoolProfile(s).
 ExecutorService newCachedThreadPool(Object source, String name)
          Deprecated. Creates a new cached thread pool.
 ExecutorService newDefaultThreadPool(Object source, String name)
          Deprecated. Creates a new thread pool using the default thread pool profile.
 ExecutorService newFixedThreadPool(Object source, String name, int poolSize)
          Deprecated. Creates a new fixed thread pool.
 ScheduledExecutorService newScheduledThreadPool(Object source, String name)
          Deprecated. Creates a new scheduled thread pool.
 ScheduledExecutorService newScheduledThreadPool(Object source, String name, int poolSize)
          Deprecated. Creates a new scheduled thread pool.
 ExecutorService newSingleThreadExecutor(Object source, String name)
          Deprecated. Creates a new single-threaded thread pool.
 ExecutorService newSynchronousThreadPool(Object source, String name)
          Deprecated. Creates a new synchronous thread pool, which executes the task in the caller thread (no task queue).
 ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize)
          Deprecated. Creates a new custom thread pool.
 ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize, int maxQueueSize)
          Deprecated. Creates a new custom thread pool.
 ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize, long keepAliveTime, TimeUnit timeUnit, int maxQueueSize, RejectedExecutionHandler rejectedExecutionHandler, boolean daemon)
          Deprecated. Creates a new custom thread pool.
 ExecutorService newThreadPool(Object source, String name, String threadPoolProfileId)
          Deprecated. Creates a new thread pool using based on the given profile id.
 void registerThreadPoolProfile(ThreadPoolProfile profile)
          Deprecated. Registers the given thread pool profile
 void setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile)
          Deprecated. Sets the default thread pool profile
 void setThreadNamePattern(String pattern)
          Deprecated. Sets the thread name pattern used for creating the full thread name.
 void shutdown(ExecutorService executorService)
          Deprecated. Shutdown the given executor service.
 List<Runnable> shutdownNow(ExecutorService executorService)
          Deprecated. Shutdown now the given executor service.
 
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Method Detail

registerThreadPoolProfile

void registerThreadPoolProfile(ThreadPoolProfile profile)
Deprecated. 
Registers the given thread pool profile

Parameters:
profile - the profile

getThreadPoolProfile

ThreadPoolProfile getThreadPoolProfile(String id)
Deprecated. 
Gets the thread pool profile by the given id

Parameters:
id - id of the thread pool profile to get
Returns:
the found profile, or null if not found

getDefaultThreadPoolProfile

ThreadPoolProfile getDefaultThreadPoolProfile()
Deprecated. 
Gets the default thread pool profile

Returns:
the default profile which are newer null

setDefaultThreadPoolProfile

void setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile)
Deprecated. 
Sets the default thread pool profile

Parameters:
defaultThreadPoolProfile - the new default thread pool profile

getThreadName

String getThreadName(String name)
Deprecated. 
Creates a full thread name

Parameters:
name - name which is appended to the full thread name
Returns:
the full thread name

getThreadNamePattern

String getThreadNamePattern()
Deprecated. 
Gets the thread name pattern used for creating the full thread name.

Returns:
the pattern

setThreadNamePattern

void setThreadNamePattern(String pattern)
                          throws IllegalArgumentException
Deprecated. 
Sets the thread name pattern used for creating the full thread name.

The default pattern is: Camel (#camelId#) thread #counter# - #name#

Where #camelId# is the name of the CamelContext
and #counter# is a unique incrementing counter.
and #name# is the regular thread name.
You can also use #longName# is the long thread name which can includes endpoint parameters etc.

Parameters:
pattern - the pattern
Throws:
IllegalArgumentException - if the pattern is invalid.

lookup

ExecutorService lookup(Object source,
                       String name,
                       String executorServiceRef)
Deprecated. 
Lookup a ExecutorService from the Registry and from known list of ThreadPoolProfile(s).

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
executorServiceRef - reference to lookup
Returns:
the ExecutorService or null if not found

lookupScheduled

ScheduledExecutorService lookupScheduled(Object source,
                                         String name,
                                         String executorServiceRef)
Deprecated. 
Lookup a ScheduledExecutorService from the Registry and from known list of ThreadPoolProfile(s).

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
executorServiceRef - reference to lookup
Returns:
the ScheduledExecutorService or null if not found

newDefaultThreadPool

ExecutorService newDefaultThreadPool(Object source,
                                     String name)
Deprecated. 
Creates a new thread pool using the default thread pool profile.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
Returns:
the created thread pool

newThreadPool

ExecutorService newThreadPool(Object source,
                              String name,
                              String threadPoolProfileId)
Deprecated. 
Creates a new thread pool using based on the given profile id.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
threadPoolProfileId - id of the thread pool profile to use for creating the thread pool
Returns:
the created thread pool, or null if the was no thread pool profile with that given id.

newCachedThreadPool

ExecutorService newCachedThreadPool(Object source,
                                    String name)
Deprecated. 
Creates a new cached thread pool.

Important: Using cached thread pool is discouraged as they have no upper bound and can overload the JVM.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
Returns:
the created thread pool

newScheduledThreadPool

ScheduledExecutorService newScheduledThreadPool(Object source,
                                                String name,
                                                int poolSize)
Deprecated. 
Creates a new scheduled thread pool.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
poolSize - the core pool size
Returns:
the created thread pool

newScheduledThreadPool

ScheduledExecutorService newScheduledThreadPool(Object source,
                                                String name)
Deprecated. 
Creates a new scheduled thread pool.

Will use the pool size from the default thread pool profile

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
Returns:
the created thread pool

newFixedThreadPool

ExecutorService newFixedThreadPool(Object source,
                                   String name,
                                   int poolSize)
Deprecated. 
Creates a new fixed thread pool.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
poolSize - the core pool size
Returns:
the created thread pool

newSingleThreadExecutor

ExecutorService newSingleThreadExecutor(Object source,
                                        String name)
Deprecated. 
Creates a new single-threaded thread pool. This is often used for background threads.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
Returns:
the created thread pool

newSynchronousThreadPool

ExecutorService newSynchronousThreadPool(Object source,
                                         String name)
Deprecated. 
Creates a new synchronous thread pool, which executes the task in the caller thread (no task queue).

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
Returns:
the created thread pool

newThreadPool

ExecutorService newThreadPool(Object source,
                              String name,
                              int corePoolSize,
                              int maxPoolSize)
Deprecated. 
Creates a new custom thread pool.

Will by default use 60 seconds for keep alive time for idle threads. And use CallerRunsPolicy as rejection handler

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
corePoolSize - the core pool size
maxPoolSize - the maximum pool size
Returns:
the created thread pool

newThreadPool

ExecutorService newThreadPool(Object source,
                              String name,
                              int corePoolSize,
                              int maxPoolSize,
                              int maxQueueSize)
Deprecated. 
Creates a new custom thread pool.

Will by default use 60 seconds for keep alive time for idle threads. And use CallerRunsPolicy as rejection handler

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
corePoolSize - the core pool size
maxPoolSize - the maximum pool size
maxQueueSize - the maximum number of tasks in the queue, use Integer.MAX_INT or -1 to indicate unbounded
Returns:
the created thread pool

newThreadPool

ExecutorService newThreadPool(Object source,
                              String name,
                              int corePoolSize,
                              int maxPoolSize,
                              long keepAliveTime,
                              TimeUnit timeUnit,
                              int maxQueueSize,
                              RejectedExecutionHandler rejectedExecutionHandler,
                              boolean daemon)
Deprecated. 
Creates a new custom thread pool.

Parameters:
source - the source object, usually it should be this passed in as parameter
name - name which is appended to the thread name
corePoolSize - the core pool size
maxPoolSize - the maximum pool size
keepAliveTime - keep alive time for idle threads
timeUnit - time unit for keep alive time
maxQueueSize - the maximum number of tasks in the queue, use Integer.MAX_INT or -1 to indicate unbounded
rejectedExecutionHandler - the handler for tasks which cannot be executed by the thread pool. If null is provided then CallerRunsPolicy is used.
daemon - whether or not the created threads is daemon or not
Returns:
the created thread pool

shutdown

void shutdown(ExecutorService executorService)
Deprecated. 
Shutdown the given executor service.

Parameters:
executorService - the executor service to shutdown
See Also:
ExecutorService.shutdown()

shutdownNow

List<Runnable> shutdownNow(ExecutorService executorService)
Deprecated. 
Shutdown now the given executor service.

Parameters:
executorService - the executor service to shutdown now
Returns:
list of tasks that never commenced execution
See Also:
ExecutorService.shutdownNow()


Apache CAMEL