Proposal: #NonHierarchicalLayers
Thomas Watson
tjwatson at us.ibm.com
Wed Dec 7 13:57:08 UTC 2016
>
> I think I'm also running across the same issue that Tom Watson raised
> last Tuesday about not knowing in advance what services are being used
> by a module. I seem to recall that we discussed allowing the Layer to
> mediate service load requests made by modules within that layer; is that
> something I've recalled correctly, and if so, is that option still on
> the table?
>
> --
> - DML
>
The way I got around this for services provided by boot layer was to
discover ALL the services provided by the boot layer which come from
unqualified exported packages. I then define ModuleDescriptors for each
OSGi bundle that uses each and every one of the 'public' services provided
by the boot layer. This allowed my to effectively state that a module for
an OSGi bundle uses * services from the boot layer. But this also
required me to make each OSGi bundle's ModuleDescription require any
module from boot which exports a packages that contains the contract API
being loaded by the ServiceLoader. Otherwise a failure will occur
creating the configuration because JPMS thinks the module using the
service does not have access to the service contract.
I would be interested to hear what ideas there are around allowing a Layer
Controller to influence this behavior such that we can detect
ServiceLoader usage by modules in our layers and addUses at runtime as
appropriate for our module systems. Perhaps a more simple option is to
simply allow any attempt at ServiceLoader.load, without checking for
service uses, from modules that are contained in a Layer that was resolved
with with the 'resolveRequires' vs. the 'resolveRequiresAndUses' method.
Tom
More information about the jpms-spec-observers
mailing list