users@jersey.java.net

Re: [Jersey] Reuse of Spring's Autowired

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Wed, 27 Aug 2008 14:41:51 +0200

On Wed, 2008-08-27 at 09:31 +0200, Paul Sandoz wrote:
> On Aug 27, 2008, at 12:57 AM, Martin Grotzke wrote:
>
> > Hi Paul,
> >
> > On Fri, 2008-08-15 at 08:15 +0200, Paul Sandoz wrote:
> >> Hi Martin,
> >>
> >> [i realize you are on holiday, but i wanted to get my idea down
> >> before i forgot it]
> > (Y) :)
> >
> >>
> >> I wonder if we can reuse the Spring @Autowired annotation:
> >>
> >> org.springframework.beans.factory.annotation.Autowired
> >>
> >> for injection of parameters of constructors and methods.
> > I'm not sure I understand what you have in mind. Can you give an
> > example?
> >
>
> We can supply an implementation of an InjectableProvider that reuses
> the Autowired annotation. That implementation can be equivalent to
> that of our own @Inject annotation. So for Spring 2.5.x users they do
> not require a Jersey specific annotation.
Hmm, I'm somehow confused. Spring 2.5 users already can use the Spring
annotations and don't have to use our @Inject. Spring does the whole job
based on the spring 2.5 annotations. Though, I don't want to depend on
the spring 2.5 annotations but still support spring 2.0.

You might have a look at AutowiredBySpringSingletonResource and
AnnotatedSingletonResource for the current usage of spring 2.5
annotations.

And I'm aware we need some spring example, perhaps I find the time to
create one this week - if no one else comes first :)

>
> I also think we may be able to support better life-cycle integration
> by enabling the SpringServlet to declare the life-cycle choosing
> factory mechanism. Thus when using @Component there may be no need to
> duplicate Jersey life-cycle declarations. I think this may be
> possible by declaring a default life-cycle when a Jersey life-cycle
> annotation is absent, looks at the spring annotations on the class,
> and defers to the appropriate Jersey life-cycle.
Probably my holiday was too long, again I'm not sure if I understand
you ;)

Trying to express what I understood/read: You want that jersey(-spring)
reads the lifecycle from the spring annotations, if no jersey lifecycle
is declared but a resource class is annotated with @Component?
So the ComponentProvider would tell jersey of what scope a component is,
if the Scope is not defined by some jersey annotation?

Cheers,
Martin


>
> Paul.
>
> > Cheers,
> > Martin
> >
> >
> >> i.e. we add
> >> an injectable provider to the spring module. This would make it more
> >> natural for Spring users than using @Inject. And i don't think it
> >> would interfere with the use on fields because Spring will get to
> >> those first (and Jersey will not set the field value if non-null).
> >>
> >> Paul.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net