Hi,

I have an use-case where I need to inject an array of objects to one
of my Java Object but the only thing I know at "configure/@provides"
time the corresponding classes.

So, basically,


public class MyComponent{

   @inject
   public setObjectList(@Named("specialObjects") List<Object>
specialObjects){
      ...
   }

}

In the Guice Module Object, I would like to have something like, but I
am not sure how to ask Guice to create the bean (see the ???? below).


public class MyGuiceModule extends AbstractModule{

    Class[] specialObjectClasses;

    public MyGuiceModule (Class[] specialObjectClasses){
         this.specialObjectClasses = specialObjectClasses;
    }

    protected void configure() {

    }

    @Provides
    @Named("specialObjects")
    public List<Object> getSpecialObjects(){
          List<Object> specialObjects = new ArrayList<Object>();

          for (Class specialObjectClass : specialObjectClasses ){

               //// ??????? how can I ask Guice to create the instance
from the specialObjectClass ??????
               Object specialObject = ??????;

               specialObjects.add(specialObject);

          }
          return specialObjects;

    }
}


Any help appreciated. I have a workaround for now, but it is not very
Guicy.
--~--~---------~--~----~------------~-------~--~----~
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