org.exolab.jms.threads
Class ThreadPoolManager

java.lang.Object
  |
  +--org.exolab.core.service.Service
        |
        +--org.exolab.core.service.BasicService
              |
              +--org.exolab.jms.threads.ThreadPoolManager
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable, org.exolab.core.service.Serviceable

public class ThreadPoolManager
extends org.exolab.core.service.BasicService

The thread pool manager 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.

Version:
$Revision: 1.4 $ $Date: 2003/08/07 13:33:10 $
Author:
Jim Mourikis
See Also:
Serialized Form

Method Summary
 org.exolab.core.threadPool.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.
 org.exolab.core.threadPool.ThreadPool getThreadPool(java.lang.String name)
          Get the ThreadPool with the given name.
static ThreadPoolManager instance()
          Return the one and only instance of the ThreadPoolManager.
 void run()
          This starts the ThreadPoolManager's thread
 void stop()
          Overide BasicService.stop.
 
Methods inherited from class org.exolab.core.service.BasicService
start, toString
 
Methods inherited from class org.exolab.core.service.Service
getName, getState, restart, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

instance

public static ThreadPoolManager instance()
Return the one and only instance of the ThreadPoolManager.

Note: Initiase must be called above to initialise the pool, else a null object will be returned.


createThreadPool

public org.exolab.core.threadPool.ThreadPool createThreadPool(java.lang.String name,
                                                              int size)
                                                       throws ThreadPoolExistsException
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.
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 org.exolab.core.threadPool.ThreadPool getThreadPool(java.lang.String name)
                                                    throws UnknownThreadPoolException
Get the ThreadPool with the given name. if the named pool does not exist throw an exception.
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 UnknownThreadPoolException
Attempts to shutdown all the threads in the pool and removes the given ThreadPool.
Parameters:
name - The unique name of the requested ThreadPool
Throws:
UnknownThreadPoolException - if the pool with the given name does not exist.

run

public void run()
This starts the ThreadPoolManager's thread
Overrides:
run in class org.exolab.core.service.BasicService

stop

public void stop()
          throws org.exolab.core.service.ServiceException
Overide BasicService.stop. Clean up all thread pools, by calling their stop methods.
Overrides:
stop in class org.exolab.core.service.BasicService
Throws:
org.exolab.core.service.ServiceException -  


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.