jrunx.scheduler
Class SchedulerService

jrunx.kernel.ServiceAdapter
  |
  +--jrunx.scheduler.ThreadPoolService
        |
        +--jrunx.scheduler.SchedulerService
All Implemented Interfaces:
javax.naming.Referenceable, java.lang.Runnable, RunnableFactory, Scheduler, SchedulerServiceMBean, java.io.Serializable, Service, ServiceMBean, ThreadPoolServiceMBean

public class SchedulerService
extends ThreadPoolService
implements Scheduler, RunnableFactory, java.lang.Runnable

See Also:
Serialized Form

Fields inherited from class jrunx.scheduler.ThreadPoolService
metrics, threadPool
 
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
 
Fields inherited from interface jrunx.scheduler.RunnableFactory
BUSY, EXCEPTION, SHUTDOWN
 
Constructor Summary
SchedulerService()
           
 
Method Summary
 int cancel(java.lang.Runnable r)
          Cancels any scheduled timer events for the given Runnable objects.
 java.lang.Runnable createRunnable()
          get a runnable object, or sleep until one is available.
 void destroy()
          Every service is eventually destroyed.
 void destroyRunnable(java.lang.Runnable r)
          destroy a runnable.
 void destroyRunnable(java.lang.Runnable r, int reason)
          destroy a runnable.
protected  void dump()
          For debugging
 java.lang.String getMetricsPrefix()
           
 RunnableFactory getRunnableFactory()
           
protected  void initArrays()
           
 void invokeRunnable(java.lang.Runnable r)
          process this request.
 void registerForShutDown(java.lang.Runnable object)
          Registers a Runnable object with the shutdown hook
 void run()
          Use by the shutdown hook to clean up resources before the VM exists
 void schedule(java.lang.Runnable r, long when)
          Schedule a Runnable object to be run at an absolute time.
 void scheduleFromNow(java.lang.Runnable r, long when)
          Schedule a Runnable object to be run at a relative time from now.
 void shutdownObjects()
          Initiates shutdown on all running objects which registered for shutdown.
 void start()
          Every service other than mere data collections should start
 java.lang.Runnable swapRunnable(java.lang.Runnable r)
          get the next runnable object.
 
Methods inherited from class jrunx.scheduler.ThreadPoolService
createMetrics, getActiveHandlerThreads, getMaxHandlerThreads, getMetrics, getMinHandlerThreads, getThreadWaitTimeout, init, setActiveHandlerThreads, setMaxHandlerThreads, setMinHandlerThreads, setThreadWaitTimeout
 
Methods inherited from class jrunx.kernel.ServiceAdapter
bind, 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, stop, toString, unbind, unscheduleRunnable, updateStatus
 
Methods inherited from interface jrunx.scheduler.ThreadPoolServiceMBean
getActiveHandlerThreads, getMaxHandlerThreads, getMinHandlerThreads, getThreadWaitTimeout, setActiveHandlerThreads, setMaxHandlerThreads, setMinHandlerThreads, setThreadWaitTimeout
 
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
getStatus, init, stop, updateStatus
 

Constructor Detail

SchedulerService

public SchedulerService()
Method Detail

start

public void start()
           throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service other than mere data collections should start
Specified by:
start in interface Service
Overrides:
start in class ThreadPoolService

getMetricsPrefix

public java.lang.String getMetricsPrefix()
Overrides:
getMetricsPrefix in class ThreadPoolService

getRunnableFactory

public RunnableFactory getRunnableFactory()
Overrides:
getRunnableFactory in class ThreadPoolService

initArrays

protected void initArrays()

destroy

public void destroy()
             throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service is eventually destroyed. Convenience implementation.
Specified by:
destroy in interface Service
Overrides:
destroy in class ServiceAdapter

createRunnable

public java.lang.Runnable createRunnable()
                                  throws java.lang.InterruptedException
get a runnable object, or sleep until one is available.
Specified by:
createRunnable in interface RunnableFactory
Returns:
a Runnable to run.

swapRunnable

public java.lang.Runnable swapRunnable(java.lang.Runnable r)
                                throws java.lang.InterruptedException
get the next runnable object. This implementation simply returns null, meaning the runnable can be discarded, and another one can be fetched using createRunnable.
Specified by:
swapRunnable in interface RunnableFactory
Parameters:
r - a Runnable that just finished running

destroyRunnable

public void destroyRunnable(java.lang.Runnable r)
destroy a runnable. For timing events, there is nothing special to do here.

invokeRunnable

public void invokeRunnable(java.lang.Runnable r)
Description copied from interface: RunnableFactory
process this request. entry point into filter pattern
Specified by:
invokeRunnable in interface RunnableFactory

destroyRunnable

public void destroyRunnable(java.lang.Runnable r,
                            int reason)
destroy a runnable. For timing events, there is nothing special to do here.
Specified by:
destroyRunnable in interface RunnableFactory

schedule

public void schedule(java.lang.Runnable r,
                     long when)
Description copied from interface: SchedulerServiceMBean
Schedule a Runnable object to be run at an absolute time.
Specified by:
schedule in interface SchedulerServiceMBean
Following copied from interface: jrunx.scheduler.SchedulerServiceMBean
Parameters:
r - The thing to run at a certain time
when - The absolute time at which to run it

scheduleFromNow

public void scheduleFromNow(java.lang.Runnable r,
                            long when)
Description copied from interface: SchedulerServiceMBean
Schedule a Runnable object to be run at a relative time from now.
Specified by:
scheduleFromNow in interface SchedulerServiceMBean
Following copied from interface: jrunx.scheduler.SchedulerServiceMBean
Parameters:
r - The thing to run at a certain time
when - The number of ms from now to run

registerForShutDown

public void registerForShutDown(java.lang.Runnable object)
Description copied from interface: SchedulerServiceMBean
Registers a Runnable object with the shutdown hook
Specified by:
registerForShutDown in interface SchedulerServiceMBean
Following copied from interface: jrunx.scheduler.SchedulerServiceMBean
Parameters:
object - The runnable object

cancel

public int cancel(java.lang.Runnable r)
Description copied from interface: SchedulerServiceMBean
Cancels any scheduled timer events for the given Runnable objects. If more than one event exists, all will be removed.
Specified by:
cancel in interface SchedulerServiceMBean
Following copied from interface: jrunx.scheduler.SchedulerServiceMBean
Parameters:
r - The object timer to cancel
Returns:
The number of timers removed

dump

protected void dump()
For debugging

run

public void run()
Use by the shutdown hook to clean up resources before the VM exists
Specified by:
run in interface java.lang.Runnable

shutdownObjects

public void shutdownObjects()
Description copied from interface: SchedulerServiceMBean
Initiates shutdown on all running objects which registered for shutdown.
Specified by:
shutdownObjects in interface SchedulerServiceMBean


Copyright � 2002 Macromedia Corporation. All Rights Reserved.