|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gcube.common.core.utils.handlers.GCUBEHandler<HANDLED>
org.gcube.common.core.utils.handlers.GCUBEScheduledHandler<HANDLED>
public class GCUBEScheduledHandler<HANDLED>
An extension of GCUBEComplexHandler which schedules the execution
of a single GCUBEHandler, the scheduled handler, at regular time intervals.
The execution of the scheduled handler occurs in accordance with either one of the two modes
enumerated by GCUBEScheduledHandler.Mode. In Mode.EAGER, the first execution of the scheduled handler
occurs immediately. In Mode.LAZY, it occurs after the first elapse of the time interval.
A GCUBEScheduledHandler may be halted in between iteration of the schedule, either explicitly, by
invoking stop(), or implicitly, by overriding repeat(Exception, int) to implement arbitrary
halting conditions.
| Nested Class Summary | |
|---|---|
static class |
GCUBEScheduledHandler.Mode
Possible modes of execution. |
| Field Summary | |
|---|---|
protected Exception |
exception
The last exception raised during the schedule. |
protected int |
exceptionCount
The number of exceptions raised at any point of the schedule. |
protected long |
interval
Time interval. |
protected boolean |
repeat
Stop flag. |
| Fields inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler |
|---|
handled, logger, producer |
| Constructor Summary | |
|---|---|
GCUBEScheduledHandler()
Creates an instance. |
|
GCUBEScheduledHandler(long interval,
GCUBEScheduledHandler.Mode mode,
GCUBEHandler<HANDLED>... handler)
Creates an instance with a given execution mode, time interval, and scheduled handler. |
|
| Method Summary | |
|---|---|
long |
getInterval()
Returns the interval of the schedule. |
GCUBEScheduledHandler.Mode |
getMode()
Returns the execution mode of the ScheduledHandler. |
GCUBEHandler<HANDLED> |
getScheduled()
Returns the scheduled handler. |
protected boolean |
onIteration()
Used internally to perform an iteration of the schedule and to indicate whether it should continue. |
protected boolean |
repeat(Exception exception,
int exceptionCount)
Indicates whether the scheduling should continue. |
void |
run()
Executes the task implemented by the handler. |
void |
setInterval(long interval)
Sets the interval of the schedule. |
void |
setMode(GCUBEScheduledHandler.Mode mode)
Sets the execution mode of the ScheduledHandler. |
void |
setScheduled(GCUBEHandler<HANDLED> scheduled)
Sets the scheduled handler. |
void |
stop()
Stops the scheduling. |
| Methods inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler |
|---|
clearBlackboard, getBlackboard, getHandled, getId, getLogger, getName, getScopeManager, getSecurityManager, getState, notify, setBlackboard, setHandled, setLogger, setName, setScopeManager, setSecurityManager, setState, subscribe, undo, unsubscribe |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.gcube.common.core.utils.handlers.lifetime.Lifetime |
|---|
getState |
| Methods inherited from interface org.gcube.common.core.utils.handlers.GCUBEIHandler |
|---|
clearBlackboard, getBlackboard, getHandled, getId, getLogger, getName, getScopeManager, getSecurityManager, setBlackboard, setHandled, setLogger, setName, setScopeManager, setSecurityManager, subscribe, undo, unsubscribe |
| Field Detail |
|---|
protected long interval
protected boolean repeat
protected Exception exception
protected int exceptionCount
| Constructor Detail |
|---|
public GCUBEScheduledHandler()
public GCUBEScheduledHandler(long interval,
GCUBEScheduledHandler.Mode mode,
GCUBEHandler<HANDLED>... handler)
interval - the time interval in seconds.mode - the execution mode.handler - (optional) the scheduled handler.| Method Detail |
|---|
public long getInterval()
public void setInterval(long interval)
the - interval.public GCUBEHandler<HANDLED> getScheduled()
public void setScheduled(GCUBEHandler<HANDLED> scheduled)
scheduled - the scheduled handled.public GCUBEScheduledHandler.Mode getMode()
ScheduledHandler.
public void setMode(GCUBEScheduledHandler.Mode mode)
ScheduledHandler.
mode - the mode.
public void run()
throws Exception
run in interface GCUBEIHandler<HANDLED>run in class GCUBEHandler<HANDLED>Exception - if the execution of the task does not complete normally.protected boolean onIteration()
true if the schedule should continue, false otherwise.public void stop()
protected boolean repeat(Exception exception,
int exceptionCount)
true if no exception occurred during the iteration,
and false otherwise. Override to implement
specific conditions.
exception - any exception which may have occurred during the iteration,
or null if the iteration completed successfully.exceptionCount - the number of exceptions which have occurred so far during the schedule.
true if the scheduling should continue, false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||