users@jersey.java.net

Re: Guice provider

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 20 Nov 2007 11:47:26 +0100

Christian wrote:
> Hi,
>
> thanx for the comments. Being able to define a default ressource factory
> and true MVC coming are both good news.
> I've experienced with both freemarker and velocity, I prefer velocity
> syntax, that's just taste. And I've switched all projects to freemarker
> for the native xml support, and better performance. However I'm pretty
> sure when you get a solid fundation for integrating one the other one
> will follow almost for free.
>

Right. I am leaning towards concentrating on Freemarker given what i
have read.


> Concerning groovy, with both support for class annotations and method
> annotation, plus the groovy bytecode compiler, stop me if I'm wrong but
> services written in groovy should work out of the box ?

Yes, see here:

http://blogs.sun.com/sandoz/entry/annotated_scala_groovy_jruby_rhino
http://blogs.sun.com/sandoz/entry/resourcegroovy


> What a specific integration could bring leveraging meta programming
> would be instant reload. (no groovyc compiler), and not explicitely
> inject. Since I love groovy I may want to try some work there, I'll let
> you know if I reach something interesting.
>

Great. It would be really interesting to have a mode whereby one could
check if a groovy resource was modified and dynamically reload it. Very
useful for rapid prototyping, especially for dynamic languages.


> However about returning a closure type, I'm not pretty sure I understand
> what jersey/groovy would do with it then ?
>

One use case is to determine if a resource has been modified or not from
associated etag and last modified information that is compared with the
relevant HTTP request headers.

It would be nice for the application to hand back control to the runtime
to perform the not-modified calculation and then for the runtime to:

   1) return a not modified response; or

   2) hand back control to the application to return a representation.

In Java this is painful to do with anonymous inner classes but it could
be very natural in languages that have good support for closures.

In general this is applicable to variant selection (based on the Accept
header) and 100 continue, and may also apply to comet style support.

At the moment the idea is a bit 'blue sky'. In Jersey there is a way to
plug-in processing of Java methods that are HTTP methods, so i think it
is possible to experiment and get some experience. It is a bit raw and
requires some tidying up but if interested follow the usage of the
interfaces:

   com.sun.ws.rest.
       impl.model.method.dispatch.ResourceMethodDispatchProvider
       spi.dispatch.RequestDispatcher

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109