users@jersey.java.net

Re: [Jersey] Configuring the singleton strategy when using Grizzly

From: Romain Rouvoy <romain.rouvoy_at_lifl.fr>
Date: Mon, 10 Aug 2009 16:15:12 +0200

On 10 Aug 2009, at 16:04, Paul Sandoz wrote:
> On Aug 10, 2009, at 3:54 PM, Paul Sandoz wrote:
>> On Aug 10, 2009, at 2:42 PM, Romain Rouvoy wrote:
>>> I'd like to know how to configure Jersey to make resource
>>> instances to singleton by default.
>>> In particular, what need to be added to this piece of code to
>>> instantiate resources only once without using the @Singleton
>>> annotation:
>> First you create a class as follows:
>> package foo;
>>
>> public class MyResourceConfig extends PackagesResourceConfig {
>> public class MyResourceConfig() {
>> super("com.sun.jersey.samples.helloworld.resources");
>>
>> getProperties
>> ().put
>> (ResourceConfig
>> .PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS,
>> com.sun.jersey.server.impl.resource.SingletonFactory);
> The above should be:
>
> getProperties
> ().put
> (ResourceConfig
> .PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS,
> com.sun.jersey.server.impl.resource.SingletonFactory.class);

ok, using this custom resource configuration, it works properly.
I will submit an issue related to this bug.

Thanks,
Romain