services, take 1
Alan.Bateman at oracle.com
Mon Dec 19 04:41:58 PST 2011
On 19/12/2011 10:41, Julien Ponge wrote:
> Ok so my understanding is that Jigsaw at the moment (aka still an
> exploratory prototype) is a static modules system where modules have
> dependencies (names + versions). Some may also be optional. You can
> also now specify services exports / imports as well. Services get
> discovered through the the ServiceLoader facility, which is a good
> thing IMHO.
Conceptually they are discovered but it's relatively efficient at
runtime because it is indexed in the configuration.
> Something which is not clear by looking at the scarce documentation
> and (empty) javadocs is how modules affect classloading. Do modules
> form an directed graph of classloaders underneath? Or do modules
> resolve within their client context classloaders?
In the simple case there will be a module loader per module at runtime
(created lazily of course). Where there are local dependencies these
these modules become strongly connected and have the same module loader.
> Suppose that I have a module that does a lookup on all services
> implementing ServiceA.
> 1. How do you load another module at runtime?
With the current patch then invoking
ServiceLoader.loadInstalled(ServiceA.class) causes the module loaders
for the modules that provide an implementation of ServiceA to be created
if they haven't been created already. This could be done more lazily,
and there's a comment in the patch as a reminder on that.
> 2. Do you see new services via the ServiceLoader?
> I think a dynamic modules/services API is important to have, not
> necessarily as an OSGi clone either. My fear is that otherwise people
> will build such frameworks on top of Jigsaw because there is a need
> for it in app servers and such, so I'd better have a clean/simple API
> in Jigsaw.
If an application is running and someone installs into the module
library a new module that provides ServiceA then that application will
not see the additional ServiceA implementations until it is
re-configured and restarted. Jigsaw doesn't have container support yet
but conceptually that involves generating configuration at runtime and
this could mean that simultaneous applications running in the same
container could observe different sets of modules that provide a
More information about the jigsaw-dev