I am having two dropwizard java App in two module. Let's Say A and B,and Our B Module depends on A.
Now I want to inject different client in two different situations i.e one when A's dropwizard run and other when B's dropwizard run.
Suppose Myclass is in A module :
public class MyClass
{
@Inject
private final CustomClient client;
}
I want to do this with HK2 dependency injection. Notice class Myclass is not a resource class...
Currently, I have registered another Implementation for CustomClient in my App of module B like this :
environment.jersey().register(new AbstractBinder() {
@Override
protected void configure() {
...
bind(new MyCustomClient()).to(CustomClient.class);
...
}
});
But when I run the app of B, and calling class MyClass of A from it I am getting null for CustomClient of Class Myclass in module A.
But I was thinking I will get an instance of MyCustomClient after getting injected.
How can I achieve what I want with HK2 DI?
Note: I want to do the injection in normal java class with HK2.