users@jersey.java.net

Re: [Jersey] Reuse of Spring's Autowired

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 27 Aug 2008 09:31:53 +0200

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.

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.

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
>