org.apache.jetspeed.services.threadpool
Class JetspeedThreadPoolService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.jetspeed.services.threadpool.JetspeedThreadPoolService
All Implemented Interfaces:
org.apache.turbine.services.Initable, org.apache.turbine.services.Service, ThreadPoolService

public class JetspeedThreadPoolService
extends org.apache.turbine.services.TurbineBaseService
implements ThreadPoolService

This is a Service that provides a simple threadpool usable by all thread intensive classes in order to optimize resources utilization screen:

It uses 3 parameters for contolling resource usage:

init.count
The number of threads to start at initizaliation
max.count
The maximum number of threads started by this service
minspare.count
The pool tries to keep lways this minimum number if threads available

Version:
$Id: JetspeedThreadPoolService.java,v 1.11 2005/03/21 18:21:44 sgala Exp $
Author:
Kevin A. Burton, Raphaël Luta, Santiago Gala

Field Summary
static int DEFAULT_THREAD_PRIORITY
          The default priority to use when creating new threads.
protected static JetspeedLogger logger
          Static initialization of the logger for this class
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.jetspeed.services.threadpool.ThreadPoolService
SERVICE_NAME
 
Constructor Summary
JetspeedThreadPoolService()
          Constructor.
 
Method Summary
 int getAvailableThreadCount()
          Get the number of threads that are available.
 int getQueueLength()
          Get the current length of the Runnable queue, waiting for processing
 int getThreadCount()
          Get the number of threads that have been created
 int getThreadProcessedCount()
          Get the number of threads that have successfully been processed for logging and debugging purposes.
 void init()
          Late init.
 void init(javax.servlet.ServletConfig config)
          Called during Turbine.init()
 void process(java.lang.Runnable runnable)
          Processes the Runnable object with an available thread at default priority
 void process(java.lang.Runnable runnable, int priority)
          Process a Runnable object by allocating a Thread for it at the given priority
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, shutdown
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker, shutdown
 

Field Detail

logger

protected static final JetspeedLogger logger
Static initialization of the logger for this class


DEFAULT_THREAD_PRIORITY

public static final int DEFAULT_THREAD_PRIORITY
The default priority to use when creating new threads.

See Also:
Constant Field Values
Constructor Detail

JetspeedThreadPoolService

public JetspeedThreadPoolService()
                          throws java.lang.Exception
Constructor.

Throws:
Exception, - a generic exception.
java.lang.Exception
Method Detail

init

public void init()
Late init. Don't return control until early init says we're done.

Specified by:
init in interface org.apache.turbine.services.Initable

init

public void init(javax.servlet.ServletConfig config)
Called during Turbine.init()

Parameters:
config - A ServletConfig.

process

public void process(java.lang.Runnable runnable)
Processes the Runnable object with an available thread at default priority

Specified by:
process in interface ThreadPoolService
Parameters:
runnable - the runnable code to process
See Also:
process( Runnable, int )

process

public void process(java.lang.Runnable runnable,
                    int priority)
Process a Runnable object by allocating a Thread for it at the given priority

Specified by:
process in interface ThreadPoolService
Parameters:
runnable - the runnable code to process
priority - the priority used be the thread that will run this runnable

getThreadCount

public int getThreadCount()
Get the number of threads that have been created

Returns:
the number of threads currently created by the pool

getAvailableThreadCount

public int getAvailableThreadCount()
Get the number of threads that are available.

Returns:
the number of threads available in the pool

getQueueLength

public int getQueueLength()
Get the current length of the Runnable queue, waiting for processing

Returns:
the length of the queue of waiting processes

getThreadProcessedCount

public int getThreadProcessedCount()
Get the number of threads that have successfully been processed for logging and debugging purposes.

Returns:
the number of processes executed since initialization


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.