Package jaxx.runtime.swing.application
Class ActionExecutor
java.lang.Object
jaxx.runtime.swing.application.ActionExecutor
public abstract class ActionExecutor
extends java.lang.Object
Executor of
ActionWorker.- Since:
- 2.1
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<ActionWorker<?,?>>taskscurrent tasksprotected java.beans.PropertyChangeListenerworkerListenerthe listener of running action -
Constructor Summary
Constructors Constructor Description ActionExecutor() -
Method Summary
Modifier and Type Method Description ActionWorker<?,?>addAction(java.lang.String actionLabel, java.lang.Runnable action)Add an new action to perform.java.lang.RunnablecreateRunnable(java.lang.Object methodContainer, java.lang.String methodName, java.lang.Object... arguments)Creates a runnable instance (via a Proxy) to a method given by his name (methodName) to invoke onmethodcontainerwith givenarguments.intgetNbActions()java.util.Set<ActionWorker<?,?>>getTasks()abstract voidonActionCancel(ActionWorker<?,?> source)Hook when a action has been canceled.abstract voidonActionEnd(ActionWorker<?,?> source)Hook when a action has end with no failure or cancel.abstract voidonActionFail(ActionWorker<?,?> source)Hook when a action has failed.abstract voidonActionStart(ActionWorker<?,?> source)Hook when a action is about to start.abstract voidonAfterAction(ActionWorker<?,?> source)Hook atfer action is consumed.voidterminatesAndWaits()Ask the thread to stop.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
tasks
current tasks -
workerListener
protected final java.beans.PropertyChangeListener workerListenerthe listener of running action
-
-
Constructor Details
-
ActionExecutor
public ActionExecutor()
-
-
Method Details
-
onActionStart
Hook when a action is about to start.- Parameters:
source- the action worker containing the action to perform
-
onActionFail
Hook when a action has failed.- Parameters:
source- the action worker containing the action to perform
-
onActionCancel
Hook when a action has been canceled.- Parameters:
source- the action worker containing the action to perform
-
onActionEnd
Hook when a action has end with no failure or cancel.- Parameters:
source- the action worker containing the action to perform
-
onAfterAction
Hook atfer action is consumed.- Parameters:
source- the action worker containing the action to perform
-
addAction
Add an new action to perform.- Parameters:
actionLabel- the name of the action to performaction- the action to perform- Returns:
- the worker that will launch the action
-
terminatesAndWaits
public void terminatesAndWaits() throws java.lang.InterruptedExceptionAsk the thread to stop. It will finish all incoming files (but will not accept more tasks). Note: The method does not return until all tasks are not consumed.- Throws:
java.lang.InterruptedException- if something wrong while waiting end of executor
-
getNbActions
public int getNbActions() -
getTasks
-
createRunnable
public java.lang.Runnable createRunnable(java.lang.Object methodContainer, java.lang.String methodName, java.lang.Object... arguments)Creates a runnable instance (via a Proxy) to a method given by his name (methodName) to invoke onmethodcontainerwith givenarguments. This is a great feature to create runnable code with a real context.- Parameters:
methodContainer- the container of the method to invokemethodName- the name of the method to invokearguments- parameters to pass to method to invke.- Returns:
- the proxy instance
-