I am looking through the ServiceFactory.class as it has been the source of some confusion on our project lately.
What is the difference between the ServiceRegistry and the ServiceLoader? When retrieving a SharedInterface implementation, is it ok to just use:
or should I use one of the following:
It appears ServiceFactory.getService() looks in the ServiceLoader first and, if it doesn’t find anything, goes to the ServiceRegistry so surely it must be the best one to call?
Finally, when is it advisable to use:
Is the only difference between this and getService() that getRequiredService() throws a MissingServiceException if the service is not found?
If I am correct, it appears we should be using ServiceFactory.getRequiredService() for any 'build-in functionality (services provided by standalone apps) such as the EventManager, ServiceManager, etc… and that we should simply use ServiceFactory.getService() when retrieving a shared interface implementation. Is this correct? Or should I be specifying the ServiceLoader / ServiceRegistry ?