public class BasicExecutionEngine extends java.lang.Object implements ExecutionManager
| Modifier and Type | Class and Description |
|---|---|
protected class |
BasicExecutionEngine.SelfSchedulingRunner |
class |
BasicExecutionEngine.ThrowableCatchingRunnable |
| Constructor and Description |
|---|
BasicExecutionEngine() |
BasicExecutionEngine(int threadCount,
java.lang.String name) |
BasicExecutionEngine(int threadCount,
java.lang.String name,
boolean daemon) |
BasicExecutionEngine(int threadCount,
java.lang.String name,
java.util.concurrent.ThreadFactory threadFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
executeOnce(java.lang.Runnable command)
Executes a runnable one time as soon as possible.
|
void |
executeOnce(java.lang.Runnable command,
long delay)
Excutes a runnable one time after a delay, specified in milliseconds
|
java.util.concurrent.ScheduledFuture<?> |
executeOnce(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
Executes a runnable after a fixed delay
|
java.lang.String |
getName() |
java.util.List<java.lang.String> |
getTaskOwners() |
java.util.List<TaskStats> |
getTasks(java.lang.String owner) |
void |
modify(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int newRate,
java.util.concurrent.TimeUnit newUnit)
Modifies the execution rate of the given execution unit.
|
void |
modifyFixedRate(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int newRate,
java.util.concurrent.TimeUnit newUnit) |
void |
register(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate)
Registers a command to be executing repeatedly at the specified rate.
|
void |
register(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit)
Registers a command to be executing repeatedly at the specified rate.
|
void |
register(java.lang.String owner,
java.lang.String name,
SelfSchedulingRunnable command)
Registers a self scheduling command to be executed.
|
void |
registerAtFixedRate(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit)
Registers a command to be executed with a fixed rate rather than a fixed delay.
|
void |
registerAtFixedRateWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit,
int initialDelay)
Registers a command to be executed with a fixed rate after some initial delay.
|
void |
registerWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
int initialDelay)
Registers a command to be executing repeatedly at the specified rate with an initial delay.
|
void |
registerWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit,
int initialDelay)
Registers a command to be executing repeatedly at the specified rate with an initial delay.
|
java.lang.String |
schedule(java.lang.String taskName,
java.lang.Runnable task,
java.lang.String cronPattern) |
protected void |
scheduleNext(BasicExecutionEngine.SelfSchedulingRunner ssr) |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
Schedules a runnable to execute with a fixed delay, and after an initial delay, much like
ExecutionManager.registerWithInitialDelay(String, String, Runnable, int, TimeUnit, int). |
void |
shutdown()
Stops all execution gracefully.
|
protected void |
synchedUpdateTaskMap(java.lang.String owner,
java.lang.String name,
java.util.concurrent.ScheduledFuture<?> future)
Updates the task map.
|
java.lang.String |
toString() |
void |
unRegister(java.lang.String owner,
java.lang.String name)
De-registers the execution unit.
|
void |
unRegisterAll(java.lang.String owner)
Unregisters all tasks for a given owner.
|
void |
unSchedule(java.lang.String taskId) |
public BasicExecutionEngine()
public BasicExecutionEngine(int threadCount,
java.lang.String name)
public BasicExecutionEngine(int threadCount,
java.lang.String name,
boolean daemon)
public BasicExecutionEngine(int threadCount,
java.lang.String name,
java.util.concurrent.ThreadFactory threadFactory)
public java.lang.String getName()
public void shutdown()
ExecutionManagershutdown in interface ExecutionManagerpublic java.lang.String schedule(java.lang.String taskName,
java.lang.Runnable task,
java.lang.String cronPattern)
throws it.sauronsoftware.cron4j.InvalidPatternException
it.sauronsoftware.cron4j.InvalidPatternExceptionpublic void unSchedule(java.lang.String taskId)
public void register(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate)
ExecutionManagerregister in interface ExecutionManagerowner - name of the "owner"- just a string qualifier for the command name.name - identifier used in conjunction with the owner to identify the command.command - Runnable to be called at the specified rate.rate - The amount of time to wait in between invocations of the command, in milliseconds.public void register(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit)
ExecutionManagerregister in interface ExecutionManagerowner - name of the "owner"- just a string qualifier for the command name.name - identifier used in conjunction with the owner to identify the command.command - Runnable to be called at the specified rate.public void registerAtFixedRate(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit)
ExecutionManagerregisterAtFixedRate in interface ExecutionManagerpublic void registerAtFixedRateWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit,
int initialDelay)
ExecutionManagerregisterAtFixedRateWithInitialDelay in interface ExecutionManagerprotected void synchedUpdateTaskMap(java.lang.String owner,
java.lang.String name,
java.util.concurrent.ScheduledFuture<?> future)
public void registerWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
int initialDelay)
ExecutionManagerregisterWithInitialDelay in interface ExecutionManagerpublic void registerWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit,
int initialDelay)
ExecutionManagerregisterWithInitialDelay in interface ExecutionManagerpublic void modify(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int newRate,
java.util.concurrent.TimeUnit newUnit)
public void modifyFixedRate(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int newRate,
java.util.concurrent.TimeUnit newUnit)
public void unRegister(java.lang.String owner,
java.lang.String name)
unRegister in interface ExecutionManagerpublic void unRegisterAll(java.lang.String owner)
unRegisterAll in interface ExecutionManagerpublic void executeOnce(java.lang.Runnable command)
executeOnce in interface ExecutionManagerpublic void executeOnce(java.lang.Runnable command,
long delay)
ExecutionManagerexecuteOnce in interface ExecutionManagerpublic java.util.concurrent.ScheduledFuture<?> executeOnce(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
throws java.util.concurrent.RejectedExecutionException
executeOnce in interface ExecutionManagerjava.util.concurrent.RejectedExecutionExceptionpublic void register(java.lang.String owner,
java.lang.String name,
SelfSchedulingRunnable command)
ExecutionManagerregister in interface ExecutionManagerprotected void scheduleNext(BasicExecutionEngine.SelfSchedulingRunner ssr)
public java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
ExecutionManagerExecutionManager.registerWithInitialDelay(String, String, Runnable, int, TimeUnit, int). The difference is that this
method returns a ScheduledFuture that can be used to cancel the task.scheduleWithFixedDelay in interface ExecutionManagerpublic java.util.List<java.lang.String> getTaskOwners()
public java.util.List<TaskStats> getTasks(java.lang.String owner)
public java.lang.String toString()
toString in class java.lang.Object