users@jersey.java.net

Re: [Jersey] Right way to create embedded grizzly with already instantiated Application?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 10 Nov 2008 09:37:39 +0100

On Nov 9, 2008, at 2:23 AM, American Jeff Bowden wrote:
>
>>
>>
>>> return GrizzlyServerFactory.create(u, new
>>> GrizzlyContainer(wa));
>>>
>>> }
>>>
>>> So perhaps you could add
>>>
>>> GrizzlyServerFactory.create(URI u, ResourceConfig rc,
>>> ComponentProvider cp);
>>>
>>
>> Will do.
>>
>> BTW the component provider interface has changed in 1.0.1-SNAPSHOT.
>> See here [1] for its use with Spring. It should be simpler to use,
>> and
>> Jersey does not get in the way as it did before in terms of IoC
>> life-cycle.
>>
>> I would be interested to know what you think and if it supports your
>> requirements.
>>
>> I have tried to capture all the existing requirements that developers
>> were using the old interface for:
>>
>> - Deferring to IoC frameworks like Spring/Guice;
>>
>> - Instantiated but Jersey managed; and
>>
>> - Proxied but Jersey instantiated and managed.
>>
>> I plan to JavaDoc it before the 1.0.1 release.
>
> My requirements are to inject a data access interface into my web
> resource classes in such a way that I can inject mock objects during
> unit tests and objects connected to the database during normal
> operation. Both of these require that my code can control the
> construction and configuration of the objects to be injected using
> information known locally to the test or the service class.
>

So that would fit in with the first point. For 1.0.1 your IoC
component provider factory needs to return back an instance of:

   com.sun.jersey.core.spi.component.ioc.IoCManagedComponentProvider

Paul.