SourceForge.net Logo

exception handling

boolean value of filters

As stated above, BERSERK uses logic expressions to specify the filter chains. The question is, how does BERSERK translates filter execution to a logical value?

The IFilter execute() method does not return a boolean value. In fact, it does not return any value at all.

As explained in the exception handling page, filters can throw any kind of exception but BERSERK only processes those who, somehow, extends the FilterException class. The others are rethrown to the caller method.

When a filter broker catches an exception two things may happen:

1 - The exception is NOT a FilterException and the evaluation stops immediately with the exception being rethrown to the caller method.

2 - The exception IS a FilterException and the evaluation continues. The filter being evaluated is considered to be returning the FALSE value.

When a filter evaluation ends without throwing an exception, it is considered to be returning the TRUE value.

The chain evaluation is made considering these boolean values.


VERY IMPORTANT:BERSERK does a PAM-like logic evaluation of logic expressions. That means that even when it is predictable that the chain will fail, the remaining filters will still be executed. For example if we have the expression A && B && C and the filter A returns false it is certain that the chain will fail. However, B and C will be executed with all the colateral effects it may have. Please take into account that all the filters transactional actions (as well as service's) will be rolledback.

filter sucess information

 
By the release of BERSERK V1.0 RC3 we've added the possibility to access the exceptions filters throw during their execution on a Invocation Timing basis. The FilterChainFailedException contains an HashMap with as many entries as the invocation timing allowed by BERSERK (at this time, Pre and Post filtering). Each entry contains a List with the exceptions thrown by failed filters.
This way, you can inspect this structure to have full information about what actually failed causing the whole chain to fail. Before this feature being added, developers only knew that the chain failed for some reason.
© 2003, Gonçalo Luiz