com.jbbres.lib.actions.tools.elements.variables
Class VariableActionService

java.lang.Object
  extended by com.jbbres.lib.actions.tools.elements.variables.VariableActionService
All Implemented Interfaces:
ActionService, ElementService

public class VariableActionService
extends java.lang.Object
implements ActionService

The ActionService for VariableAction.

Since:
1.0.0
Version:
1.0.0
Author:
Jean-Baptiste Bres

Constructor Summary
VariableActionService(VariableAction parent)
          Instantiates a new variable action model.
 
Method Summary
 void addExecutionListener(ActionExecutionListener l)
          Adds a listener to the execution.
 void addServiceListener(VariableActionServiceListener l)
          Adds a model listener.
 java.lang.Object execute(java.lang.Object input, Parameters parameters)
          Executes the action.
 void fireActionExecutionEnd(int status, java.lang.Object input, Parameters parameters, java.lang.Object result)
          Calls the actionExecutionEnds() method of all the action listeners.
 void fireActionExecutionEnd(int status, java.lang.Object input, Parameters parameters, java.lang.Object result, java.lang.Throwable exception)
          Calls the actionExecutionEnds() method of all the action listeners.
 void fireActionExecutionStart(java.lang.Object input, Parameters parameters)
          Calls the actionExecutionStarts() method of all the action listeners.
 void fireAssignValueChange()
          Calls the assignValueChange method of all the model listeners.
 void fireVariableChange()
          Calls the variableChange method of all the model listeners.
 Variable getVariable()
          Returns the variable.
 boolean isAssignValue()
          Returns true if the assign value functionality is on.
 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.
 void removeServiceListener(VariableActionServiceListener l)
          Removes a execution listener.
 void setAssignValue(boolean assignValue)
          Sets if the assign value functionality is on.
 void setVariable(Variable variable)
          Sets the variable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableActionService

public VariableActionService(VariableAction parent)
Instantiates a new variable action model.

Parameters:
parent - - the parent action
Method Detail

execute

public final java.lang.Object execute(java.lang.Object input,
                                      Parameters parameters)
                               throws ActionExecutionException
Description copied from interface: ActionService
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 ActionService.outputClass(Class) method is Void), it returns a null object.

Specified by:
execute in interface ActionService
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

setVariable

public void setVariable(Variable variable)
Sets the variable.

Parameters:
variable - the new variable

getVariable

public Variable getVariable()
Returns the variable.

Returns:
the variable

setAssignValue

public void setAssignValue(boolean assignValue)
Sets if the assign value functionality is on.

Parameters:
assignValue - the assignValue to set

isAssignValue

public boolean isAssignValue()
Returns true if the assign value functionality is on.

Returns:
true if the assign value functionality is on. false otherwise.

outputClass

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

Specified by:
outputClass in interface ActionService
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:
ActionService.isValidInputClass(Class)

isValidInputClass

public boolean isValidInputClass(java.lang.Class<? extends java.lang.Object> clazz)
Description copied from interface: ActionService
Returns true if an instance of the given class is an acceptable input.

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

addExecutionListener

public void addExecutionListener(ActionExecutionListener l)
Description copied from interface: ActionService
Adds a listener to the execution.

Specified by:
addExecutionListener in interface ActionService
Parameters:
l - - new listener.
See Also:
ActionService.removeExecutionListener(ActionExecutionListener)

removeExecutionListener

public void removeExecutionListener(ActionExecutionListener l)
Description copied from interface: ActionService
Removes a listener to the execution.

Specified by:
removeExecutionListener in interface ActionService
Parameters:
l - - listener to remove
See Also:
ActionService.addExecutionListener(ActionExecutionListener)

addServiceListener

public void addServiceListener(VariableActionServiceListener l)
Adds a model listener.

Parameters:
l - - the listener

removeServiceListener

public void removeServiceListener(VariableActionServiceListener l)
Removes a execution listener.

Parameters:
l - - the listener

fireAssignValueChange

public void fireAssignValueChange()
Calls the assignValueChange method of all the model listeners.


fireVariableChange

public void fireVariableChange()
Calls the variableChange method of all the model listeners.


fireActionExecutionStart

public void fireActionExecutionStart(java.lang.Object input,
                                     Parameters parameters)
                              throws ActionExecutionException
Calls the actionExecutionStarts() method of all the action listeners.

Parameters:
input - the input
parameters - the parameters
Throws:
ActionExecutionException - the action exception

fireActionExecutionEnd

public void fireActionExecutionEnd(int status,
                                   java.lang.Object input,
                                   Parameters parameters,
                                   java.lang.Object result)
                            throws ActionExecutionException
Calls the actionExecutionEnds() method of all the action listeners.

Parameters:
status - - the status of the action (SUCCEED or FAILED)
input - - the input object
parameters - - the parameters
result - - the result object
Throws:
ActionExecutionException - the action exception

fireActionExecutionEnd

public void fireActionExecutionEnd(int status,
                                   java.lang.Object input,
                                   Parameters parameters,
                                   java.lang.Object result,
                                   java.lang.Throwable exception)
                            throws ActionExecutionException
Calls the actionExecutionEnds() method of all the action listeners.

Parameters:
status - - the status of the action (SUCCEED or FAILED)
input - - the input object
parameters - - the parameters
result - - the result object
exception - - the exception that occurs during the execution
Throws:
ActionExecutionException - the action exception


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.