|
From: Ryan J. M. <ry...@da...> - 2008-07-10 12:30:52
|
I like it! And I see where you're going with it. I think this will
provide a ton of flexibility in the app. I can see a lot of
opportunities for this kind of feature. How far along are with it?
Ryan-
On Jul 9, 2008, at 6:53 PM, Bill Burke wrote:
> I'm currently prototyping some asynchronous jax-rs based on some of
> the
> asynchronous talk in the Restful Web Services book. At first I
> implemented it in a non-abstract fashion. Just brute force as I
> wanted
> to see what patterns came up. After this I realized that I needed
> some
> form of interception to implement it. (Mainly because of security).
>
> So, for interception here's some ideas:
>
> * Interceptors will be internal and not supported. (I want us to
> write
> a few before we even allow users to try them out).
>
> * interception would happen based on what additional annotation you
> provided: @BeforeUnmarshalling, @AfterUnmarshalling,
> @BeforeMarshalling,
> and @Aftermarshalling.
>
> * Interceptors will not be called for any subresource locator methods.
>
> * You would be able to use any JAX-RS annotation within the intercept
> method.
>
> * It is an "around" pattern (like EJB's @AroundInvoke
>
> interface RequestContext
> {
> void invokeNext();
> }
>
> * You must inject and call invokeNext() on a RequestContext or no
> other
> interceptors will be called, and the request will not be dispatched.
>
> * You will be able to inject the ResourceMethod object so you can get
> preprocessed information about the method you are invoking on
> (annotations, etc...)
>
>
> So here's an example:
>
> @Provider
> @Interceptor
> public class CacheControlInterceptor
> {
> @BeforeUnmarshalling(@Context HttpRequest request,
> @Context HttpResponse response,
> @Context RequestContext ctx)
> {
> if (isCached(request)) {
> writeCachedResponse(request, response);
> return; // don't continue with dispatching
> }
> return invokeNext();
> }
>
>
> @BeforeMarshalling
> public void writeCacheControlHeaders(@Context HttpResponse response
> @Context RequestContext ctx)
> {
> ... write some cache control headers...
> }
>
> @AfterMarshalling
> public void grabBytesToMarshall(@Context HttpResponse response
> @Context RequestContext) {
> }
> }
>
>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Resteasy-developers mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
|