org.sape.carbon.services.scheduler
Class DefaultSchedulerServiceImpl

java.lang.Object
  |
  +--org.sape.carbon.services.scheduler.DefaultSchedulerServiceImpl
All Implemented Interfaces:
Configurable, FunctionalInterface, Initializable, SchedulerService, Startable, Suspendable

public class DefaultSchedulerServiceImpl
extends Object
implements SchedulerService, Initializable, Configurable, Startable, Suspendable

Default implementation for the SchedulerService. This implementation uses java.util.Timer to schedule tasks. When this service is stopped or suspended, all tasks are canceled. When this service is started or resumed, all configured tasks are scheduled.

Since:
carbon 1.0
Version:
$Revision: 1.13 $($Author: dvoet $ / $Date: 2003/12/08 15:59:15 $)
Author:
Douglas Voet, June 2002
See Also:
Copyright 2002 Sapient

Field Summary
private  Timer internalTimer
          Holds the timer object that will execute the tasks.
private  org.apache.commons.logging.Log log
          Provides a handle to Apache-commons logger
private  Collection scheduledTasks
          Holds the collection of scheduled tasks for this service.
private  Component thisComponent
           
 
Constructor Summary
DefaultSchedulerServiceImpl()
           
 
Method Summary
 void configure(ComponentConfiguration configuration)
          Configure the component.
 void initialize(Component thisComponent)
          Initialize the component.
 void resume()
          Resume the component.
private  void scheduleAllTasks()
          Iterates over tasks and schedules them.
 void start()
          Start the component.
 void stop()
          Stop the component.
 void suspend()
          Suspend the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log
Provides a handle to Apache-commons logger


internalTimer

private Timer internalTimer
Holds the timer object that will execute the tasks.


scheduledTasks

private Collection scheduledTasks
Holds the collection of scheduled tasks for this service.


thisComponent

private Component thisComponent
Constructor Detail

DefaultSchedulerServiceImpl

public DefaultSchedulerServiceImpl()
Method Detail

configure

public void configure(ComponentConfiguration configuration)
Description copied from interface: Configurable
Configure the component. This is preceded and followed by the suspend and resume operations if they are available on the component.

Specified by:
configure in interface Configurable
Parameters:
configuration - the configuration for this component
See Also:
Configurable.configure(ComponentConfiguration)

start

public void start()
Description copied from interface: Startable
Start the component. On return, the container will begin fowarding requests to the component. This may be an opportunity to dispatch worker threads.

Specified by:
start in interface Startable
See Also:
Startable.start()

stop

public void stop()
Description copied from interface: Startable
Stop the component. Prior to entry, the container will cease forwarding requests for service to the component. This is an opportunity to cleanly complete or abort any outstanding work. For example, a set of worker threads could be killed off, or a queue set to drain.

Specified by:
stop in interface Startable
See Also:
Startable.stop()

resume

public void resume()
Description copied from interface: Suspendable
Resume the component. This implies "picking-up where you left off". On return of this method, the container will resume forwarding service requests to the component.

Specified by:
resume in interface Suspendable
See Also:
Suspendable.resume()

suspend

public void suspend()
Description copied from interface: Suspendable
Suspend the component. This is an opportunity to 'pause' any ongoing work". Prior to calling this method, the container will block requests for service to the component.

Specified by:
suspend in interface Suspendable
See Also:
Suspendable.suspend()

initialize

public void initialize(Component thisComponent)
                throws Exception
Description copied from interface: Initializable
Initialize the component. Called immediately after the Component's constructor. On return, the container may start the component.

Specified by:
initialize in interface Initializable
Parameters:
thisComponent - the reference to the component that this object is a part of. Store this referece within your Functional Implementation for future use.
Throws:
Exception - when there is a failure to initialize the component

scheduleAllTasks

private void scheduleAllTasks()
Iterates over tasks and schedules them.



Copyright 1999-2003 Sapient Corporation. All Rights Reserved.