Hi Jersey2 devs,
can anyone help shed some light on how to implement custom providers for Jersey 2?
I saw some discussions on this for Jersey 1, but the classes mentioned there did not survive the migration to Jersey 2. Any hints or material how to approach custom injection in Jersey 2?
Specifically, I need to get hold of a managed object (say, a service that I can use to look up credentials given a loginId) and pass that to a new filter instance during runtime setup:
So far, I am doing something like the following:
@javax.ws.rs.ApplicationPath("r")
public class ApplicationConfig extends ResourceConfig {
MyCredentialsService s; // ............. this needs to be injected
public ApplicationConfig() {
packages( ... bunch of packages with resource classes ...);
this.registerInstances(new SpecialAuthFeature(s)); // ............ pass injected service
}
}
Now, I understand (I hope) that I could do this with CDI, using the provided Binder mechanisms. However, I want at least my filters to steer clear of jersey dependencies. Instead, I thought I could simply pass the injected object to the filter constructor.
But how do I get the service injected into the constructor of my ResourceConfig?
Jan