com.cometway.ak
Class Scheduler

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.ServiceAgent
              extended by com.cometway.ak.Scheduler
All Implemented Interfaces:
AgentInterface, HasStateMachineModel, IScheduleChangeListener, IScheduler

public class Scheduler
extends ServiceAgent
implements IScheduler, IScheduleChangeListener

The Scheduler is a ServiceAgent which implements the com.cometway.util.IScheduler interface. It maintains a pool of threads that periodically wake up any com.cometway.util.IScheduleable that has been scheduled.


Field Summary
 java.util.Hashtable threadHash
           
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Constructor Summary
Scheduler()
           
 
Method Summary
static IScheduler getScheduler()
          Returns a reference to the Scheduler registered with the Service Manager.
static IScheduler getScheduler(java.lang.String serviceName)
          Returns a reference to the Scheduler registered as the passed name with the Service Manager.
 int getSize()
          Get the size of the Scheduler.
 void initProps()
          Initializes the Props for this agent: service_name The service name this agent uses to register with the Service Manager.
 boolean schedule(ISchedulable schedulable)
          Method implements IScheduler.schedule().
 void scheduleChanged(ISchedulable schedulable)
          Method implements IScheduleChangeListener.scheduleChanged()
 void setDebug(boolean debug)
          Set the debug state of Scheduler.
 void start()
          Starts up the scheduler and registers it with the Service Manager.
 boolean unschedule(ISchedulable schedulable)
          Method implements IScheduler.unschedule().
 
Methods inherited from class com.cometway.ak.ServiceAgent
stop
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

threadHash

public java.util.Hashtable threadHash
Constructor Detail

Scheduler

public Scheduler()
Method Detail

initProps

public void initProps()
Initializes the Props for this agent:
service_name
The service name this agent uses to register with the Service Manager.
number_of_threads
The number of threads reserved for waking up scheduled clients.

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class Agent

start

public void start()
Starts up the scheduler and registers it with the Service Manager.

Specified by:
start in interface AgentInterface
Overrides:
start in class ServiceAgent

setDebug

public void setDebug(boolean debug)
Set the debug state of Scheduler.


schedule

public boolean schedule(ISchedulable schedulable)
Method implements IScheduler.schedule(). Given an ISchedulable item, method adds the item to the Scheduler.

Specified by:
schedule in interface IScheduler
Parameters:
schedulable - an object which implements the ISchedulable interface.
Returns:
true if the object was added; false otherwise.
See Also:
ISchedulable

unschedule

public boolean unschedule(ISchedulable schedulable)
Method implements IScheduler.unschedule(). Given an ISchedulable item, method removes that item from the Scheduler.

Specified by:
unschedule in interface IScheduler
Parameters:
schedulable - an object which implements the ISchedulable interface.
Returns:
true if the object was removed; false if the object was invalid.
See Also:
ISchedulable

scheduleChanged

public void scheduleChanged(ISchedulable schedulable)
Method implements IScheduleChangeListener.scheduleChanged()

Specified by:
scheduleChanged in interface IScheduleChangeListener
Parameters:
schedulable - a reference to the IScheduleable object whose schedule has changed.

getSize

public int getSize()
Get the size of the Scheduler.


getScheduler

public static IScheduler getScheduler()
Returns a reference to the Scheduler registered with the Service Manager.


getScheduler

public static IScheduler getScheduler(java.lang.String serviceName)
Returns a reference to the Scheduler registered as the passed name with the Service Manager.