users@hk2.java.net

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

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Fri, 06 Dec 2013 00:46:35 -0500

Oh, I see. I thought that the inhabitant generator only generated
binding for the @Service annotation. In that case, I agree with you that
it should stay.

I just don't think you should be forced to use it for @Service-annotated
classes because there is a decent way to auto-bind those at runtime.

Gili

On 05/12/2013 11:09 PM, Mason Taube wrote:
> 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
> <mailto: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?
>