Filters are services without endpoint deployed in the Servent. All we have told about services [] and deployment [] is also valid for filers. There are only small differences:
The applicationName in the deployment.props [] file is needed. This will be the way to find an specific filter
Filters do not implement the org.dbe.servent.Adapter interface but org.dbe.servent.filters.ServiceFilter that is basically the same as adapter but it contains one more method named doFilter.
It is not necessary to implement any specific Service interface because only the doFilter method will be called. (Methods will not be parsed as done with DBEServices)
org.dbe.servent.filter.ServiceFilter interface
public interface ServiceFilter {
/**
* Init the filter
*/
public void init(ServiceContext context);
/**
* Destroy the filter,
*/
public void destroy();
/**
* Executes the filter. Some action can be done before and after the Real
* Service execution.
*/
void doFilter(InvokationRequest request, InvokationResponse response,
FilterContext context, ServiceFilterChain chain)
throws ServiceFilterException;
}
Filters are deployed in the Servent and services can specify which filter must be used before call the service code. Filters can execute actions before and after the the service execution to save information, change parameters, abort execution... Notice that if a service specify that one filter must be executed and this filter is not deployed in the Servent, the execution is aborted[1].
A DBEService can specify in its deployment.props file the filter(s) it want to use before and after execution. Unser can specify in a new parameter named filters all the filters to be used. These names must be separated by coma.
When a filter is used by a service, some parameters must be needed. The filters can access to the service paramters (using the init method) but it has also some specific filter parameters. These parameters can be specified in the deployment.props file using the <name_of_the_filter>.<name_of_the_paramter>. Next you can find a deployment.props file where two filters are specified (one of then with some parameters).
# filters filters= one, two # here we can specify paramteres for filter “one” one.name=nombre one.count=8080
In previous example the filter one have two paramters: named and count.
[1] | It is better to abort execution than execute a possible service with an insecure user. It is possible service uses filters to authenticate a user or receive by its services. |