On Jul 14, 2008, at 11:10 AM, Kedar Mhaswade wrote:
> Thanks for these instructions. I will try them out.
>
> If you have two "Service"s implementing the same "Contract", can
> a Service be looked up by "name"?
it depends if you do an injection
@Inject(name="the name of the service you want")
Realm realm
if u do an API lookup, that's
habitat.getComponent(Realm.class, "the name of the service you want")
>
>
> Where does the "name" of a Service reflect in domain.xml? (What
> attribute)?
>
the name, the contract, the service name does *not* go into the
domain.xml.
It's stored in the inhabitant file.
jerome
> Thanks,
> Kedar
>
> 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();
>> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>