Re: obtaining objects from 3rd party containers

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

Hi Paul

Here's a simple scenario:

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

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?


On 7/9/07, Paul Sandoz <> 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:
> For additional commands, e-mail: