Hi,
I am trying to use AssistedInject to bind in Guice modules results
from that factory, since i don't want (and i shouldn't have to for
testing purposes) have my implementations depending on the factory.
I am wondering why the following code does not work. I get:
1) A binding to AssistedTest$FileScanner was already configured at
AssistedTest$1.libScanner().
at AssistedTest$FileScannerFactory.create(AssistedTest.java:1)
at com.google.inject.assistedinject.FactoryProvider2.initialize
(FactoryProvider2.java:161)
at AssistedTest$1.configure(AssistedTest.java:19)
Thank you for your help !
final class AssistedTest {
public static void main(String... args) {
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(FileScannerFactory.class).toProvider
(FactoryProvider.newFactory(FileScannerFactory.class,
AntFileScanner.class));
}
@Provides
FileScanner libScanner(FileScannerFactory factory) {
return factory.create("**/*.jar");
}
});
}
static interface FileScannerFactory {
FileScanner create(@Assisted("pattern") String pattern);
}
static interface FileScanner {
List<File> scan();
}
static class AntFileScanner implements FileScanner {
@Inject
AntFileScanner(@Assisted("pattern") String pattern) {
}
@Override
public List<File> scan() {
return null;
}
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---