dev@glassfish.java.net

Re: Wiki page with OSGi package statistics for various glassfish bundles

From: Sahoo <Sahoo_at_Sun.COM>
Date: Fri, 07 May 2010 06:03:53 +0530

Tim Quinn wrote:
>
> On May 6, 2010, at 11:17 AM, Sahoo wrote:
>
>> Tim Quinn wrote:
>>>
>>>
>>> 2. Modules that hk2 scans to discover implementations of
>>> interfaces. For example, Sniffer implementations.
>>>
>>> The hk2 code looks at all the JARs that have been placed in the
>>> modules directory, searching each for inhabitants. The hk2 module
>>> does not declare imports of such modules - it cannot know about them
>>> at the time hk2 is built.
>>>
>>> Yet hk2 is using OSGi loading techniques, so the relevant packages
>>> must be exported from the OSGi modules even thought no other OSGi
>>> module in the reporting tool's survey imports those packages at all.
>> No, this is not true. Packages of the services don't have to be
>> exported. Only the service interface package has to be exported.
>
> I'm confused.
>
> The interface (e.g., org.glassfish.api.container.Sniffer) is defined
> in one module (common/glassfish-api) and several implementation
> classes of that interface are defined in other modules:
>
> web/gf-web-connector contains org.glassfish.web.sniffer.WebSniffer,
> exports org.glassfish.web.sniffer
> appclient/server/connector contains
> org.glassfish.appclient.server.connector.AppClientSniffer, exports
> org.glassfish.appclient.server.connector
>
> etc.
>
> Are you saying that the modules which hold the implementations do not
> need to export the implementation packages? How would OSGi find and
> load the implementation classes for hk2 if the modules do not export
> the implementation packages?
Yes, I did say that modules which hold the implementations do not need
to and should not export the implementation packages. Service classes
are loaded by a special module called osgi-adapter.jar using using
org.osgi.framework.Bundle.loadClass().

Thanks,
Sahoo