jaxx.runtime.swing.application
Class ActionExecutor

java.lang.Object
  extended by jaxx.runtime.swing.application.ActionExecutor

public abstract class ActionExecutor
extends Object

Executor of ActionWorker.

Since:
2.1
Author:
tchemit

Field Summary
protected  Set<ActionWorker<?,?>> tasks
          current tasks
protected  PropertyChangeListener workerListener
          the listener of running action
 
Constructor Summary
ActionExecutor()
           
 
Method Summary
 ActionWorker<?,?> addAction(String actionLabel, Runnable action)
          Add an new action to perform.
 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.
 int getNbActions()
           
 Set<ActionWorker<?,?>> getTasks()
           
abstract  void onActionCancel(ActionWorker<?,?> source)
          Hook when a action has been canceled.
abstract  void onActionEnd(ActionWorker<?,?> source)
          Hook when a action has end with no failure or cancel.
abstract  void onActionFail(ActionWorker<?,?> source)
          Hook when a action has failed.
abstract  void onActionStart(ActionWorker<?,?> source)
          Hook when a action is about to start.
abstract  void onAfterAction(ActionWorker<?,?> source)
          Hook atfer action is consumed.
 void terminatesAndWaits()
          Ask the thread to stop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tasks

protected final Set<ActionWorker<?,?>> tasks
current tasks


workerListener

protected final PropertyChangeListener workerListener
the listener of running action

Constructor Detail

ActionExecutor

public ActionExecutor()
Method Detail

onActionStart

public abstract void onActionStart(ActionWorker<?,?> source)
Hook when a action is about to start.

Parameters:
source - the action worker containing the action to perform

onActionFail

public abstract void onActionFail(ActionWorker<?,?> source)
Hook when a action has failed.

Parameters:
source - the action worker containing the action to perform

onActionCancel

public abstract void onActionCancel(ActionWorker<?,?> source)
Hook when a action has been canceled.

Parameters:
source - the action worker containing the action to perform

onActionEnd

public abstract void onActionEnd(ActionWorker<?,?> source)
Hook when a action has end with no failure or cancel.

Parameters:
source - the action worker containing the action to perform

onAfterAction

public abstract void onAfterAction(ActionWorker<?,?> source)
Hook atfer action is consumed.

Parameters:
source - the action worker containing the action to perform

addAction

public ActionWorker<?,?> addAction(String actionLabel,
                                   Runnable action)
Add an new action to perform.

Parameters:
actionLabel - the name of the action to perform
action - the action to perform
Returns:
the worker that will launch the action

terminatesAndWaits

public void terminatesAndWaits()
                        throws InterruptedException
Ask 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:
InterruptedException - if something wrong while waiting end of executor

getNbActions

public int getNbActions()

getTasks

public Set<ActionWorker<?,?>> getTasks()

createRunnable

public 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.

This is a great feature to create runnable code with a real context.

Parameters:
methodContainer - the container of the method to invoke
methodName - the name of the method to invoke
arguments - parameters to pass to method to invke.
Returns:
the proxy instance


Copyright © 2008-2012 CodeLutin. All Rights Reserved.