com.jbbres.lib.actions.elements
Interface ActionService

All Superinterfaces:
ElementService
All Known Implementing Classes:
AbstractActionService, SimpleAction, VariableActionService

public interface ActionService
extends ElementService

The service provided by an action.

The service is a major part of an action as it defined its behavior within a workflow. It describes how the element performs during the workflow execution. For an action, the service describes:

Since:
1.0.0
Version:
1.0.0
Author:
Jean-Baptiste Bres
See Also:
Action.getService()

Method Summary
 void addExecutionListener(ActionExecutionListener l)
          Adds a listener to the execution.
 java.lang.Object execute(java.lang.Object input, Parameters parameters)
          Executes the action.
 boolean isValidInputClass(java.lang.Class<? extends java.lang.Object> clazz)
          Returns true if an instance of the given class is an acceptable input.
 java.lang.Class<? extends java.lang.Object> outputClass(java.lang.Class<? extends java.lang.Object> inputClazz)
          Returns the class of the object returned by the execute method, depending on the class of the object received as an input.
 void removeExecutionListener(ActionExecutionListener l)
          Removes a listener to the execution.
 

Method Detail

execute

java.lang.Object execute(java.lang.Object input,
                         Parameters parameters)
                         throws ActionExecutionException
Executes the action. This method is called during the workflow execution.

The method receives as an input the result of the previous action in the workflow, casted in the input type of the action. As it might appends that the action is the first one of the workflow, or that the previous one did not generate an output compatible with the expected input of this one, the value received as a parameter might be null. The method should handle this case in order to avoid workflow execution errors.

This method returns the result of the execution, which will be used as input of the next action. Action(s) considers that the execution of the action is successful if no exception is raised during its execution. If the result of this function is null, it will be considered as successful and the workflow will continue its execution.

An ActionExecutionException means that the action failed during its execution. Such an exception (and any other exception) will result in ending the workflow execution.

If the action is not supposed to return any output (result of the outputClass(Class) method is Void), it returns a null object.

Parameters:
input - - the result of the previous action
parameters - - the settings related to this action, to apply for this execution.
Returns:
the output to be used as input of the next action
Throws:
ActionExecutionException - - if the execution failed

outputClass

java.lang.Class<? extends java.lang.Object> outputClass(java.lang.Class<? extends java.lang.Object> inputClazz)
Returns the class of the object returned by the execute method, depending on the class of the object received as an input.

Parameters:
inputClazz - - the class of the object that will be received as an input
Returns:
the class of the object returned by the execute method
See Also:
isValidInputClass(Class)

isValidInputClass

boolean isValidInputClass(java.lang.Class<? extends java.lang.Object> clazz)
Returns true if an instance of the given class is an acceptable input.

Parameters:
clazz - - the tentative class
Returns:
true if an instance of the given class is an acceptable input. false otherwise.
See Also:
outputClass(Class)

addExecutionListener

void addExecutionListener(ActionExecutionListener l)
Adds a listener to the execution.

Parameters:
l - - new listener.
See Also:
removeExecutionListener(ActionExecutionListener)

removeExecutionListener

void removeExecutionListener(ActionExecutionListener l)
Removes a listener to the execution.

Parameters:
l - - listener to remove
See Also:
addExecutionListener(ActionExecutionListener)


To file bugs or suggest feature enhancements, visit the app.jbbres.com Bug Reporter website.

Additional documentation available online at http://app.jbbres.com/actions/developers.

Copyright � 2009-2011 app.jbbres.com. All Rights Reserved.