org.apache.jcs.utils.threadpool
Class ThreadPoolManager

java.lang.Object
  extended by org.apache.jcs.utils.threadpool.ThreadPoolManager

public class ThreadPoolManager
extends java.lang.Object

This manages threadpools for an application using Doug Lea's Util Concurrent package. http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html

It is a singleton since threads need to be managed vm wide.

This manager forces you to use a bounded queue. By default it uses the current thread for execution when the buffer is full and no free threads can be created.

You can specify the props file to use or pass in a properties object prior to configuration. By default it looks for configuration information in thread_pool.properties.

If set, the Properties object will take precedence.

If a value is not set for a particular pool, the hard coded defaults will be used.

 int boundarySize_DEFAULT = 2000;
 
 int maximumPoolSize_DEFAULT = 150;
 
 int minimumPoolSize_DEFAULT = 4;
 
 int keepAliveTime_DEFAULT = 1000 * 60 * 5;
 
 boolean abortWhenBlocked = false;
 
 String whenBlockedPolicy_DEFAULT = IPoolConfiguration.POLICY_RUN;
 
 int startUpSize_DEFAULT = 4;
 
You can configure default settings by specifying a default pool in the properties, ie "cache.ccf"

Author:
Aaron Smuts

Field Summary
static java.lang.String DEFAULT_PROPS_FILE_NAME
          This is the default value.
 
Method Summary
protected  void configure()
          Intialize the ThreadPoolManager and create all the pools defined in the configuration.
static ThreadPoolManager getInstance()
          Returns a configured instance of the ThreadPoolManger To specify a configuation file or Properties object to use call the appropriate setter prior to calling getInstance.
 ThreadPool getPool(java.lang.String name)
          Returns a pool by name.
 java.util.ArrayList getPoolNames()
          Returns the names of all configured pools.
static java.util.Properties getProps()
           
static java.lang.String getPropsFileName()
          Returns the name of the properties file that we used to initialize the pools.
protected  PoolConfiguration loadConfig(java.lang.String root)
          Configures the default PoolConfiguration settings.
static void setProps(java.util.Properties props)
          This will be used if it is not null on initialzation.
static void setPropsFileName(java.lang.String propsFileName)
          Setting this post initialization will have no effect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROPS_FILE_NAME

public static final java.lang.String DEFAULT_PROPS_FILE_NAME
This is the default value.

See Also:
Constant Field Values
Method Detail

getInstance

public static ThreadPoolManager getInstance()
Returns a configured instance of the ThreadPoolManger To specify a configuation file or Properties object to use call the appropriate setter prior to calling getInstance.

Returns:
The single instance of the ThreadPoolManager

getPool

public ThreadPool getPool(java.lang.String name)
Returns a pool by name. If a pool by this name does not exist in the configuration file or properties, one will be created using the default values.

Pools are lazily created.

Parameters:
name -
Returns:
The thread pool configured for the name.

getPoolNames

public java.util.ArrayList getPoolNames()
Returns the names of all configured pools.

Returns:
ArrayList of string names

setPropsFileName

public static void setPropsFileName(java.lang.String propsFileName)
Setting this post initialization will have no effect.

Parameters:
propsFileName - The propsFileName to set.

getPropsFileName

public static java.lang.String getPropsFileName()
Returns the name of the properties file that we used to initialize the pools. If the value was set post-initialization, then it may not be the file used.

Returns:
Returns the propsFileName.

setProps

public static void setProps(java.util.Properties props)
This will be used if it is not null on initialzation. Setting this post initialization will have no effect.

Parameters:
props - The props to set.

getProps

public static java.util.Properties getProps()
Returns:
Returns the props.

configure

protected void configure()
Intialize the ThreadPoolManager and create all the pools defined in the configuration.


loadConfig

protected PoolConfiguration loadConfig(java.lang.String root)
Configures the default PoolConfiguration settings.

Parameters:
root -
Returns:
PoolConfiguration


Copyright © 2002-2011 Apache Software Foundation. All Rights Reserved.