• Post Reply Bookmark Topic Watch Topic
  • New Topic

Google Guice and factories question  RSS feed

Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm playing with Guice a little, and I am not sure how to sort this out. I have a factory that produces objects based on the creation method parameter, like this:

I want to provide only singletons, meaning TypeA is a single instance and it uses a single instance of FooA inside; the same for FooB and TypeB pair. Then, I inject this factory to any objects that need it using guice @Provides methods in a module.

Now, I don't thing this code is very guicy as I am using all the new statements. How to create factories that take parameters in their create methods?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!