All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.jaw.impl.agent.services.scheduler.Scheduler
java.lang.Object
|
+----com.sun.jaw.impl.agent.services.scheduler.Scheduler
- public class Scheduler
- extends Object
- implements AlarmClockListener, Serializable, ActivatableIf
This class provides a simple implementation of a scheduler service.
The scheduler service sends out an alarm at a specified time
that wakes up all the listeners registered to receive scheduler events.
Implements a SchedulerListener interface in all objects
that are required to receive events of type SchedulerEvent.
The SchedulerEvent is a simple implementation of an event
used by the scheduler service.
This class uses a vector to store the scheduler events.
A method allows users to add/remove as many events as required.
Added scheduler events can be made into regularly repeating events.
Users can start or stop the scheduler service by invoking the
performStart/performStop methods.
Note:
All events before the time when the performAddEvent method is called
are ignored irrespective of the notifyPastEvents flag.
- See Also:
- SchedulerListener, SchedulerEvent
-
ONE_DAY
- Number of milliseconds in one day.
-
ONE_HOUR
- Number of milliseconds in one hour.
-
ONE_MINUTE
- Number of milliseconds in one minute.
-
ONE_SECOND
- Number of milliseconds in one second.
-
ONE_WEEK
- Number of milliseconds in one week.
-
Scheduler()
- Creates a scheduler object.
-
addSchedulerListener(SchedulerListener)
- Adds a scheduler listener.
-
getClassVersion()
- Returns the version of this class.
-
getDateFromEvent(SchedulerEvent)
- Returns a copy of the date of the specified scheduler event.
-
getDateFromIndex(int)
- Returns a copy of the date of the scheduler event at the specified index.
-
getListOfEvents()
- Returns in an array all the events registered into the vector.
-
getNbRepetitionsFromEvent(SchedulerEvent)
- Returns a copy of the remaining number of repetitions of the specified scheduler event.
-
getNbRepetitionsFromIndex(int)
- Returns a copy of the remaining number of repetitions of the scheduler event at the specified index.
-
getNotifyPastEvents()
- Returns the flag that indicates if the scheduler notifies past events or not.
-
getNumberOfEvents()
- Returns the number of events registered into the vector.
-
getPeriodInMillisFromEvent(SchedulerEvent)
- Returns a copy of the period in milliseconds of the specified scheduler event.
-
getPeriodInMillisFromIndex(int)
- Returns a copy of the period in milliseconds of the scheduler event at the specified index.
-
handleAlarmClock(AlarmClockEvent)
- This method is called each time an event has exceeded its time out.
-
isActive()
- Tests if the
Scheduler is active.
-
isListOfEventsEmpty()
- Tests if the list of events is empty.
-
performAddEvent(SchedulerEvent, Date)
- Inserts the specified scheduler event into the vector with a null
period and a null number of repetitions.
-
performAddEvent(SchedulerEvent, Date, long)
- Inserts the specified scheduler event into the vector with a null number
of repetitions.
-
performAddEvent(SchedulerEvent, Date, long, long)
- Inserts the specified scheduler event into the vector.
-
performRemoveAllEvents()
- Removes all the events from the vector.
-
performRemoveEvent(int)
- Removes the scheduler event at the specified index from the vector.
-
performRemoveEvent(SchedulerEvent)
- Removes the specified scheduler event from the vector.
-
performStart()
- Activates the
Scheduler service.
-
performStop()
- Deactivates the
Scheduler service.
-
removeSchedulerListener(SchedulerListener)
- Removes a scheduler listener.
-
setNotifyPastEvents(boolean)
- Sets the flag that indicates if the scheduler notifies past events or not.
ONE_SECOND
public static final long ONE_SECOND
- Number of milliseconds in one second.
Useful constant for the performAddEvent method.
ONE_MINUTE
public static final long ONE_MINUTE
- Number of milliseconds in one minute.
Useful constant for the performAddEvent method.
ONE_HOUR
public static final long ONE_HOUR
- Number of milliseconds in one hour.
Useful constant for the performAddEvent method.
ONE_DAY
public static final long ONE_DAY
- Number of milliseconds in one day.
Useful constant for the performAddEvent method.
ONE_WEEK
public static final long ONE_WEEK
- Number of milliseconds in one week.
Useful constant for the performAddEvent method.
Scheduler
public Scheduler()
- Creates a scheduler object.
handleAlarmClock
public void handleAlarmClock(AlarmClockEvent event)
- This method is called each time an event has exceeded its time out.
- Parameters:
- event - The alarm clock event.
- See Also:
- AlarmClockEvent
addSchedulerListener
public void addSchedulerListener(SchedulerListener listener)
- Adds a scheduler listener.
- Parameters:
- listener - The scheduler listener to add.
- See Also:
- SchedulerListener
removeSchedulerListener
public void removeSchedulerListener(SchedulerListener listener)
- Removes a scheduler listener.
- Parameters:
- listener - The scheduler listener to remove.
- See Also:
- SchedulerListener
performAddEvent
public synchronized void performAddEvent(SchedulerEvent event,
Date date,
long periodInMillis,
long nbRepetitions) throws InstanceAlreadyExistException, InvalidPropertyValueException
- Inserts the specified scheduler event into the vector.
If the scheduler event to be inserted has a date that is before the current date,
the method attempts to update the event using the defined period.
If the defined period is null then the method generates an exception.
If the scheduler event has a non null period, the date of the event is updated
by adding the period until the event date is later than the current date.
Then the scheduler event is inserted into the vector.
If the specified number of repetitions is non null, the previous mechanism
is employed. The number of times that the period is added is limited to
the specified number of repetitions. If the event date remains earlier than
the current date, an exception is generated.
A specified scheduler event can be added only once.
Note that once the scheduler event has been added into the vector,
its associated date, period and number of repetitions cannot be updated.
- Parameters:
- event - The scheduler event to be added.
- date - The date when the event occurs.
- periodInMillis - The period of the scheduler event.
- nbRepetitions - The number of repetitions of the scheduler event.
- Throws: InstanceAlreadyExistException
- The scheduler event to add is already in the vector.
- Throws: InvalidPropertyValueException
- The periodicity has negative values or
the date event is before the current date.
- See Also:
- SchedulerEvent
performAddEvent
public synchronized void performAddEvent(SchedulerEvent event,
Date date,
long periodInMillis) throws InstanceAlreadyExistException, InvalidPropertyValueException
- Inserts the specified scheduler event into the vector with a null number
of repetitions.
The scheduler event will repeat continuously using the scheduler period.
- Parameters:
- event - The scheduler event to be added.
- date - The date when the event occurs.
- periodInMillis - The period of the scheduler event.
- Throws: InstanceAlreadyExistException
- The scheduler event to add is already in the vector.
- Throws: InvalidPropertyValueException
- The periodicity has negative values or
the date event is before the current date.
- See Also:
- SchedulerEvent
performAddEvent
public synchronized void performAddEvent(SchedulerEvent event,
Date date) throws InstanceAlreadyExistException, InvalidPropertyValueException
- Inserts the specified scheduler event into the vector with a null
period and a null number of repetitions.
The scheduler event will be handled once at date
date.
- Parameters:
- event - The scheduler event to be added.
- date - The date when the event occurs.
- Throws: InstanceAlreadyExistException
- The scheduler event to add is already in the vector.
- Throws: InvalidPropertyValueException
- The periodicity has negative values or
the date event is before the current date.
- See Also:
- SchedulerEvent
performRemoveEvent
public synchronized void performRemoveEvent(SchedulerEvent event) throws InstanceNotFoundException
- Removes the specified scheduler event from the vector.
If the object is found in this vector, each component in the vector
with an index greater or equal to the object's index is shifted downward
to have an index one smaller than the value it had previously.
- Parameters:
- event - The scheduler event to be removed.
- Throws: InstanceNotFoundException
- The scheduler event to remove is not in the vector.
- See Also:
- SchedulerEvent
performRemoveEvent
public synchronized void performRemoveEvent(int index) throws InstanceNotFoundException
- Removes the scheduler event at the specified index from the vector.
Each component in this vector with an index greater or equal to the specified index
is shifted downward to have an index one smaller than the value it had previously.
- Parameters:
- index - The index in the vector of the scheduler event to remove.
- Throws: InstanceNotFoundException
- The index is invalid.
performRemoveAllEvents
public synchronized void performRemoveAllEvents()
- Removes all the events from the vector.
performStart
public synchronized void performStart()
- Activates the
Scheduler service.
performStop
public synchronized void performStop()
- Deactivates the
Scheduler service.
isActive
public boolean isActive()
- Tests if the
Scheduler is active.
getListOfEvents
public synchronized SchedulerEvent[] getListOfEvents()
- Returns in an array all the events registered into the vector.
getDateFromEvent
public Date getDateFromEvent(SchedulerEvent event)
- Returns a copy of the date of the specified scheduler event.
Returns null if the specified scheduler event is not in the vector.
- Parameters:
- event - The scheduler event.
- See Also:
- SchedulerEvent
getDateFromIndex
public Date getDateFromIndex(int index)
- Returns a copy of the date of the scheduler event at the specified index.
Returns null if the specified index is invalid.
- Parameters:
- index - The index of the scheduler event.
getPeriodInMillisFromEvent
public Long getPeriodInMillisFromEvent(SchedulerEvent event)
- Returns a copy of the period in milliseconds of the specified scheduler event.
Returns null if the specified scheduler event is not in the vector.
- Parameters:
- event - The scheduler event.
- See Also:
- SchedulerEvent
getPeriodInMillisFromIndex
public Long getPeriodInMillisFromIndex(int index)
- Returns a copy of the period in milliseconds of the scheduler event at the specified index.
Returns null if the specified index is invalid.
- Parameters:
- index - The index of the scheduler event.
getNbRepetitionsFromEvent
public Long getNbRepetitionsFromEvent(SchedulerEvent event)
- Returns a copy of the remaining number of repetitions of the specified scheduler event.
Returns null if the specified scheduler event is not in the vector.
- Parameters:
- event - The scheduler event.
- See Also:
- SchedulerEvent
getNbRepetitionsFromIndex
public Long getNbRepetitionsFromIndex(int index)
- Returns a copy of the remaining number of repetitions of the scheduler event at the specified index.
Returns null if the specified index is invalid.
- Parameters:
- index - The index of the scheduler event.
getNumberOfEvents
public int getNumberOfEvents()
- Returns the number of events registered into the vector.
getNotifyPastEvents
public boolean getNotifyPastEvents()
- Returns the flag that indicates if the scheduler notifies past events or not.
setNotifyPastEvents
public void setNotifyPastEvents(boolean b)
- Sets the flag that indicates if the scheduler notifies past events or not.
getClassVersion
public static String getClassVersion()
- Returns the version of this class.
isListOfEventsEmpty
public boolean isListOfEventsEmpty()
- Tests if the list of events is empty.
All Packages Class Hierarchy This Package Previous Next Index