Interesting, but how you get the injection inside the module?
On Jul 26, 11:20 pm, Andreas Petersson <[email protected]> wrote:
> i would do this the following way:
> 1) instead of @Provides use a Provider<List<Object>> bound to
> @Named("specialobjects")
> 2) when setting up the provider inside the module inject the injector
> into the provider.
> 3) use the injector to create instances of your specific classes simply
> with inj.getInstance(Class<T>);
> 4)???
> 5) profit
>
> thats how i did it.
>
> what may be not obvious is that you can happily inject into providers
> even if you fire them up with "new Provider<>"
> br
> andreas
>
>
>
> > @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;
>
> > }
> > }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---