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 <tableyourt...@googlemail.com> wrote: > 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. > > How would you do that? I don't like the idea to create a new subclass > just for this config purpose. > > If I am doing: > bind(MaxBoundSet.class).toInstance(new MaxBoundSet<String>(30, > 60).setMaxAge(10 * 60 * 1000)); > > guice (2.0 with warp persist) does not use this instance. Instead it > uses the default constructor to construct a new instance. Or am I > doing a mistake if thats not working? > > Regards, > Peter. > > * > > http://groups.google.com/group/google-guice/browse_thread/thread/21f3b72d9b86422b/a89eefb6ed54b06e?#a89eefb6ed54b06e > > > http://groups.google.com/group/google-guice/browse_thread/thread/f03262830bd68419/b7fdf4e800caf98e?#b7fdf4e800caf98e > > > http://groups.google.com/group/google-guice/browse_thread/thread/ed1b1fb9e963eb51/17a7bf99d49f8a5b?#17a7bf99d49f8a5b > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to google-gu...@googlegroups.com. > To unsubscribe from this group, send email to > google-guice+unsubscr...@googlegroups.com<google-guice%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.