users@hk2.java.net

Re: ServiceLocator.getService(Class<T>, Annotation...)

From: John Wells <john.wells_at_oracle.com>
Date: Fri, 29 Nov 2013 18:28:46 -0500

Yes, that is a good idea. And I agree the documentation should say
something about that...

On 11/29/2013 6:21 PM, cowwoc wrote:
> Okay, so the documentation should highlight this fact.
>
> Would it make sense to add "ServiceLocator.getService(Class<T>,
> Class<? extends Annotation>...)" for marker annotations so we don't
> have to instantiate them for nothing?
>
> Thanks,
> Gili
>
> On 29/11/2013 6:17 PM, John Wells wrote:
>> Mainly because annotations may have data in them that would not be
>> there just from the class. This API allows you to match based on the
>> data in the annotation.
>>
>> On 11/29/2013 4:01 PM, cowwoc wrote:
>>> Hi,
>>>
>>> https://hk2.java.net/2.2.0-b24/api-overview.html explains that we
>>> must instantiate an annotation in order to use
>>> ServiceLocator.getService() by annotation. Instead of
>>> "ServiceLocator.getService(Class<T>, Annotation...)" why couldn't
>>> you do "ServiceLocator.getService(Class<T>, Class<? extends
>>> Annotation>...)"?
>>>
>>> Thanks,
>>> Gili
>>
>