dev@jsr311.java.net

Re: obtaining objects from 3rd party containers

From: Heiko Braun <hbraun_at_redhat.com>
Date: Mon, 16 Jul 2007 13:01:00 +0200

IMO this lies beyond the scope of this specification.
Any JSR-311 implementation can always add functionality like
this, but it's highly target container / framework depended.

I.e. an 311 implementation may add capabilities to deal with spring
dependencies:

        @SpringBean
        private PersonDao dao; //injected by spring

While porting this bean to another container will results in no
injection, because the annotation is not regarded at all.

I'd say we better leave it to the vendor implementation.


/Heiko

On Mon, 2007-07-16 at 12:19 +0200, Paul Sandoz wrote:
> Hi Dhanji,
>
> Thanks, this does give a better picture.
>
> I better understand now if some generic mechanism were available to
> 'hook in' life-cycle and injection support of resources this could work
> for SE, EE or Spring profile etc.
>
> Paul.
>
> Dhanji R. Prasanna wrote:
> > 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
> > <mailto: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
> > <mailto:dev-unsubscribe_at_jsr311.dev.java.net>
> > For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
> > <mailto:dev-help_at_jsr311.dev.java.net>
> >
> >
>