On Sep 1, 1:04 am, "Dhanji R. Prasanna" <[email protected]> wrote:
> On Wed, Sep 1, 2010 at 1:11 AM, Brian R. Jackson
> <[email protected]<brian%[email protected]>
>
> > wrote:
> > I have a guice app running in a JavaEE container and realize I have
> > the need to annotate my classes/providers with a (non-existant)
> > @ApplicationScoped.  Specifically I'm registering ehcache MBeans and
> > need to dispose of them when the application is unloaded from the
> > container, and wanted to use guiceyfruit support of JSR-250 to do
> > that.
>
> > My question, is there a good reason this scope doesn't already exist?
> > Am I missing something silly, like the feature exists in a different
> > form?
>
> Well, it sounds a lot like @Singleton. If you mean is there some broader
> Java EE specific application scope, then no, we do not have an out-of-box
> solution for that =)
>
> Dhanji.


Thanks Dhanji,
After posting this yesterday I came to the realization that @Singleton
is exactly equivalent to what I'm asking about.  I forgot that each
application has their own Injector and that @Singletons aren't shared
at the JVM level, only at the Injector level.

By the way, it was incredibly simple to write the custom scope, which
I had done until I realized it effectively duplicated @Singleton and
Scopes.SINGLETON.  Great job with the excellent documentation of
custom scopes.  I threw out my implementation when I realized it
didn't add any value over Scopes.SINGLETON, which stored objects in
ServletContext.setAttribute() instead of the private volatile field in
the anonymous Provider that Scopes.SINGLETON uses.

Thanks again,
Brian

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to