Another module system question

Langer, Christoph christoph.langer at sap.com
Mon Feb 20 19:15:51 UTC 2017


Hi,

here is another question which generates out of my attempts to refactor our code into modules.

My design idea currently is to have a module for the API and another module which implements it. The API has a package where service interfaces are defined and the implementation will implement these service interfaces.

Let's say it looks like this:

a) module my.api exports the.api.package.services
b) module my.impl requires my.api
    provides the.api.package.services.Service1 with the.impl.package.providers.Service1Impl

This seems obvious to me as the impl needs to know the service interfaces. Anyway, maybe you could comment on this idea if this sounds like a reasonable pattern.

However, the main issue I have with this approach is: When is the time that my service from the second module 'b' will be available and registered? I assume, module 'a' will load first, then 'b'. So, when I use some static class initialization as the place in 'a' where I try to load the service from 'b', I guess the service couldn't be available yet. Is there some module system initialization hook, where I could plug in and then assume the service from 'b' is ready? Or should I maybe add a static class initializer in 'a' which would try to resolve the implementing service from 'b' in a loop until it is ready?

Looking forward to some suggestions here.

Thanks and best regards
Christoph



More information about the jigsaw-dev mailing list