The reason is pretty simple: it doesn't make any sense otherwise.

AssistedInject is for when your code needs to inject something that needs
some "guice managed" objects and some "user managed" objects.  If I have a
class Foo that looks like:

  Foo { @Inject Foo(Manager manager, @Assisted String name) { } }

how is it supposed to be injected?  If my method is "@Inject setFoo(Foo foo)
{}", what would the value for 'name' be?  Similarly, if I inject "@Inject
setFoo(Provider<Foo> pFoo) { pFoo.get(); }", when I call get on the
Provider, what would the value of 'name' be?

AssistedInject requires a factory for creating Foo:

   FooFactory { Foo create(String name); }

So that places that need a Foo inject the FooFactory and call the create
method, so that 'name' can have a value.

Sam

On Thu, Jul 2, 2009 at 1:25 PM, gabe97330 <[email protected]> wrote:

>
> Is it an explicit design decision that a Provider cannot be created
> using Assisted Inject? If so, is it based on technical or policy
> driven considerations?
>
> If not, is there an example someone could provide for how to make it
> work? My various attempts fail with the error message indicating that
> Guice is not finding an implementation for the assisted constructor
> parameter(s), i.e. something like the following (edited):
>
> No implementation for java.lang.Integer annotated with
> @com.google.inject.assistedinject.Assisted(value=) was bound.  while
> locating java.lang.Integer annotated with
> @com.google.inject.assistedinject.Assisted(value=)
>    for parameter 0 at ProviderOfA.<init>(at ....configure)
>
> Thanks,
>
> Gabe
> >
>

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