dev@glassfish.java.net

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

From: Tim Quinn <tim.quinn_at_oracle.com>
Date: Thu, 6 May 2010 11:59:45 -0500

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?

Thanks.

- Tim