Well I found a workaround.
Basically instead of letting FactoryProvider create an implementation
of SomeClassFactory, I created my own implementation:
class SomeClassFactoryImpl implements SomeClassFactory
{
private SomeService m_service;
@Inject
public SomeClassFactoryImpl(SomeService service)
{
m_service = service;
}
public SomeClass createForKicks(Kicks kicks)
{
return new SomeClass(m_service, kicsk);
}
public SomeClass createForLaughs(Laughs laughs)
{
return new SomeClass(m_service, laughs);
}
}
However, this seems like a backwards step to me. Why shouldn't a class
be able to have multiple constructors that are annotated with @Inject?
I understand that it's not to hard to come up with an example where
Guice wouldn't know which constructor to call, because all required
dependencies of every
parameter for every constructor are available.
But in the case of assisted injection, the factory method basically
dictates which constructor to call.
Does anyone else have any thoughts?