I'm migrating a JavaSE application from Jersey 2.x to 2.26. The application relies on HK2 for dependency injection.
Unfortunately some of the official documentation - custom injection, chapter 23 - is now incorrect and has not yet been updated. In his answer here, Paul explains how to migrate a HK2 Factory
to a Supplier
, which jersey now uses to set up a custom injection provider. Works great, but I'd like to ask for help for the rest of the chapter:
How do I setup a custom injection annotation?
Currently, my existing custom-injection-resolver classes (exactly as per the documentation) compile fine. I'm not sure if they should continue to implement org.glassfish.hk2.api.InjectionResolver
direcly? In the javadocs, I find InjectionResolverWrapper, do I need to extend that instead?
The real problem is how to bind the injection resolver to the custom injection. This does not compile:
bind(SessionInjectResolver.class)
.to(new TypeLiteral<InjectionResolver<SessionInject>>(){})
.in(Singleton.class);
I'd very much appreciate an example how to make injection with custom annotations work on Jersey 2.26 again.