I might be misunderstanding the intent here, but would this FAQ solve
the problem?

http://code.google.com/p/google-guice/wiki/FrequentlyAskedQuestions#How_do_I_build_two_similar_but_slightly_different_trees_of_objec

The way I read it, replace bind(Foot.class).toInstance(new
Foot("leftie")); with bind(B.class).to(B1.class); and you have a solution. 

It makes the module setup slightly complex, but makes things really
simple for the user.

On 07/15/2011 12:10 PM, Sam Berlin wrote:
> Yah, exposing the factory definitely adds complexity for the user.
>  You can hide the complexity by continuing to use the @Provides
> methods and using the factory within those.  That leaves the
> complexity just within your code and it never leaks to the user.
>
> As far as what AssistedInject gets you... the main benefit is that
> everything lives in Guice-land.  You get better error messages if
> things go wrong, checks for null injections, support for AOP on the
> assisted class, etc..
>
> sam
>
> On Fri, Jul 15, 2011 at 12:57 PM, glenviewjeff <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Sam:
>
>     Thanks for the quick response!  I hadn't yet used AssistedInject,
>     but unless I'm missing something, in this case AssistedInject
>     appears to me to be overkill and substantially /*increases* /the
>     complexity rather than decreasing complexity like I had hoped. 
>
>     As shown in the sample code, I have no other "automatic"
>     injections, and am already manually injecting the necessary
>     parameter as I would in the AssistedInject case.  Is there some
>     benefit to using AssistedInject that I am missing?
>
>     Thanks,
>     Jeff
>
>     -- 
>     You received this message because you are subscribed to the Google
>     Groups "google-guice" group.
>     To view this discussion on the web visit
>     https://groups.google.com/d/msg/google-guice/-/QuZRkxeF9VcJ.
>
>     To post to this group, send email to [email protected]
>     <mailto:[email protected]>.
>     To unsubscribe from this group, send email to
>     [email protected]
>     <mailto:google-guice%[email protected]>.
>     For more options, visit this group at
>     http://groups.google.com/group/google-guice?hl=en.
>
>
> -- 
> 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.

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