Currently it is not possible to enforce that a certain instance be a
singleton across multiple modules in the same JVM. This is most visible in
a J2EE context where you have several instances (maybe of the same module)
which are bound to create multiple injectors, or at least one for each
entry-point; e.g. Web services, struts2, EJB.
When using a pool of resources which is finite for a JVM you may want to
force this finite allocation across multiple modules - for example if there
can only be 25 open handles to some native software. This could be done
with a singleton which manages a pool; however this singleton must
obviously be single for the whole JVM, otherwise more than 25 handles could
be opened.
It would be great if a class could be bound as @TrueSingleton or bound in a
scope which was available to all modules in the JVM (essentially a static
scope). This would allow Guice management of true singletons.
Original issue reported on code.google.com by mpetz...@gmail.com on 14 Jan 2008 at 3:54
Original issue reported on code.google.com by
mpetz...@gmail.com
on 14 Jan 2008 at 3:54