dev@jsr311.java.net

Re: obtaining objects from 3rd party containers

From: Dhanji R. Prasanna <dhanji_at_gmail.com>
Date: Mon, 16 Jul 2007 15:23:42 +1000

Hi Paul

Here's a simple scenario:

@URITemplate("/person/{id}")
public class PersonResource {

    private PersonDao dao; //injected by spring

    @HttpMethod(GET) public Response get(@URIParam("id") String id) { .. }
}

In the above example, the get() method uses PersonDao to fetch a Person
record from the database (presumably). If the PersonResource object were
provided by spring, the dao would be injected based on deployment
configuration.

Fitting it in with jsr311's runtime is potentially tricky. At first blush I
would say when PersonResource is registered by the runtime, it does the
necessary reflection work and upon each request asks for an instance from
spring (or HiveMind, guice, whatever). The scopes, lifecycle and
instantiation of both the PersonResource and its dependencies (PersonDao)
can then be managed by the external container.

For instance, the PersonResource may have some very complex domain-specific
lifecycle ("holiday mode" while a Person is away on holiday for a frivolous
example). All this can be left to the user and the problem domain (and of
course the external IoC container).

This will make for a lightweight and flexible, embeddable jsr311 framework.
Does this give a better picture of what Im talking about?

Dhanji.

On 7/9/07, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
> Hi Dhanji,
>
> I am not that familiar with Spring, could you provide a simple example
> of how Spring could work with a 311 POJO?
>
> Is this similar to you previous email on filters?
>
> Paul.
>
> Dhanji R. Prasanna wrote:
> > Is there some kind of extensible ResourceDispatcher that can be
> > implemented to obtain JaxRs Resources from say, a spring container?
> >
> > I can definitely see this as an important use case (especially for
> > things like transaction management, aop logging, security etc.). Is this
> > something that has been slotted against the spi?
> >
> > Dhanji.
>
> --
> | ? + ? = To question
> ----------------\
> Paul Sandoz
> x38109
> +33-4-76188109
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
>