--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
Yeah, that's what I was missing. This should do exactly what I need
but I can't get it to work yet. It compiles but at runtime it fails.
I find the documentation on this feature too sparse. Instead of
giving one full example they jump between two separate partial
examples.
In particular the docs don't make clear which module it is referring
to. In my case the class to be dynamically created has no non-
assisted parameters. I.e. the constructor of that class has 5
parameters and they all have the @Assisted annotation.
So then question 1 is...should this class have the @Inject annotation
or the @AssistededInject annotation?
The docs aren't real clear on
this, I think the later is needed only if I have overloaded
constructors which I do not. Question 2 is...do I even need a module
for this class? Since it has no injected parameters it seems it has
nothing to do.
Now for the class(s) that need to inject the factory interface I
assume these are the modules that need this:
install(new FactoryModuleBuilder()
.implement(IMyClass.class, MyClass.class)
.build(IMyClassFactory.class));
And this would be positioned in the module to line up with the
IMyClassFactory injected parameter (which in my case is after the bind
methods).
However at runtime I get this error:
com.google.inject.CreationException: Guice creation errors:
1) A binding to com.app.MyParam annotated with
@com.google.inject.assistedinject.Assisted(value=) was already
configured at com.app.IMyClassFactory.create().
at com.app.IMyClassFactory.create(IMyClassFactory.java:1)
at
com.google.inject.assistedinject.FactoryProvider2.initialize(FactoryProvider2.java:
539)
at com.google.inject.assistedinject.FactoryModuleBuilder
$1.configure(FactoryModuleBuilder.java:335)
Where MyParam is one of the 5 parameters in the IMyClassFactory create
method (i.e. MyClass constructor).
Any idea what is wrong? Is there a full example of this someplace?
If you want to test the injection, refer to the other replys.
Jan