I try this, but... this is a "jersey" feature.
Any "jax-rs" (annotated) alternative?
Future jax-rs 2.0 include this filters?
Thank you
On 04/08/2011 16:51, Pavel Bucek wrote:
> Hello,
>
> you can define ContainerRequest/Response filter - it should do exactly
> what you need; see
>
> http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/container/ContainerRequestFilter.html
>
> http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/container/ContainerResponseFilter.html
>
>
> you might want to look at LoggingFilter as sample for your own one:
>
> http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
>
> (source:
> http://java.net/projects/jersey/sources/svn/content/trunk/jersey/jersey-server/src/main/java/com/sun/jersey/api/container/filter/LoggingFilter.java?rev=5224)
>
> Regards,
> Pavel
>
> On 8/4/11 12:28 PM, Jose Antonio Illescas Del Olmo wrote:
>> Can I define custom handlers?
>>
>>
>> example:
>>
>> public class MyInvocationHandler {
>>
>> public Response process(Annotation[] annotations, MediaType
>> mediaType, InvocationContex context) {
>>
>> // put your pre-process here: logs, security,
>> transactions...
>>
>> context.invoke(); // this method calls to my found
>> REST service method
>>
>> // put your post-process here: redirect/forwards,
>> Reponse modifications...
>> }
>>
>> and defining my hadler on my REST service (or use a META-INF/services
>> file to configure)
>>
>> @Path("hello")
>> public class HelloWorld {
>>
>> @GET
>> @Produces("text/xml")
>> @Handle(MyInvocationHandler)
>> public String sayHello() {
>> return "<message>Hello world</message>";
>> }
>>
>>
>
>