org.alfresco.util
Class ThreadPoolExecutorFactoryBean

java.lang.Object
  extended by org.alfresco.util.ThreadPoolExecutorFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class ThreadPoolExecutorFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

Factory for ThreadPoolExecutor instances, which cannot easily be constructed using constructor injection. This instance also allows the setting of the thread-specific properties that would otherwise require setting a ThreadFactory.

This factory provides the a singleton instance of the pool.

Defaults are:


Constructor Summary
ThreadPoolExecutorFactoryBean()
          Constructor setting default properties:
 
Method Summary
 void afterPropertiesSet()
           
 java.lang.Object getObject()
           
 java.lang.Class getObjectType()
           
 java.lang.String getPoolName()
           
 boolean isSingleton()
           
 void setCorePoolSize(int corePoolSize)
          The number of threads to keep in the pool, even if idle.
 void setKeepAliveTime(int keepAliveTime)
          The time (in seconds) to keep non-core idle threads in the pool
 void setMaximumPoolSize(int maximumPoolSize)
          The maximum number of threads to keep in the pool
 void setPoolName(java.lang.String poolName)
           
 void setRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
          The optional handler for when tasks cannot be submitted to the queue.
 void setThreadDaemon(boolean threadDaemon)
          Set whether the threads run as daemon threads or not.
 void setThreadPriority(int threadPriority)
          The priority that all threads must have on the scale of 1 to 10, where 1 has the lowest priority and 10 has the highest priority.
 void setWorkQueueSize(int workQueueSize)
          The maximum number of queued work instances to keep before blocking against further adds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPoolExecutorFactoryBean

public ThreadPoolExecutorFactoryBean()
Constructor setting default properties:

Method Detail

setCorePoolSize

public void setCorePoolSize(int corePoolSize)
The number of threads to keep in the pool, even if idle.

Parameters:
corePoolSize - core thread count

setMaximumPoolSize

public void setMaximumPoolSize(int maximumPoolSize)
The maximum number of threads to keep in the pool

Parameters:
maximumPoolSize - the maximum number of threads in the pool

setKeepAliveTime

public void setKeepAliveTime(int keepAliveTime)
The time (in seconds) to keep non-core idle threads in the pool

Parameters:
keepAliveTime - time to stay idle in seconds

setThreadPriority

public void setThreadPriority(int threadPriority)
The priority that all threads must have on the scale of 1 to 10, where 1 has the lowest priority and 10 has the highest priority.

Parameters:
threadPriority - the thread priority

setThreadDaemon

public void setThreadDaemon(boolean threadDaemon)
Set whether the threads run as daemon threads or not.

Parameters:
threadDaemon - true to run as daemon

setWorkQueueSize

public void setWorkQueueSize(int workQueueSize)
The maximum number of queued work instances to keep before blocking against further adds.

Parameters:
size - the queue size before blocks, or -1 default to indicate no upper bound

setRejectedExecutionHandler

public void setRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
The optional handler for when tasks cannot be submitted to the queue. The default is the CallerRunsPolicy.

Parameters:
rejectedExecutionHandler - the handler to use

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean
Returns:
Returns true always.

getObject

public java.lang.Object getObject()
                           throws java.lang.Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean
Returns:
Returns the singleton instance.
Throws:
java.lang.Exception

getObjectType

public java.lang.Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean
See Also:
ThreadPoolExecutor

getPoolName

public java.lang.String getPoolName()

setPoolName

public void setPoolName(java.lang.String poolName)


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.