For some reason, this isn't working for me:
public class MyModule<T> extends PrivateModule {
private final Key<T> key;
@Override
protected void configure() {
bindConstant().annotatedWith(key.getAnnotation()).to("42");
requireBindings(key);
expose(key);
}
}
Now, if I create an injector with a MyModule<String>, things appear to be
fine. However, if I create an injector with a MyModule<Integer>, I get a
creation error on the expose(), saying that it could not expose Integer
with key.getAnnotation(). If I'm not mistaken, requireBindings() above
seems to indicate that it is bound.
Why does this happen, and how should I resolve this? (I plan on replacing
"42" with, say, System.getProperties("foobar").)
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/89663f49-c0b6-4036-ab5a-5bc5e3cec494%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.