It turns out my binding was missing a to(Class<?>) statement.
binder.bind(Key.get(OptionsFilter.class,
Names.named("clinicsResource"))).in(Scopes.SINGLETON);
should have read:
binder.bind(Key.get(OptionsFilter.class,
Names.named("clinicsResource"))).to(OptionsFilter.class).in(Scopes.SINGLETON);
Question: shouldn't Guice issue some sort of warning in this case?
Thanks,
Gili
On 24/02/2011 1:06 PM, cowwoc wrote:
Hi,
I'm attempting to instantiate multiple instances of the same servlet
filter, with different filter parameters each time. Here is what I
did:
public class ServletConfiguration extends GuiceServletContextListener
implements Module
@Override
protected Injector getInjector()
{
return Guice.createInjector(new JerseyServletModule()
{
@Override
protected void configureServlets()
{
install(ServletConfiguration.this);
Map<String, String> corsParams =
Maps.newHashMap();
filter("/clinics").through(Key.get(OptionsFilter.class,
Names.named("clinicsResource")),
corsParams);
}
});
}
@Override
public void configure(Binder binder)
{
binder.bind(Key.get(OptionsFilter.class,
Names.named("clinicsResource"))).in(Scopes.SINGLETON);
}
}
I am getting this exception at runtime:
com.google.inject.CreationException: Guice creation errors:
1) No implementation for com.foo.OptionsFilter annotated with
@com.google.inject.name.Named(value=clinicsResource) was bound.
at com.foo.ServletConfiguration.configure(ServletConfiguration.java:
72)
1 error
Any ideas?
Thanks,
Gili
--
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.