I'm trying to use Jersey with HK2. I need to bind really weird type:
List<TransformationService<? extends Transformation, ? extends TransformationInfor>>
So I have my binder defined as follows:
resourceConfig.register(new AbstractBinder() {
@Override
protected void configure() {
List<TransformationService<? extends Transformation, ? extends TransformationInfo>> transformationServices = ... ;
bind(transformationServices)
.to(new TypeLiteral<List<TransformationService<? extends Transformation, ? extends TransformationInfo>>>() {});
// This class needs the list for its construction
bind(TransformationServiceImpl.class).to(TransformationService.class);
}
});
When I run the code though I get exception that my list can't be injected (packages ommitted):
[11/20/15 16:46:34] WARNING org.glassfish.jersey.internal.Errors logErrors : The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 3
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=List<TransformationService<? extends ...Transformation,? extends ...TransformationInfo>>,parent=TransformationServiceImpl,qualifiers={},position=3,optional=false,self=false,unqualified=null,334434299)
at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:74)
at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:214)
Any tips on how to inject such weirdo with HK2?