users@jersey.java.net

Re: [Jersey] Interceptors

From: Arul Dhesiaseelan <arul_at_fluxcorp.com>
Date: Sat, 14 Mar 2009 22:31:41 -0600

Nice.

Jersey makes life restful :)

-Arul

----- Original Message -----
From: Erdinc Yilmazel
[mailto:erdinc_at_yilmazel.com]
To: users_at_jersey.dev.java.net
Sent: Sat, 14 Mar
2009 20:52:55 -0600
Subject: Re: [Jersey] Interceptors


> Thanks Arul! This is really what I was looking for. I already wrote my
> own @LoginRequired annotation that triggers a resource filter. I am
> really in love with the flexibility that Jersey provides.
>
> On Sat, Mar 14, 2009 at 4:08 PM, Arul Dhesiaseelan <arul_at_fluxcorp.com>
> wrote:
> > Did you look at the client/server Filters in Jersey[1, 2]? I would say it
> is very similar to interceptors. You could implement your own filters, but
> Jersey already provides some useful filters such as Logging,
> GZIPContentEncoding, PostReplace(Server only), HTTPBasicAuthFilter (Client
> only, in 1.0.3 snapshot).
> >
> > -Arul
> >
> > [1]
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/com/sun/jersey/api/client/filter/package-summary.html
> >
> > [2]
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/index.html
> >
> > ----- Original Message -----
> > From: Erdinc Yilmazel
> > [mailto:erdinc_at_yilmazel.com]
> > To: users_at_jersey.dev.java.net
> > Sent: Fri, 13 Mar
> > 2009 21:17:14 -0600
> > Subject: [Jersey] Interceptors
> >
> >
> >> Hi everybody,
> >>
> >> I was wondering if adding interceptors for resource classes are
> >> possible Jersey. What I mean is a class that will be called before a
> >> method annotated with @GET or @POST etc. is called. For instance see
> >> the following code:
> >>
> >> class AuthenticationInterceptor implements JerseyInterceptor {
> >>    public void intercept(@CookieParam cookies) {
> >>        ... authentication logic
> >>        if(!loggedIn) {
> >>           throw new WebApplicationException(403);
> >>        }
> >>    }
> >> }
> >>
> >> And on the resource method:
> >>
> >> @GET
> >> @Intercept(AuthenticationInterceptor.class)
> >> public Response something() {
> >>    ...
> >> }
> >>
> >> Well the actual API may be much different but I think you get the
> >> point. If the interceptor does not throw any exceptions the resource
> >> method gets called. Or may be interceptor chains can be implemented
> >> like a servlet filter like API.
> >>
> >> How can I hack jersey to add such functionality? Or is there already
> >> any similar feature in Jersey or JAX-RS?
> >>
> >> Thanks,
> >> Erdinc
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>