|
create filter chainsThis page explains how to create a BERSERK filter chain. A filter chain does not have a programmatic object as services and filters do have. It is only an object that allows developers to reutilize and compose filters. chain's configurationThe differences between using OJB and XML storage are explained in
the Tutorials section of this website. Thus, in this page we will use XML
storage and make no reference to how things would be if we were using OJB.
We will also associate this chain with a service. See the "how
to create services" page.
The configuration file should look like this:
<filterChainsDefinitions> <filterChain> <name>FebruaryChecker</name> <expression>IsFebruary</expression> <description>Checks if it is worth to buy flowers for Valentine's.</description> <invocationTiming>1</invocationTiming> <filterClass>IsFebruary</filterClass> </filterChain> </filterChainsDefinitions> This chain is invoked before the service, and
invokes the IsFebruary filter. If you want your filter chain to be invoked before the service (Pre-Filtering) the InvocationTiming property must have the value FilterInvocationTimingType.PRE. The corresponding value to enter in the configuration is "1". If you want your filter chain to be invoked after the service (Post-Filtering) the InvocationTiming property must have the value FilterInvocationTimingType.POST. The corresponding value to enter in the configuration is "2". To ease this configuration we will, in future versions, allow users to directly specify "PRE" and "POST" values on the configuration. Because only one filter is used, we can use the IsFebruary as
filterClass as well.
semantic coherenceIn order to mantain filter chains' semantic coherence, there is a
configuration field "filterClass" that stipulates a hierarchy of filters. That
is, all filters must be assignable to the specified object (in pratice this
means that the filters must implement the class if the class is an interface,
or inherit from it othewise).
This helps avoiding things to get messy. For example, the return
value of a filter that logs accesses and another that checks if it is a rainy
day, should not be processed the same way.
calling the chainA chain is executed when a service that it is associated with is
invoked.
Depending on its invocation timing it may be invoked before the service (Pre-filtering) or after the service (Post-filtering). Remember to change the invocationTiming configuration to tune the invocation timing for your chains. |