jrun.jms.core.threads
Class ThreadPoolManagerService

jrunx.kernel.ServiceAdapter
  |
  +--jrun.jms.core.util.JMSServiceAdapter
        |
        +--jrun.jms.core.threads.ThreadPoolManagerService
All Implemented Interfaces:
JMSService, JMSServiceAdapterMBean, javax.naming.Referenceable, java.io.Serializable, Service, ServiceMBean, ThreadPoolManager, ThreadPoolManagerServiceMBean

public class ThreadPoolManagerService
extends JMSServiceAdapter
implements ThreadPoolManager

The thread pool manager service manages all the required ThreadPool objects. The clients can obtain a ThreadPool from the ThreadPoolManager with a given number of Threads.

The manager keeps a list of all The ThreadPools it has dished out with a unique client provided name. Client can then re-request the already created ThreadPool or share common ThreadPools if required.

The ThreadPool manager will attempt to shutdown all ThreadPools and stop all Threads when it receives a stop request.

If a client attempts to create a ThreadPool with a name that already exists a ThreadPoolExistsException will be raised and the creation will fail.

See Also:
Serialized Form

Field Summary
static java.lang.String OBJECT_NAME
           
 
Fields inherited from class jrunx.kernel.ServiceAdapter
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER
 
Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
ThreadPoolManagerService()
           
 
Method Summary
 ThreadPool createThreadPool(java.lang.String name, int size)
          A client has requested a new thread pool creation with the given name.
 void deleteThreadPool(java.lang.String name)
          Attempts to shutdown all the threads in the pool and removes the given ThreadPool.
 ThreadPool getThreadPool(java.lang.String name)
          Get the ThreadPool with the given name.
 void init()
          Initializes pools
static ThreadPoolManagerService instance()
           
 void stop()
          Overide ServiceAdapter stop.
 
Methods inherited from class jrun.jms.core.util.JMSServiceAdapter
getMetaData, restart, resume, setMetaData, suspend
 
Methods inherited from class jrunx.kernel.ServiceAdapter
bind, destroy, findObjectInstance, findObjectInstance, findObjectInstance, getBindToJNDI, getDeactivated, getDomainName, getDomainSearchPath, getJRunService, getLogger, getName, getParentService, getReference, getResourceManager, getServerName, getServerProperties, getStatus, invokeMethod, isInPartition, isPartition, lookup, postDeregister, postRegister, preDeregister, preRegister, requestServer, scheduleRunnable, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, start, toString, unbind, unscheduleRunnable, updateStatus
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
destroy, getStatus, start, updateStatus
 

Field Detail

OBJECT_NAME

public static final java.lang.String OBJECT_NAME
Constructor Detail

ThreadPoolManagerService

public ThreadPoolManagerService()
Method Detail

instance

public static ThreadPoolManagerService instance()

init

public void init()
          throws java.lang.Exception
Initializes pools
Specified by:
init in interface Service
Overrides:
init in class ServiceAdapter

createThreadPool

public ThreadPool createThreadPool(java.lang.String name,
                                   int size)
                            throws ThreadPoolException
A client has requested a new thread pool creation with the given name. if the named Pool has not already been created, then create it add it to the list, and return it to the client.
Specified by:
createThreadPool in interface ThreadPoolManager
Parameters:
name - The unique name given to this ThreadPool
size - The maximum nuber of Threads this pool contains.
Throws:
ThreadPoolExistsException - if the pool with the given name already exists.

getThreadPool

public ThreadPool getThreadPool(java.lang.String name)
                         throws ThreadPoolException
Get the ThreadPool with the given name. if the named pool does not exist throw an exception.
Specified by:
getThreadPool in interface ThreadPoolManager
Parameters:
name - The unique name of the requested ThreadPool
Throws:
UnknownThreadPoolException - if the pool with the given name does not exist.

deleteThreadPool

public void deleteThreadPool(java.lang.String name)
                      throws ThreadPoolException
Attempts to shutdown all the threads in the pool and removes the given ThreadPool.
Specified by:
deleteThreadPool in interface ThreadPoolManager
Parameters:
name - The unique name of the requested ThreadPool
Throws:
UnknownThreadPoolException - if the pool with the given name does not exist.

stop

public void stop()
          throws java.lang.Exception
Overide ServiceAdapter stop. Clean up all thread pools, by calling their stop methods.
Specified by:
stop in interface Service
Overrides:
stop in class ServiceAdapter
Throws:
ServiceException -  


Copyright � 2002 Macromedia Corporation. All Rights Reserved.