Re: configure Singleton

2010-12-14 Thread Sam Berlin
Use bind(*new TypeLiteralMaxBoundSetString(){*}).[] instead of bind( *MaxBoundSet.class*).[...]. This tells Guice that you want a typed version of the set. The funky syntax is because you're creating a subclass of TypeLiteral so that Java can retain the generics information at runtime,

Re: configure Singleton

2010-12-14 Thread Peter
both suggestions pointed me in the right direction ... thanks for them! Now I'm using: @Inject private ProviderMaxBoundSet lastSearches; // along with bind(MaxBoundSet.class).toInstance(new MaxBoundSetString(30, 60).setMaxAge(10 * 60 * 1000)); the following line won't work! @Inject private

Re: configure Singleton

2010-12-13 Thread jordi
Maybe @Provides will handle this for you? @Provides @Singleton public MaxBoundSet providesMaxBoundSet() { // instantiate the way you need return maxBoundSet; } http://code.google.com/p/google-guice/wiki/ProvidesMethods hth, jordi On Sun, Dec 12, 2010 at 1:02 AM, Peter

configure Singleton

2010-12-11 Thread Peter
Hi, I know this 'singleton' problem was asked a lot of times here* but I would like to know the following specific case which wasn't answered. If I am doing: bind(MaxBoundSet.class).in(Singleton.class); all is fine except that I need to configure the MaxBoundSet singleton before instantiation.