|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jaw.impl.agent.services.scheduler.Scheduler
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.
SchedulerListener
,
SchedulerEvent
, Serialized FormField Summary | |
static long |
ONE_DAY
Number of milliseconds in one day. |
static long |
ONE_HOUR
Number of milliseconds in one hour. |
static long |
ONE_MINUTE
Number of milliseconds in one minute. |
static long |
ONE_SECOND
Number of milliseconds in one second. |
static long |
ONE_WEEK
Number of milliseconds in one week. |
Constructor Summary | |
Scheduler()
Creates a scheduler object. |
Method Summary | |
void |
addSchedulerListener(SchedulerListener listener)
Adds a scheduler listener. |
static java.lang.String |
getClassVersion()
Returns the version of this class. |
java.util.Date |
getDateFromEvent(SchedulerEvent event)
Returns a copy of the date of the specified scheduler event. |
java.util.Date |
getDateFromIndex(int index)
Returns a copy of the date of the scheduler event at the specified index. |
SchedulerEvent[] |
getListOfEvents()
Returns in an array all the events registered into the vector. |
java.lang.Long |
getNbRepetitionsFromEvent(SchedulerEvent event)
Returns a copy of the remaining number of repetitions of the specified scheduler event. |
java.lang.Long |
getNbRepetitionsFromIndex(int index)
Returns a copy of the remaining number of repetitions of the scheduler event at the specified index. |
boolean |
getNotifyPastEvents()
Returns the flag that indicates if the scheduler notifies past events or not. |
int |
getNumberOfEvents()
Returns the number of events registered into the vector. |
java.lang.Long |
getPeriodInMillisFromEvent(SchedulerEvent event)
Returns a copy of the period in milliseconds of the specified scheduler event. |
java.lang.Long |
getPeriodInMillisFromIndex(int index)
Returns a copy of the period in milliseconds of the scheduler event at the specified index. |
boolean |
isActive()
Tests if the Scheduler is active. |
boolean |
isListOfEventsEmpty()
Tests if the list of events is empty. |
void |
performAddEvent(SchedulerEvent event,
java.util.Date date)
Inserts the specified scheduler event into the vector with a given date and a null period and number of repetitions. |
void |
performAddEvent(SchedulerEvent event,
java.util.Date date,
long periodInMillis)
Inserts the specified scheduler event into the vector with a given date and period and a null number of repetitions. |
void |
performAddEvent(SchedulerEvent event,
java.util.Date date,
long periodInMillis,
long nbRepetitions)
Inserts the specified scheduler event into the vector with a given date, period and number of repetitions. |
void |
performRemoveAllEvents()
Removes all the events from the vector. |
void |
performRemoveEvent(int index)
Removes the scheduler event at the specified index from the vector. |
void |
performRemoveEvent(SchedulerEvent event)
Removes the specified scheduler event from the vector. |
void |
performStart()
Activates the Scheduler service. |
void |
performStop()
Deactivates the Scheduler service. |
void |
removeSchedulerListener(SchedulerListener listener)
Removes a scheduler listener. |
void |
setNotifyPastEvents(boolean b)
Sets the flag that indicates if the scheduler notifies past events or not. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final long ONE_SECOND
public static final long ONE_MINUTE
public static final long ONE_HOUR
public static final long ONE_DAY
public static final long ONE_WEEK
Constructor Detail |
public Scheduler()
Method Detail |
public void addSchedulerListener(SchedulerListener listener)
listener
- The scheduler listener to add.SchedulerListener
public void removeSchedulerListener(SchedulerListener listener)
listener
- The scheduler listener to remove.SchedulerListener
public void performAddEvent(SchedulerEvent event, java.util.Date date, long periodInMillis, long nbRepetitions) throws InstanceAlreadyExistException, InvalidPropertyValueException
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.
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.SchedulerEvent
public void performAddEvent(SchedulerEvent event, java.util.Date date, long periodInMillis) throws InstanceAlreadyExistException, InvalidPropertyValueException
The scheduler event will repeat continuously using the scheduler period.
event
- The scheduler event to be added.date
- The date when the event occurs.periodInMillis
- The period of the scheduler event.SchedulerEvent
public void performAddEvent(SchedulerEvent event, java.util.Date date) throws InstanceAlreadyExistException, InvalidPropertyValueException
The scheduler event will be handled once at date date
.
event
- The scheduler event to be added.date
- The date when the event occurs.SchedulerEvent
public void performRemoveEvent(SchedulerEvent event) throws InstanceNotFoundException
event
- The scheduler event to be removed.SchedulerEvent
public void performRemoveEvent(int index) throws InstanceNotFoundException
index
- The index in the vector of the scheduler event to remove.public void performRemoveAllEvents()
public void performStart()
Scheduler
service.public void performStop()
Scheduler
service.public boolean isActive()
Scheduler
is active.public SchedulerEvent[] getListOfEvents()
public java.util.Date getDateFromEvent(SchedulerEvent event)
event
- The scheduler event.SchedulerEvent
public java.util.Date getDateFromIndex(int index)
index
- The index of the scheduler event.public java.lang.Long getPeriodInMillisFromEvent(SchedulerEvent event)
event
- The scheduler event.SchedulerEvent
public java.lang.Long getPeriodInMillisFromIndex(int index)
index
- The index of the scheduler event.public java.lang.Long getNbRepetitionsFromEvent(SchedulerEvent event)
event
- The scheduler event.SchedulerEvent
public java.lang.Long getNbRepetitionsFromIndex(int index)
index
- The index of the scheduler event.public int getNumberOfEvents()
public boolean getNotifyPastEvents()
public void setNotifyPastEvents(boolean b)
public static java.lang.String getClassVersion()
public boolean isListOfEventsEmpty()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |