users@jersey.java.net

Re: [Jersey] LW HTTP Server and injectable providers

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 11 Jun 2008 14:08:40 +0200

Bertold Kolics wrote:
> Paul Sandoz wrote:
>> Bertold Kolics wrote:
>>> My case maybe special, because I have a constructor in my injectable
>>> provider that takes some parameters. The simplest way I can find to
>>> setup an LW HTTP Server was something like this (hacked together from
>>> the ContainerFactory and HttpServerFactory classes). Is there a
>>> better way?
>>>
>>
>> We need to create a better way. What if there was a specific resource
>> config property that contains a list of injectable provider instances
>> to add to the web application?
>>
>> I can modify the ContainerFactory to check for this property.
> Sounds good to me as long as there is not much restriction on the
> constructor of the injectable provider.
>

I have managed to improve things and make it more general. Since
instances of InjectableProvider are providers the
WebApplication.addInjectable method was really just a special case of
adding an instance of any provider. So i have removed that method.

In the latest source/build you can achieve what you require as follows:

   ResourceConfig rc = ....
   rc.getProviderInstances().add(new MyInjectableProvider(myParams));

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109