Reputation: 6207
I'm converting an OSGi system into a non-OSGi one, and I have a few services that used to be managed by OSGi. I'I'm trying to use HK2 to inject service implementations in a few classes.
I created a custom injection annotation, and created an InjectResolver
for it. Then I extended AbstractBinder
and used the bind
method to link my annotation to my custom injection resolver. Great.
But now, how do I make the system use this binder??
If I were using HK2 with Jersey, I'd register this binder in Jersey's ResoureConfig
. But this is not a Jersey application.
How do I tell Hk2 to use my binder so it knows about my custom annotation?
Thanks!
Upvotes: 1
Views: 1778
Reputation: 2404
Use any one of these:
There are several other API in ServiceLocatorUtilities designed to make adding/removing services from HK2 easy. In general HK2 is very dynamic, so there are many other ways to add/remove services. The base of all of them is the DynamicConfigurationService:
https://hk2.java.net/2.3.0/apidocs/org/glassfish/hk2/api/DynamicConfigurationService.html
Upvotes: 1