Hi,

As per the discussions in the "[Dev] [C5] MSF4J Interceptors need to be
configurable" email thread, we have started working on the MSF4J filters.

Mentioned below is a brief explanation of how things will look like
according to what we have planned so far.

*Ability to filter request / response messages *

We will be adapting JAX-RS defined interfaces (ContainerRequestFilter,
ContainerResponseFilter) for request and response filtering. For handling
the request and the response we are hoping to use JAX-RS defined interfaces
(ContainerRequestContext and ContainerResponseContext)

*Ability to apply/skip filters in global and pre-service levels*

Filters could be applied globally, resource or sub-resource vice which
implies that when a sub-resource is executed filters applied to the
sub-resource, resource and filters applied globally should execute
according to the relevant priority (Union set of filters).

However, we are not adopting the Annotation driven NameBinding concept
defined for JAX-RS Filters but would be adopting a similar concept to
reduce the developer effort in writing annotations to the filters. Using
this approach we would still be using annotations to define filters in
resource and sub-resource levels.

Ex:- Applying filters in the resource and sub-resource levels can be done
by using the below-mentioned annotations


@FilterRequest(filterclass=MyClass.class, priority=1000)
@FilterRequest(filterclass=MyClass2.class, priority=2000)
@FilterRequest(filterclass=MyClass3.class)
// Some method or class

@FilterResponse(filterclass=MyClass4.class, priority=1000)
@FilterResponse(filterclass=MyClass5.class, priority=2000)
@FilterResponse(filterclass=MyClass6.class)
// Some method or class


By default, filters will be applied globally.

*The order of the filters*

Priorities for the JAXRSInInterceptors are in ascending order while
priorities for the JAXRSOutInterceptors are in descending order. This will
feature in proper execution when both ContainerRequestFilter and
ContainerResponseFilter
interfaces are implemented.

Filters which do not have a priority specified will have a default priority
[1].

*How to register filters globally, to a resource or a sub-resource*

   - Using annotations as mentioned above
   - In fat jar mode, filters can be registered using
   addFilter(<filtername>, <priority>) method
   - In OSGI mode, filters can be registered in the same way interceptors
   are registered now

[1]
https://dennis-xlc.gitbooks.io/restful-java-with-jax-rs-2-0-2rd-edition/content/en/part1/chapter12/ordering_filters_and_interceptors.html


Best Regards,

*Vidura Nanayakkara*
Software Engineer

Email : [email protected]
Mobile : +94 (0) 717 919277
Web : http://wso2.com
Blog : https://medium.com/@viduran <http://wso2.com/>
Twitter : http://twitter.com/viduranana
LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara <http://wso2.com/>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to