Tag Archives: service locator

OSGi Service Locator

The Service Locator pattern is a well-established mechanism for accessing local and remote services in a consistent manner:

public interface ServiceLocator {

<T> T findService(String serviceName) throws ServiceNotAvailableException;
}

Using a structured service name interface we can improve uniformity and reduce the potential for typos:

public enum ServiceName {

SomeService("SomeService");

private final String filter;
[...]

Posted in Java | Also tagged , | 2 Comments