stella
Class AbstractScheduler

java.lang.Object
  extended by util.PropertyContainer
      extended by stella.AbstractScheduler
All Implemented Interfaces:
Cloneable, Scheduling, Initializable, PropertyBearing
Direct Known Subclasses:
XMLScheduler

public abstract class AbstractScheduler
extends PropertyContainer
implements Scheduling

An abstract implementation of the Scheduling interface. Provided are methods for loading a target list and for registering a set of globals. A constructor using a single Map object as argument is provided.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private  Collection<Appointable.Constraint> global
          The collection of global constraints currently assigned.
private  Object sleeper
          Notify this object if asked to.
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
protected AbstractScheduler(Map<String,String> sprop)
          Protected constructer defining this schedulers properties.
 
Method Summary
 void addGlobalConstraint(Appointable.Constraint cons)
          Adds a global constraint to the scheduler.
protected  boolean checkGlobalConstraints(ParameterClustering set, TargetDefinition target)
          Checks, if the target is observable under all global constraints.
static Scheduling createScheduler(Map<String,String> prop)
          Constructs a new scheduling instance using the mapping of the PropertyBearing.KEY_CLASS to the class name to derive the class to instantiate.
 Collection<Appointable.Constraint> getGlobalConstraints()
          Returns a collection of all currently registered global constraints.
 Collection<TargetDefinition> getObservableTargets(ParameterClustering set, Collection<TargetDefinition> targets)
          Shortens the list of targets to all targets thet are currently observable.
 Object registerMonitor(Object waiter)
          Registers an object for notification.
 void removeAllGlobalConstraints()
          Removes all global constraints.
 void removeGlobalConstraint(Appointable.Constraint cons)
          Removes a global constraint from the scheduler.
protected  void wakeUp()
          Notifies the sleeping object if it is set.
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, init, isNew, keyCreate, keyCreate, parseObject, reload, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Scheduling
getHighestTarget
 
Methods inherited from interface util.PropertyBearing
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getLocalized, getProperties, getProperty, getResource, getResourceAsStream, getResources, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

global

private Collection<Appointable.Constraint> global
The collection of global constraints currently assigned.


sleeper

private Object sleeper
Notify this object if asked to.

Constructor Detail

AbstractScheduler

protected AbstractScheduler(Map<String,String> sprop)
Protected constructer defining this schedulers properties.

Method Detail

addGlobalConstraint

public void addGlobalConstraint(Appointable.Constraint cons)
Adds a global constraint to the scheduler.

Specified by:
addGlobalConstraint in interface Scheduling

removeGlobalConstraint

public void removeGlobalConstraint(Appointable.Constraint cons)
Removes a global constraint from the scheduler.

Specified by:
removeGlobalConstraint in interface Scheduling

removeAllGlobalConstraints

public void removeAllGlobalConstraints()
Removes all global constraints.

Specified by:
removeAllGlobalConstraints in interface Scheduling

getGlobalConstraints

public Collection<Appointable.Constraint> getGlobalConstraints()
Returns a collection of all currently registered global constraints. If no globals have been added, null is returned.

Specified by:
getGlobalConstraints in interface Scheduling

registerMonitor

public Object registerMonitor(Object waiter)
Registers an object for notification. If the method wakeUp() is called after an object has been registered the argumental objects is notified of any change happened to the sequencer. Due to the synchronizing behaviour of the wakeUp() method, care must be taken to avoid dead-lock.

Specified by:
registerMonitor in interface Scheduling
Returns:
The previously monitored object.

getObservableTargets

public Collection<TargetDefinition> getObservableTargets(ParameterClustering set,
                                                         Collection<TargetDefinition> targets)
Shortens the list of targets to all targets thet are currently observable. Does this by checking the global requirement and by calculating the remaining time from the constraints. Only targets that have a remainig time higher then zero survive.

Specified by:
getObservableTargets in interface Scheduling
Returns:
observable A list of currently observable targets

checkGlobalConstraints

protected boolean checkGlobalConstraints(ParameterClustering set,
                                         TargetDefinition target)
Checks, if the target is observable under all global constraints.


wakeUp

protected void wakeUp()
Notifies the sleeping object if it is set. Tries to synchronize on the object prior to notification.


createScheduler

public static final Scheduling createScheduler(Map<String,String> prop)
Constructs a new scheduling instance using the mapping of the PropertyBearing.KEY_CLASS to the class name to derive the class to instantiate. If this property is defined, a new Scheduling instance with the stated class name is created, the supplied properties used as an argument in the constructor. Can throw a lot of exceptions if unsuccessful.