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