Thank you for the response. There is one thing I am still confused about Guice, is how to bind array of Objects (when you want the Objects themselves to go through the Guice injector).
In my model, the specialObjects do not have to have any interface or base class in common. They just have some of their methods annotated in a special way. I will look at the multibinder, but my feeling is that it won't really fit the model. Right now, I have the setSpecialObjects(..) outside of the GuiceModule (which obviously has some limitation) Jeremy, On Jul 26, 5:58 pm, "Dhanji R. Prasanna" <[email protected]> wrote: > On Mon, Jul 27, 2009 at 10:24 AM, Jeremy Chone <[email protected]>wrote: > > > �...@provides > > �...@named("specialObjects") > > public List<Object> getSpecialObjects(){ > > public List<Object> getSpecialObjects(Injector injector){ > > > > > List<Object> specialObjects = new ArrayList<Object>(); > > > for (Class specialObjectClass : specialObjectClasses ){ > > > //// ??????? how can I ask Guice to create the instance > > from the specialObjectClass ?????? > > Object specialObject = ??????; > > injector.getInstance(specialObjectClass); > > > > > specialObjects.add(specialObject); > > > } > > return specialObjects; > > > } > > Though, I don't recommend this as a common practice. It is always better to > be explicit about what your deps are. In this case I would use multibinder > to contribute deps from various modules that *do* know what each of the > specialObjectClasses are in advance. > > Dhanji. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
