I have followed Michal's guide from his answer to this question [1] on implementing custom annotation for injecting arbitrary things into resource methods. This (gist) [2] contains a minimalistic testbed adapted from the jersey-quickstart-grizzly2
archetype. I will refer to it in the following text.
I encountered a few problems:
My resolver is parametrized type (or at least it would make things much more cleaner, in my opinion) and thus I can not
bind
it in my binder the way Michal suggests.// Instead of the suggested: // bind(MyInjectionResolver.class).to(new TypeLiteral<InjectionResolver<MyAnnotation>>() {}).in(Singleton.class); // I do: bind(myInjectionResolverObject).to(new TypeLiteral<InjectionResolver<MyAnnotation>>() {});
When I use
MyAnnotation
in the resource method, I get the following warning on server start-up (but the server still starts):WARNING: The following warnings have been detected: WARNING: A HTTP GET method, public java.lang.String com.example.MyResource.get02(java.lang.Integer,java.lang.String), should not consume any entity.
When I request the resource (
curl -X GET http://localhost:8080/myresource/01/aa
), I get02: value = aa; providedValue = null
instead of the expected02: value = aa; providedValue = 123
.The
MyResolver.resolve
method is never executed (butMyBinder.configure
is executed).(This does not concern the testbed application, but I encounter the problem in a slightly more complicated code: the resource method is never executed and the server responds with
500 No content to map to Object due to end of input
)
Any ideas as to what I might be doing wrong?