assistedinject and mapbinder example

797 views
Skip to first unread message

Leigh Klotz

unread,
May 4, 2009, 4:30:07 PM5/4/09
to google-guice
Here's my updated version of an example showing how to combine
Mapbinder and Assisted Inject.

http://graflex.org/klotz/2009/05/assisted-mapbinder/assisted-mapbinder.zip

The old code in http://groups.google.com/group/google-guice/browse_thread/thread/b1b86a9976a74b20/def8bf9064a289ca
didn't work in Guice prior to 20090205.

I tried to post it to the old thread, but it's gone readonly.

I don't know if it's possible to make a FactoryProvider for a Factory
which is declared to create an object satisfying an interface, instead
of a concrete class. Also there's one unpleasant generic cast.

Leigh.

Alen Vrecko

unread,
May 4, 2009, 7:40:57 PM5/4/09
to google-guice
This is very similar to this

http://pastie.org/453944

from this thread

http://groups.google.com/group/google-guice/browse_thread/thread/efcdcd851c06ca1d/182ce22e96d9eb90#182ce22e96d9eb90

I've taken the liberty of modifying your example and put it here

http://pastie.org/468210

As generic cast goes it is as good as it gets. At least from what I
can tell.

But you don't need to use the MapBinder here is an example without. It
creates Factories on the fly. I use child injectors maybe this is a
bit questionable. Does it make a difference if you have a 100+ child
injectors?

This is just on the fly haven't given it that much tought. Here is the
code.

http://pastie.org/468219

Maybe some of this can be included in the wiki?

Cheers,
Alen

On May 4, 10:30 pm, Leigh Klotz <Leigh.Kl...@gmail.com> wrote:
> Here's my updated version of an example showing how to combine
> Mapbinder and Assisted Inject.
>
> http://graflex.org/klotz/2009/05/assisted-mapbinder/assisted-mapbinde...
>
> The old code inhttp://groups.google.com/group/google-guice/browse_thread/thread/b1b8...
Reply all
Reply to author
Forward
0 new messages