public class ActionExecutor extends Object
ActionWorker.| Modifier and Type | Field and Description |
|---|---|
protected Set<ActionWorker<?,?>> |
tasks
Cuurrent tasks.
|
protected PropertyChangeListener |
workerListener
The listener of running action.
|
| Constructor and Description |
|---|
ActionExecutor() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAction(ActionWorker<?,?> worker)
Add an new worker to perform.
|
ActionWorker<?,?> |
addAction(String actionLabel,
Runnable action)
Add an new action to perform.
|
void |
addActionExecutorListener(ActionExecutorListener listener) |
Runnable |
createRunnable(Object methodContainer,
String methodName,
Object... arguments)
Creates a runnable instance (via a Proxy) to a method given by his name
(
methodName) to invoke on methodcontainer with given
arguments. |
protected void |
executeWorker(String actionLabel,
ActionWorker<?,?> worker)
Execute worker once it was added to tasks.
|
protected void |
fireAction(ActionWorker<?,?> worker,
BiConsumer<ActionExecutorListener,ActionExecutorEvent> function) |
protected void |
fireActionCancel(ActionWorker<?,?> source) |
protected void |
fireActionDone(ActionWorker<?,?> worker) |
protected void |
fireActionEnd(ActionWorker<?,?> source) |
protected void |
fireActionFail(ActionWorker<?,?> source) |
protected void |
fireActionStart(ActionWorker<?,?> source) |
protected ActionExecutorListener[] |
getActionExecutorListener() |
int |
getNbActions() |
Set<ActionWorker<?,?>> |
getTasks() |
void |
onActionCancel(ActionWorker<?,?> source)
Hook when a action has been canceled.
|
void |
onActionEnd(ActionWorker<?,?> source)
Hook when a action has end with no failure or cancel.
|
void |
onActionFail(ActionWorker<?,?> source)
Hook when a action has failed.
|
void |
onActionStart(ActionWorker<?,?> source)
Hook when a action is about to start.
|
void |
onAfterAction(ActionWorker<?,?> source)
Hook after action is consumed.
|
void |
removeActionExecutorListener(ActionExecutorListener listener) |
void |
terminatesAndWaits()
Ask the thread to stop.
|
protected final Set<ActionWorker<?,?>> tasks
protected final PropertyChangeListener workerListener
public ActionWorker<?,?> addAction(String actionLabel, Runnable action)
actionLabel - the name of the action to performaction - the action to performpublic void addAction(ActionWorker<?,?> worker)
worker - the worker to runpublic void onActionStart(ActionWorker<?,?> source)
source - the action worker containing the action to performpublic void onActionFail(ActionWorker<?,?> source)
source - the action worker containing the action to performpublic void onActionCancel(ActionWorker<?,?> source)
source - the action worker containing the action to performpublic void onActionEnd(ActionWorker<?,?> source)
source - the action worker containing the action to performpublic void onAfterAction(ActionWorker<?,?> source)
source - the action worker containing the action to performpublic void terminatesAndWaits()
It will finish all incoming files (but will not accept more tasks). Note: The method does not return until all tasks are not consumed.
public void addActionExecutorListener(ActionExecutorListener listener)
public void removeActionExecutorListener(ActionExecutorListener listener)
protected ActionExecutorListener[] getActionExecutorListener()
protected void fireActionStart(ActionWorker<?,?> source)
protected void fireActionFail(ActionWorker<?,?> source)
protected void fireActionCancel(ActionWorker<?,?> source)
protected void fireActionEnd(ActionWorker<?,?> source)
protected void fireActionDone(ActionWorker<?,?> worker)
protected void fireAction(ActionWorker<?,?> worker, BiConsumer<ActionExecutorListener,ActionExecutorEvent> function)
public int getNbActions()
public Set<ActionWorker<?,?>> getTasks()
public Runnable createRunnable(Object methodContainer, String methodName, Object... arguments)
methodName) to invoke on methodcontainer with given
arguments.
This is a great feature to create runnable code with a real context.
methodContainer - the container of the method to invokemethodName - the name of the method to invokearguments - parameters to pass to method to invke.protected void executeWorker(String actionLabel, ActionWorker<?,?> worker)
This method permits to override how to execute it.
actionLabel - action labelworker - worker to executeCopyright © 2008–2020 Ultreia.io. All rights reserved.