public class CronSchedulerBuilder extends Object
CronScheduler. Create one using CronScheduler.newBuilder method.| Modifier and Type | Method and Description |
|---|---|
CronScheduler |
build()
Creates and returns a new
CronScheduler using this builder. |
CronSchedulerBuilder |
setBackwardTimeShiftLogger(Consumer<String> logger)
Sets the logger to log detected backward time shift events.
|
CronSchedulerBuilder |
setThreadFactory(ThreadFactory factory)
Sets the thread factory to be used to create the
CronScheduler's thread. |
CronSchedulerBuilder |
setThreadName(String threadName)
Sets the name for the
CronScheduler's thread. |
CronSchedulerBuilder |
setThreadPriority(int priority)
Sets the thread priority for the
CronScheduler's thread. |
CronSchedulerBuilder |
setTimeProvider(Clock timeProvider)
Sets the time provider to be used in
CronScheduler(s) created with this builder. |
public CronSchedulerBuilder setThreadPriority(int priority)
CronScheduler's thread. If specified, overwrites the
priority set by the ThreadFactory if any is set via setThreadFactory(ThreadFactory). By default, a thread of normal priority is created.priority - the priority for the CronScheduler's threadIllegalArgumentException - if the given priority is less than Thread.MIN_PRIORITY or greater than Thread.MAX_PRIORITY.public CronSchedulerBuilder setThreadName(String threadName)
CronScheduler's thread. If specified, overwrites the name set
by the ThreadFactory if any is set via setThreadFactory(ThreadFactory). By
default, a name like "cron-scheduler-N" is used, where N is a global sequence number.threadName - the name for the CronScheduler's threadNullPointerException - if the given name is nullpublic CronSchedulerBuilder setThreadFactory(ThreadFactory factory)
CronScheduler's thread. The default
thread factory creates daemon threads of normal priority,
not tied to any ThreadGroup, with a name of the form "cron-scheduler-N" where N is
a global sequence number. If setThreadName(java.lang.String) or setThreadPriority(int) are
explicitly specified they overwrite the values set by the thread factory.factory - the thread factory to be used to create the CronScheduler's thread.NullPointerException - if the given factory is nullpublic CronSchedulerBuilder setTimeProvider(Clock timeProvider)
CronScheduler(s) created with this builder. By
default, Clock.systemUTC() is used, which in turn delegates to currentTimeMillis. Note that the time zone embedded into the
Clock is not used by CronScheduler. Time zone-sensitive methods such
as scheduleAtRoundTimesInDay accept ZoneId as a parameter.timeProvider - a Clock instance used to provide the instant timeNullPointerException - if the given time provider is nullpublic CronScheduler build()
CronScheduler using this builder.CronScheduler using parameters configured in this builderpublic CronSchedulerBuilder setBackwardTimeShiftLogger(Consumer<String> logger)
Clock.instant() with a happens-before relation between them
return instantA and instantB where instantA is later than instantB. This may be caused by NTP server-initiated adjustments of the system time on the
machine, manual adjustments of the system time on the machine, or leap seconds. Note that
local time zone offset changes (e. g. daylight saving time changes) don't cause such
time shifts because they affect wall clock representation of the instant times, not the
instant times themselves.
By default, a lambda equivalent to message -> System.err.println(message) is used.
Example usage: setBackwardTimeShiftLogger(LoggerFactory.getLogger(CronScheduler.class)::info).
logger - the logger to log backward time shift events detected by the CronScheduler.NullPointerException - if the given logger is null