Guice singleton scope

2010-05-26 Thread Marek Šabo
Hi all,

I wanted to try the @Singleton annotation in guice with sort of data
facade. What concerns me is the scope of the created singleton. Javadoc
says its a singleton per Injector. So if I create configured
InjectorHolder and return Injector in Application's init(), does it mean
there is a singleton for the whole application (thus for all sessions)?

I would prefer per session based singleton, because the facade
construction is not short, I don't want to instantiate it every
time it's injected. Have you ever considered this -- any ideas?

Regards,

-- 
Marek Šabo



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Guice singleton scope

2010-05-26 Thread James Carman
That's not a singleton at all.  That's a session-scoped bean.

On Wed, May 26, 2010 at 12:45 PM, Marek Šabo ms...@buk.cvut.cz wrote:
 Hi all,

 I wanted to try the @Singleton annotation in guice with sort of data
 facade. What concerns me is the scope of the created singleton. Javadoc
 says its a singleton per Injector. So if I create configured
 InjectorHolder and return Injector in Application's init(), does it mean
 there is a singleton for the whole application (thus for all sessions)?

 I would prefer per session based singleton, because the facade
 construction is not short, I don't want to instantiate it every
 time it's injected. Have you ever considered this -- any ideas?

 Regards,

 --
 Marek Šabo



 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Guice singleton scope

2010-05-26 Thread Marek Šabo
Yes, I gather that is correct term for this.
What would be the proper way to implement it? Just put a referrence with
@Inject in the custom WebSession?

Anyway, ad my first question, I suppose then the singleton would be in
the scope of whole application thus needing synchronization.

Regards

On 05/26/2010 06:48 PM, James Carman wrote:
 That's not a singleton at all.  That's a session-scoped bean.

 On Wed, May 26, 2010 at 12:45 PM, Marek Šabo ms...@buk.cvut.cz wrote:
   
 Hi all,

 I wanted to try the @Singleton annotation in guice with sort of data
 facade. What concerns me is the scope of the created singleton. Javadoc
 says its a singleton per Injector. So if I create configured
 InjectorHolder and return Injector in Application's init(), does it mean
 there is a singleton for the whole application (thus for all sessions)?

 I would prefer per session based singleton, because the facade
 construction is not short, I don't want to instantiate it every
 time it's injected. Have you ever considered this -- any ideas?

 Regards,

 --
 Marek Šabo



 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


   


-- 
Marek Šabo
Server Manager
Club SU CVUT Buben
Bubenečská Kolej (421)
XMPP: zeratul...@gmail.com


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Guice singleton scope

2010-05-26 Thread James Carman
On Wed, May 26, 2010 at 1:05 PM, Marek Šabo ms...@buk.cvut.cz wrote:
 Yes, I gather that is correct term for this.
 What would be the proper way to implement it? Just put a referrence with
 @Inject in the custom WebSession?

 Anyway, ad my first question, I suppose then the singleton would be in
 the scope of whole application thus needing synchronization.

There's no problem making your bean @SessionScoped, but that doesn't
necessarily guarantee that you only have one thread going through it
at a time.  Do you need to worry about threading?  What kind of bean
is it?

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org