users@hk2.java.net

Re: ServiceLocator.getService() failing for _at_Service-annotated classes

From: Mason Taube <mason.taube_at_oracle.com>
Date: Thu, 5 Dec 2013 23:09:35 -0500

Were you suggesting getting rid of the inhabitant generator entirely? I was trying to provide an example as to why it’s still needed.

You don’t have to use the inhabitant generator today if you don’t want to, it won’t happen automatically but you could register your class programmatically prior to performing the lookup:

org.glassfish.hk2.utilities.ServiceLocatorUtilities.addClasses(serviceLocator, TestClass.class);

https://hk2.java.net/apidocs/org/glassfish/hk2/utilities/ServiceLocatorUtilities.html#addClasses%28org.glassfish.hk2.api.ServiceLocator,%20java.lang.Class...%29
 

On Dec 5, 2013, at 10:36 PM, cowwoc <cowwoc_at_bbs.darktech.org> wrote:

> I'm a little confused. I was talking exclusively of replacing the need to use inhabitant generator to translate @Service annotations to HK2 bindings. It sounds to me like you're talking about converting OSGI bundles to HK2 bindings. How are the two related?