users@jersey.java.net

Re: [Jersey] Simplifying Jersey life-cycle and IoC integration

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Sat, 22 Nov 2008 10:47:00 -0800 (PST)

I know nothing of Spring so can you please explain what
getInjectableInstance() is meant to do? It has no Javadoc. Looking at the
Spring code it looks like it takes an already-constructed instance and if
it's a proxy returns the real object. I'm not even sure where this method
gets the object from. Is it from ComponentProvider.getInstance()?

Thanks,
Gili


Paul Sandoz wrote:
>
>
> On Nov 21, 2008, at 8:49 PM, Gili wrote:
>
>>
>>
>> Paul Sandoz wrote:
>>>
>>> IoCInstantiatedComponentProvider should be used when the IoC
>>> component
>>> provider instantiates but Jersey manages in terms of life-cycle and
>>> should be annotated with Jersey life-cycle annotations.
>>>
>>
>> I'm not clear on how that could happen. Can you provide a code
>> sniplet that
>> demonstrates this?
>>
>
> See the com.sun.jersey.spi.spring.container.SpringComponentProvider
> (and the snippets of code at end of email).
>
> It is used for Spring 2.0.x when there is no annotation-based
> autowiring capability and we can emulate that with a Jersey specific
> annotation.
>
> I suspect that for most cases IoCInstantiatedComponentProvider is
> unlikely to be used and the managed provider is of most interest.
>
> Paul.
>
> final Autowire autowire =
> (Autowire)c.getAnnotation(Autowire.class);
> if (autowire != null) {
> if (LOGGER.isLoggable(Level.FINEST)) {
> LOGGER.finest("Creating resource class " +
> c.getSimpleName() +
> " annotated with @" +
> Autowire.class.getSimpleName() +
> " as spring bean.");
> }
> return new SpringInstantiatedComponentProvider(c,
> autowire);
> }
>
>
> private class SpringInstantiatedComponentProvider implements
> IoCInstantiatedComponentProvider {
> private final Class c;
> private final Autowire a;
>
> SpringInstantiatedComponentProvider(Class c, Autowire a) {
> this.c = c;
> this.a = a;
> }
>
> public Object getInstance() {
> return springContext.getBeanFactory().createBean(c,
> a.mode().getSpringCode(), a.dependencyCheck());
> }
>
> public Object getInjectableInstance(Object o) {
> return
> SpringComponentProviderFactory.getInjectableInstance(o);
> }
> }
>
>
>> Gili
>> --
>> View this message in context:
>> http://n2.nabble.com/Simplifying-Jersey-life-cycle-and-IoC-integration-tp1367641p1563239.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>

-- 
View this message in context: http://n2.nabble.com/Simplifying-Jersey-life-cycle-and-IoC-integration-tp1367641p1566158.html
Sent from the Jersey mailing list archive at Nabble.com.