dev@glassfish.java.net

Re: How to load a class using HK2 mechanisms

From: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Mon, 14 Jul 2008 21:56:18 +0530

Sahoo wrote:

> Kumar,
>
> This is a good question. I am copying dev@ for others' benefit.
> Something like this should work:
>
> 1. Realm is a contract, which means.
> @Contract intercace Realm {...}
> 2. Let's say user provides FooRealm. They write:
> @Service class FooRealm implements Realm {...}
> They can choose to implement the same using OSGi service mechanism as
> well. We do the mapping from OSGi to HK2 service transparently.
>
> 3. Assuming you have the class name from domain.xml, in your code, you
> can use Habitat API to get hold of the service as shown below:
> @Inject Habitat habitat;
> Realm customRealm = habitat.getInhabitantsByType("FooRealm").get();
>
I am assuming the argument above can acutally be the fully package
qualified classname (of the custom realm) is that correct ?.

regards,
kumar

> Hope this helps,
>
> Thanks,
> Sahoo
> V B Kumar Jayanti wrote:
>
>> Hi Sahoo,
>>
>> I wanted to put in code for loading a Custom Realm defined as a
>> HK2/OSGI Module. Can you tell me how i can do that.
>>
>> regards,
>> kumar
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>