Hi guys,
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:
> 1 public class Main {
> 2
> 3 public static void main(String[] args) throws IOException {
> 4
> 5 final String baseUri = "http://localhost:9998/";
> 6 final Map<String, String> initParams = new
> HashMap<String, String>();
> 7
> 8
> initParams.put("com.sun.jersey.config.property.packages",
> 9 "com.sun.jersey.samples.helloworld.resources");
> 10
> 11 System.out.println("Starting grizzly...");
> 12 SelectorThread threadSelector =
> GrizzlyWebContainerFactory.create(
> 13 baseUri, initParams);
> 14 System.out.println(String.format(
> 15 "Jersey app started with WADL available at
> %sapplication.wadl\n” +
> 16 “Try out %shelloworld\nHit enter to stop
> it...", baseUri, baseUri));
> 17 System.in.read();
> 18 threadSelector.stopEndpoint();
> 19 System.exit(0);
> 20 }
> 21 }
Thanks,
Romain
PS. I already tried this without success:
> initParam
> .put
> ("com
> .sun
> .jersey
> .config.property.DefaultResourceComponentProviderFactoryClass",
> "com.sun.jersey.server.impl.resource.SingletonFactory");