|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.glaivestone.javax.execution.AbstractEvaluableAction
Abstract superclass for evaluable action implementations.
An action is configured with a receiver (the instance or class which supports the code to be executed) and a code element which defines the behavior of the action.
Argument values for evaluating an action can be provided at construction time or at evaluation time. Default message arguments can be configured for the action if the desired values are known at construction time. Actual argument values can be provided dynamically at evaluation time; arguments supplied at invocation time override any default values. In keeping with strict type checking, actions require the correct number and type of arguments to be supplied.
An action is also configured with an ExceptionHandler
which is invoked if an exception occurs when the action is evaluated.
The default exception handling behavior is to propagate the exception
into the client context using an unchecked PropagatedException
.
Use of an unchecked exception is necessary so that evaluable actions
can be used to configure dynamic behavior in contexts which do not
necessarily have suitable declarations for checked exceptions that may occur.
Clients must consider the exception architecture of their application
and define suitable handlers when using evaluable actions. The exception
handler for a specific action can be configured using the
setExceptionHandler
message to install an alternate handler.
The standard exception handler behavior for the application session
can be configured by installing an alternate handler as
AbstractEvaluableAction.DEFAULT_HANDLER
. The latter
mechanism should be used with care, however, since it is a
global setting which controls the default handler configued for
all actions created in the session.
Subclass implementations provide for various flavors of code that is executed when the action is evaluated.
Not clear how useful the exception handler mechanism is w.r.t. allowing clients to configure arbitrary handlers. In practice, we seem to mainly just use the standard propagated exception and be done with it.
We retain the exception handler mechanism, though, despite it being a violation of overgeneralizing the design (YAGNI - You Aren't Going to Need It). It does provide a hook so that an application session could be configured with an standard exception handler which, say, reported evaluation failures to a session logging mechanism for the session.
Field Summary | |
static ExceptionHandler |
CONTINUABLE_HANDLER
An exception handler which blithely ignores problems and continues execution regardless. |
static ExceptionHandler |
DEFAULT_HANDLER
The default exception handler for evaluable actions propagates the underlying cause of an evaluation failure as an unchecked PropagatedException which wraps the original exception. |
static java.lang.Object[] |
EMPTY_ARGS
Arguments array for a no-arg action. |
static java.lang.Class[] |
EMPTY_PARM_TYPES
Parameter types for a no-arg action. |
static ExceptionHandler |
PROPAGATING_HANDLER
An exception handler which propagates the original exception by wrapping it in an unchecked PropagatedException . |
static ExceptionHandler |
TERMINATING_HANDLER
An exception handler which abruptly terminates the session. |
Method Summary | |
java.lang.Object |
evaluate()
Answer the result of evaluating the action |
java.lang.Object |
evaluate(java.lang.Object anArg)
Answer the result of evaluating the receiver with the given argument value. |
abstract java.lang.Object |
evaluate(java.lang.Object[] args)
Answer the result of evaluating the action with the given argument values. |
java.lang.Object |
evaluate(java.lang.Object arg1,
java.lang.Object arg2)
Answer the result of evaluating the action with the given argument values. |
java.lang.Object[] |
getArguments()
Answer the default arguments used for evaluating the action. |
int |
getNumberOfArguments()
Answer the number of arguments required to evaluate the action. |
static java.lang.Throwable |
getOriginalException(java.lang.Throwable anException)
Answer the original cause of an exception. |
java.lang.Object |
getReceiver()
Answer the object which performs the evaluation. |
abstract java.lang.String |
getSelector()
Answer the name of the action. |
void |
setArguments(java.lang.Object[] arguments)
Specify the default arguments used for evaluating the action. |
void |
setExceptionHandler(ExceptionHandler aHandler)
Set the evaluation exception handler for this action. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final ExceptionHandler PROPAGATING_HANDLER
PropagatedException
.
public static final ExceptionHandler TERMINATING_HANDLER
public static final ExceptionHandler CONTINUABLE_HANDLER
public static final java.lang.Class[] EMPTY_PARM_TYPES
public static final java.lang.Object[] EMPTY_ARGS
public static ExceptionHandler DEFAULT_HANDLER
PropagatedException
which wraps the original exception.
Method Detail |
public static java.lang.Throwable getOriginalException(java.lang.Throwable anException)
public java.lang.Object evaluate()
evaluate
in interface EvaluableAction
EvaluableAction.evaluate()
public java.lang.Object evaluate(java.lang.Object anArg)
evaluate
in interface EvaluableAction
EvaluableAction.evaluate(Object)
public java.lang.Object evaluate(java.lang.Object arg1, java.lang.Object arg2)
evaluate
in interface EvaluableAction
EvaluableAction.evaluate(Object, Object)
public abstract java.lang.Object evaluate(java.lang.Object[] args)
evaluate
in interface EvaluableAction
EvaluableAction.evaluate(Object[])
public java.lang.Object[] getArguments()
getArguments
in interface EvaluableAction
EvaluableAction.getArguments()
public int getNumberOfArguments()
public java.lang.Object getReceiver()
getReceiver
in interface EvaluableAction
EvaluableAction.getReceiver()
public abstract java.lang.String getSelector()
getSelector
in interface EvaluableAction
EvaluableAction.getSelector()
public void setArguments(java.lang.Object[] arguments)
setArguments
in interface EvaluableAction
EvaluableAction.setArguments(java.lang.Object[])
public void setExceptionHandler(ExceptionHandler aHandler)
setExceptionHandler
in interface EvaluableAction
EvaluableAction.setExceptionHandler(com.glaivestone.javax.execution.ExceptionHandler)
|
GFL 1.1 API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |