Package com.sodius.oslc.server.core.jobs
Class JobSchedule
- java.lang.Object
-
- com.sodius.oslc.server.core.jobs.JobSchedule
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JobSchedule.FixedDelaySchedule
,JobSchedule.FixedRateSchedule
public abstract class JobSchedule extends Object implements Serializable
Provides information on how to schedule a job.Jobs can be scheduled either at a
fixed rate
or with afixed delay
. A job can also bedisabled
, to suspend executions.- Since:
- 3.11.0
- See Also:
JobScheduler.schedule(Job, JobSchedule)
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JobSchedule.FixedDelaySchedule
Provides information for a job to schedule with a fixed delay.static class
JobSchedule.FixedRateSchedule
Provides information for a job to schedule at a fixed rate.static class
JobSchedule.Type
Determines the type of schedule.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static JobSchedule.FixedRateSchedule
atFixedRate(int hour, int minute)
Indicates the job is to run at fixed rate, at given hour and minute, each day.static JobSchedule
disabled()
Indicates the job is disabled and shall not run.abstract boolean
equals(Object obj)
abstract String
getDescription(List<Locale> locales)
Returns a description of the schedule, for end-user understanding, typically inserted in audit events.abstract JobSchedule.Type
getType()
Returns the type of scheduling.abstract int
hashCode()
String
toString()
static JobSchedule.FixedDelaySchedule
withFixedDelay(long initialDelay, long delay, TimeUnit unit)
Indicates the job is to run periodically with a given delay between the termination of one execution and the commencement of the next.
-
-
-
Method Detail
-
atFixedRate
public static JobSchedule.FixedRateSchedule atFixedRate(int hour, int minute)
Indicates the job is to run at fixed rate, at given hour and minute, each day.- Parameters:
hour
- the hour (0 to 23) at which the job must runminute
- the minute (0 to 59) at which the job must run- Returns:
- a job schedule
- Throws:
IllegalArgumentException
- if hour and minute values are out of range
-
withFixedDelay
public static JobSchedule.FixedDelaySchedule withFixedDelay(long initialDelay, long delay, TimeUnit unit)
Indicates the job is to run periodically with a given delay between the termination of one execution and the commencement of the next.Note a
cluster
job cannot use a fixed delay schedule.- Parameters:
initialDelay
- the initial delay before running the job, 0 or a negative number if the job must run immediatelydelay
- the delay between the termination of one execution and the commencement of the nextunit
- the unit of time for the two delay values- Returns:
- a job schedule
- Throws:
NullPointerException
- if unit is nullIllegalArgumentException
- if delay is not a positive number
-
disabled
public static JobSchedule disabled()
Indicates the job is disabled and shall not run. This method is convenient to suspend executions of jobs.- Returns:
- a job schedule
-
getType
public abstract JobSchedule.Type getType()
Returns the type of scheduling.- Returns:
- the type of scheduling.
-
getDescription
public abstract String getDescription(List<Locale> locales)
Returns a description of the schedule, for end-user understanding, typically inserted in audit events.- Parameters:
locales
- the locales to use, in decreasing order starting with the preferred locale- Returns:
- a description of the schedule
-
-