users@hk2.java.net

Default scopes for _at_Service annotated services

From: Dave Trombley <dave.trombley_at_gmail.com>
Date: Sat, 7 Jun 2014 00:33:02 -0400

    I'm trying to dynamically bind some services that will be used from
(dynamically generated) resources in a jersey application container.
These services are annotated @Service, but when I try to bind them into the
appropriate scope (org.glassfish.jersey.process.internal.RequestScoped),
the reify process complains that the default annotations on the class
(@Singleton, rather than @PerLookup, for some reason?) does not match the
value passed in the descriptor I tried to bind.

    I want to override the default value in the class, somehow. This is
because I'm locating these things manually from a JAR and loading them in,
and I do not want to require the developer to create a separate version
that just adds @RequestScoped to every service. It should just be a
@Service - my container will "know" how to bind it to scope and determine
the correct value...

    Is this possible to do? How is that default determined? Are @Service
defaulted @Singleton and that is just the way it is, and final? I could
write my own @some.other.package.Service, but that's real ugly, and still
requires code changes...

   Thanks again,
  -David