Package com.sodius.oslc.server.core.jobs
Class Jobs
- java.lang.Object
-
- com.sodius.oslc.server.core.jobs.Jobs
-
public class Jobs extends Object
Provide helper functions to describe job configurations and validate schedules.- Since:
- 3.11.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JobScheduler
createScheduler(UnaryOperator<JobRunner> runnerAdapter)
Creates a scheduler that uses the given function to adapt the execution of jobs.static String
getDescription(String jobDescription, JobSchedule schedule, List<Locale> locales)
Returns a description combining the given short description and the job schedule.static BiFunction<JobSchedule,List<Locale>,String>
rejectFixedDelaySchedule()
Returns a function rejecting jobs scheduled with a fixed delay.static BiFunction<JobSchedule,List<Locale>,String>
rejectFixedRateSchedule()
Returns a function rejecting jobs scheduled at a fixed rate.
-
-
-
Method Detail
-
createScheduler
public static JobScheduler createScheduler(UnaryOperator<JobRunner> runnerAdapter)
Creates a scheduler that uses the given function to adapt the execution of jobs. The adapter can typically be used by an application to apply pre or post handling, for example when running background jobs requires additional care compared to regular requests with an authenticated user.- Parameters:
runnerAdapter
- the function adapting a given job runner- Returns:
- a scheduler using the adapter to execute jobs
-
getDescription
public static String getDescription(String jobDescription, JobSchedule schedule, List<Locale> locales)
Returns a description combining the given short description and the job schedule. This method shall be used in aconfig provider
to assign a description on a job configuration.- Parameters:
jobDescription
- a short description of the job, e.g."Repairing all TRS feeds"
schedule
- the job schedulelocales
- the locales to use, in decreasing order starting with the preferred locale- Returns:
- a description including schedule information
- See Also:
Job.Builder.configProvider(BiFunction)
-
rejectFixedRateSchedule
public static BiFunction<JobSchedule,List<Locale>,String> rejectFixedRateSchedule()
Returns a function rejecting jobs scheduled at a fixed rate.- Returns:
- a function to reject jobs scheduled at a fixed rate.
- See Also:
Job.Builder.scheduleValidator(BiFunction)
-
rejectFixedDelaySchedule
public static BiFunction<JobSchedule,List<Locale>,String> rejectFixedDelaySchedule()
Returns a function rejecting jobs scheduled with a fixed delay.- Returns:
- a function to reject jobs scheduled with a fixed delay.
- See Also:
Job.Builder.scheduleValidator(BiFunction)
-
-