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
-~----------~----~----~----~------~----~------~--~---

Reply via email to