dev@glassfish.java.net

Re: [Asking]About META-INF/hk2-locator/default

From: John Wells <john.wells_at_oracle.com>
Date: Thu, 25 Apr 2013 06:57:54 -0400

Comments in-line:

On 4/25/2013 12:36 AM, Tang Yong wrote:
> Thanks! I see.
>
> If john has other suggestions, please telling me.
>
> Thanks
> Tang
>
> Sahoo wrote:
>> That file does not contain @inject details. Only @service details.
>> The format may have been documented in hk2 project website. John and
>> co have taken a lot of care to document things. If you don't find any
>> such document, then look at the maven plugin that generates this file.
>> Since anyway you have to scan classes for @inject annotations, you
>> might as well scan @service annotations. That way you don't have to
>> deal with this file format.
>> John may also point you in some good direction.
>> Thank, Sahoo
We explicitly do NOT document the format of this file because we would
like to be able to change the format in the future if we come up with
some reason for doing so. Sahoo is correct though, we do not in fact
keep any @Inject information in the file. This file is read at startup
and hence we are trying to keep it as small as possible.
>>
>> Sent from my Android phone, please excuse me for its brevity.
>>
>> -----Original Message----- From: Tang Yong [tangyong_at_cn.fujitsu.com]
>> Received: Thursday, 25 Apr 2013, 9:11
>> To: John Wells [john.wells_at_oracle.com]
>> CC: Sahoo [sanjeeb.sahoo_at_oracle.com]; dev_at_glassfish.java.net
>> [dev_at_glassfish.java.net]
>> Subject: [Asking]About META-INF/hk2-locator/default
>>
>> Hi JWells,
>> CC: Sahoo,
>>
>> I have two questions about META-INF/hk2-locator/default file,
>> eg. for web-glue.jar,
>>
>> 1. in the default file, whether containing metadata generated by
>> @Inject? That is to say, if some class in web-glue module defines the
>> following,
>>
>> @Inject
>> private JCDIService jcdiService;
>>
>> Then, whether generating @Inject related info(JCDIService,...) into
>> META-INF/hk2-locator/default.
>>
>> As far as I know, I found META-INF/hk2-locator/default seems to only
>> write @Service related info.
>>
>> 2. in web-glue.jar's META-INF/hk2-locator/default file, the following,
>>
>> ...
>> [com.sun.enterprise.web.PEWebContainerFeatureFactoryImpl]S
>> contract={com.sun.enterprise.web.pluggable.WebContainerFeatureFactory}
>> name=pe
>>
>> [com.sun.enterprise.web.ServerConfigLookup]
>> ...
>>
>> 1) whether "S" in
>> [com.sun.enterprise.web.PEWebContainerFeatureFactoryImpl]S means the
>> entry is @Service info?
The "S" means that service is in the Singleton scope. This is a
shorthand which made the file much smaller (we used to have to say
"scope=javax.inject.Singleton".

Another shortcut in the file is that the implementation by default is
considered to be in the set of contracts unless "-" is after the ].
This was also done to reduce the size of the file.
>>
>> 2) [com.sun.enterprise.web.ServerConfigLookup] entry has not "S", I want
>> to know the meaning?
If it does not have an "S" and does not have a scope= clause then it is
in PerLookup scope.
>>
>> Finally, if META-INF/hk2-locator/default file does not generate @Inject
>> info, I wish that @Inject info can be added into the file because on
>> some scenes, I need to introspect glassfish modules(class file) to find
>> @Inject info, if the @Inject info can be added into
>> META-INF/hk2-locator/default file, that will avoid redundant things by
>> pasing the file directly.
>>
>> Thanks
>> --Tang
>>
>