ServiceLoader.load() alternative

Hendy Irawan hendy at soluvas.com
Wed Oct 17 10:06:33 PDT 2012


Hi Jigsaw,

After reading openjdk-jigsaw-modular-services.pdf. Given the issues with
static methods like ServiceLoader.load(), particular in dynamic
environments (OSGi) and even more in scoped frameworks (like OSGi regions),
is it planned to offer a new recommended approach for locating services?

Instead of ServiceLoader.load(), the mechanism to locate a service would be
in a ServiceLookup interface, that can be provided to the consumer via
injection or other means... (or perhaps via static calls for simple cases).
This will be useful for testing, mocking, reusability, and also dynamic
frameworks like OSGi. ServiceLookup can be scoped to a specific region, and
the implementation can even change during runtime (e.g. by proxying).

Even better if an async version of ServiceLookup is provided, or a sync
version with a timeout. This will allow expanded use of ServiceLookup for
distributed environments, or stricter timing requirements.

ServiceLoader.load() will then be deprecated, or at least given a note that
it only supports a subset of the Jigsaw service capabilities. New
implementors should use ServiceLookup interface.

Is this feasible?


-- 
Hendy Irawan - on Twitter <http://twitter.com/hendybippo> - on
LinkedIn<http://id.linkedin.com/in/hendyirawan>
Web Developer | Bippo Indonesia <http://www.bippo.co.id/> | Akselerator
Bisnis | Bandung



More information about the jigsaw-dev mailing list