Package com.sun.identity.common
Class PeriodicRunnable
- java.lang.Object
-
- com.sun.identity.common.GeneralTaskRunnable
-
- com.sun.identity.common.PeriodicRunnable
-
- All Implemented Interfaces:
TaskRunnable,Runnable
- Direct Known Subclasses:
PeriodicGroupRunnable
public class PeriodicRunnable extends GeneralTaskRunnable
Periodic task (task will be run periodically) which has handler integrated (implements ScheduleableAction) can be scheduled to Timer or TimerPool by using PeriodicRunnable. All the elements in the same PeriodicRunnable must have the same timeout period and run period. Elements will be grouped by using the time they enter PeriodicRunnable. Elements which entered PeriodicRunnable excess the timeout time will be checked 1 by 1 and ScheduleableAction (doAction()) will be invoked.
-
-
Field Summary
Fields Modifier and Type Field Description protected intcontainerNeededprotected Set[]nextTurnprotected booleanremoveElementAfterActionprotected longrunPeriodprotected SetthisTurnprotected longtimeoutPeriod-
Fields inherited from class com.sun.identity.common.GeneralTaskRunnable
headTask, nextTask, previousTask
-
-
Constructor Summary
Constructors Constructor Description PeriodicRunnable(long runPeriod, long timeoutPeriod, boolean removeElementAfterAction)Constructor of PeriodicRunnable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddElement(Object obj)Adds an element to this PeriodicRunnable.longgetRunPeriod()Returns the run period of this PeriodicRunnable.longgetTimeoutPeriod()Returns the timeout period of this PeriodicRunnable.booleanisEmpty()Indicates whether this PeriodicRunnable is empty.booleanremoveElement(Object obj)Removes an element from this PeriodicRunnable.voidrun()Implements for TaskRunnable.-
Methods inherited from class com.sun.identity.common.GeneralTaskRunnable
cancel, getHeadTask, isScheduled, next, previous, scheduledExecutionTime, setHeadTask, setNext, setPrevious
-
-
-
-
Constructor Detail
-
PeriodicRunnable
public PeriodicRunnable(long runPeriod, long timeoutPeriod, boolean removeElementAfterAction) throws IllegalArgumentExceptionConstructor of PeriodicRunnable.- Parameters:
runPeriod- The period of running this PeriodicRunnabletimeoutPeriod- The timeout period of the objects in this PeriodicRunnableremoveElementAfterAction- Whether to remove the elements after running the ScheduleableAction on the objects- Throws:
IllegalArgumentException
-
-
Method Detail
-
addElement
public boolean addElement(Object obj)
Adds an element to this PeriodicRunnable.- Parameters:
obj- Element to be added to this PeriodicRunnable- Returns:
- a boolean to indicate whether the add success
-
removeElement
public boolean removeElement(Object obj)
Removes an element from this PeriodicRunnable.- Parameters:
obj- Element to be removed from this PeriodicRunnable- Returns:
- A boolean to indicate whether the remove success
-
getTimeoutPeriod
public long getTimeoutPeriod()
Returns the timeout period of this PeriodicRunnable.- Returns:
- A long value to indicate the timeout period
-
isEmpty
public boolean isEmpty()
Indicates whether this PeriodicRunnable is empty.- Returns:
- A boolean to indicate whether this PeriodicRunnable is empty
-
getRunPeriod
public long getRunPeriod()
Returns the run period of this PeriodicRunnable.- Returns:
- A long value to indicate the run period
-
run
public void run()
Implements for TaskRunnable. Run the function of ScheduleableAction on all the objects in thisTurn 1 by 1, and interchange thisTurn and nextTurn.
-
-