JBoss Modular Service Kernel API 1.0.0.Beta1

org.jboss.msc.services
Class ThreadPoolExecutorService

java.lang.Object
  extended by org.jboss.msc.services.ThreadPoolExecutorService
All Implemented Interfaces:
Service<ExecutorService>, Value<ExecutorService>

public final class ThreadPoolExecutorService
extends Object
implements Service<ExecutorService>

A thread pool executor service, which is configurable at runtime.

Author:
David M. Lloyd

Field Summary
static ServiceName JBOSS_THREADS
          The service name under which thread-related services are registered.
static ServiceName JBOSS_THREADS_EXECUTOR
          The service name under which executors (thread pools) are registered.
 
Fields inherited from interface org.jboss.msc.service.Service
NULL, NULL_VALUE
 
Constructor Summary
ThreadPoolExecutorService()
          Construct a new instance.
 
Method Summary
 int getCorePoolSize()
          Get the configured core pool size.
 RejectedExecutionHandler getHandler()
          Get the rejected execution handler.
 long getKeepAliveTime(TimeUnit unit)
          Get the keep-alive time.
 int getMaximumPoolSize()
          Get the configured maximum pool size.
 ThreadFactory getThreadFactory()
          Get the configured thread factory.
 ExecutorService getValue()
          Get the public executor service for this thread pool.
 boolean isAllowCoreTimeout()
          Determine whether core threads are allowed to time out.
 void setAllowCoreTimeout(boolean allowCoreTimeout)
          Specify whether core threads are allowed to time out.
 void setCorePoolSize(int corePoolSize)
          Set the configured core pool size.
 void setHandler(RejectedExecutionHandler handler)
          Set the rejected execution handler.
 void setKeepAliveTime(long keepAliveTime, TimeUnit unit)
          Set the keep-alive time.
 void setMaximumPoolSize(int maximumPoolSize)
          Set the configured maximum pool size.
 void setThreadFactory(ThreadFactory threadFactory)
          Set the configured thread factory.
 void setWorkQueue(BlockingQueue<Runnable> workQueue)
          Set the configured work queue.
 void start(StartContext context)
          Start the service.
 void stop(StopContext context)
          Stop the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JBOSS_THREADS

public static ServiceName JBOSS_THREADS
The service name under which thread-related services are registered.


JBOSS_THREADS_EXECUTOR

public static ServiceName JBOSS_THREADS_EXECUTOR
The service name under which executors (thread pools) are registered.

Constructor Detail

ThreadPoolExecutorService

public ThreadPoolExecutorService()
Construct a new instance.

Method Detail

isAllowCoreTimeout

public boolean isAllowCoreTimeout()
Determine whether core threads are allowed to time out.

Returns:
true if core threads are allowed to time out

setAllowCoreTimeout

public void setAllowCoreTimeout(boolean allowCoreTimeout)
Specify whether core threads are allowed to time out. If the service is already started, the change will take effect immediately.

Parameters:
allowCoreTimeout - true if core threads are allowed to time out

getCorePoolSize

public int getCorePoolSize()
Get the configured core pool size.

Returns:
the core pool size

setCorePoolSize

public void setCorePoolSize(int corePoolSize)
Set the configured core pool size. If the service is already started, the change will take effect immediately.

Parameters:
corePoolSize - the core pool size

getMaximumPoolSize

public int getMaximumPoolSize()
Get the configured maximum pool size.

Returns:
the maximum pool size

setMaximumPoolSize

public void setMaximumPoolSize(int maximumPoolSize)
Set the configured maximum pool size. If the service is already started, the change will take effect immediately.

Parameters:
maximumPoolSize - the maximum pool size

getKeepAliveTime

public long getKeepAliveTime(TimeUnit unit)
Get the keep-alive time.

Parameters:
unit - the units to use
Returns:
the keep-alive time

setKeepAliveTime

public void setKeepAliveTime(long keepAliveTime,
                             TimeUnit unit)
Set the keep-alive time. If the service is already started, the change will take effect immediately.

Parameters:
keepAliveTime - the keep-alive time
unit - the time unit

setWorkQueue

public void setWorkQueue(BlockingQueue<Runnable> workQueue)
Set the configured work queue. If the service is already started, the change will take effect upon next restart.

Parameters:
workQueue - the work queue

getThreadFactory

public ThreadFactory getThreadFactory()
Get the configured thread factory.

Returns:
the thread factory

setThreadFactory

public void setThreadFactory(ThreadFactory threadFactory)
Set the configured thread factory. If the service is already started, the change will take effect immediately.

Parameters:
threadFactory - the thread factory

getHandler

public RejectedExecutionHandler getHandler()
Get the rejected execution handler.

Returns:
the rejected execution handler

setHandler

public void setHandler(RejectedExecutionHandler handler)
Set the rejected execution handler. If the service is already started, the change will take effect immediately.

Parameters:
handler - the rejected execution handler

getValue

public ExecutorService getValue()
                         throws IllegalStateException
Get the public executor service for this thread pool.

Specified by:
getValue in interface Value<ExecutorService>
Returns:
the public executor service
Throws:
IllegalStateException - if the service is not started

start

public void start(StartContext context)
           throws StartException
Start the service. Do not return until the service has been fully started, unless an asynchronous service start is performed. All injections will be complete before this method is called.

Specified by:
start in interface Service<ExecutorService>
Parameters:
context - the context which can be used to trigger an asynchronous service start
Throws:
StartException - if the service could not be started for some reason

stop

public void stop(StopContext context)
Stop the service. Do not return until the service has been fully stopped, unless an asynchronous service stop is performed. All injections will remain intact until the service is fully stopped. This method should not throw an exception.

Specified by:
stop in interface Service<ExecutorService>
Parameters:
context - the context which can be used to trigger an asynchronous service stop

JBoss Modular Service Kernel API 1.0.0.Beta1

Copyright © 2010 JBoss, a division of Red Hat, Inc.