|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IlrExceptionHandler
An exception handler manages the way an execution context processes
the exceptions thrown during the execution of rules. Only instances
of IlrUserRuntimeException
are subject to processing by
an exception handler. Those exceptions are thrown by the user's
code executed from the rule engine, such as constructors, methods,
field accesses, and so on.
At its creation, a context does not have any exception handler. When
an exception is thrown in the user's code, the rule engine catches it
and an instance of IlrUserRuntimeException
is constructed with
the former exception as its target, then the IlrUserRuntimeException
is thrown.
When an exception handler has been set for an execution context, the
constructed IlrUserRuntimeException
is not thrown. Instead,
it is processed by the exception handler.
If the exception occurs
during the evaluation of rule condition, then the result of
the processing is the result of the evaluation. For example, if the
processing returns false
, then the tests are considered
as false
. If the exception occurs within an action,
then the result of the processing is ignored. The remainder of the
action part of the rule which caused the exception is never executed.
If its occurs within a ruleflow, then the result of the processing is ignored.
The remainder of the ruleflow is not executed.
It is possible to differentiate the way exceptions are processed according to their origin (condition or action part). In particular, the processing can choose to throw the exception itself or another exception.
The following example considers the tests as false
if
their evaluation throws exceptions, but does not process exceptions
in the action part of rules:
context.setExceptionHandler(new IlrExceptionHandler() { public boolean handleException(IlrUserRuntimeException ex) { if (ex.isInConditions()) return false; else throw ex; } });
Note: As IlrContext
is serializable, an exception handler
is also serializable. It is the user's responsibility to ensure
that the exception handler object supports Java serialization.
Method Summary | |
---|---|
boolean |
handleException(IlrUserRuntimeException ex)
Processes an exception and returns a Boolean value as a result. |
Method Detail |
---|
boolean handleException(IlrUserRuntimeException ex)
Processes an exception and returns a Boolean value as a result. The value is used as the test evaluation if the exception has occurred in a rule condition part. Otherwise, it is ignored.
ex
- An IlrUserRuntimeException
.
|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |