public interface ServiceFinder
Very similar to ServiceLoader but provides additional methods to
load configurations without being forced to load the classes.
Furthermore, it is not restricted to META-INF/services and the contents
of the configuration file. Supports dedicated classloaders for services as well.
Applications should use the ServiceFactory to allow replacement of the
finder (see Service-annotation)
| Modifier and Type | Method and Description |
|---|---|
Map<String,String> |
createNameMap(String serviceName)
Creates a map of names to mapped services.
|
Map<String,Set<String>> |
createNameMapToAll(String serviceName)
Creates a map of names to all mapped services.
|
Map.Entry<String,URL> |
findFirstServiceConfiguration(String serviceName)
Finds the first service configurations by service name.
If similar configurations appear more than once on the classpath, the first is returned. |
<T> Class<T> |
findFirstServiceProvider(Class<T> service)
Finds the first service provider by service name.
If similar configurations appear more than once on the classpath, the first is returned. |
Map<String,URL> |
findServiceConfigurations(String serviceName)
Finds service configurations by service name.
Iterations over the returned map are ordered by discovery along the classpath. |
<T> Collection<Class<T>> |
findServiceProviders(Class<T> service)
Finds the service providers by service names.
|
Enumeration<URL> |
findServiceURLs(String serviceName)
Finds URLs of a service by name.
|
Map.Entry<String,URL> |
findUniqueServiceConfiguration(String serviceName)
Finds a unique service configurations by service name.
It is checked that the service is defined exactly once. |
<T> Class<T> |
findUniqueServiceProvider(Class<T> service)
Finds the unique service provider by service name.
|
ClassLoader |
getClassLoader()
Gets the default classloader used by this finder.
|
String |
getServicePath()
Gets the finder' service path it is responsible for.
|
ClassLoader getClassLoader()
String getServicePath()
Map.Entry<String,URL> findFirstServiceConfiguration(String serviceName)
serviceName - the service name, usually a classnameTentackleRuntimeException - if no such service found<T> Class<T> findFirstServiceProvider(Class<T> service) throws ClassNotFoundException
T - the service typeservice - the service classClassNotFoundException - if some provider could not be loadedMap<String,URL> findServiceConfigurations(String serviceName)
serviceName - the service name, usually a classname<T> Collection<Class<T>> findServiceProviders(Class<T> service) throws ClassNotFoundException
T - the service typeservice - the service classClassNotFoundException - if some provider could not be loadedEnumeration<URL> findServiceURLs(String serviceName)
serviceName - the service name, usually a classnameMap.Entry<String,URL> findUniqueServiceConfiguration(String serviceName)
serviceName - the service name, usually a classname<T> Class<T> findUniqueServiceProvider(Class<T> service) throws ClassNotFoundException
T - the service typeservice - the service classClassNotFoundException - if some provider could not be loadedMap<String,String> createNameMap(String serviceName)
They key of the map is the service name. The value is the name providing the service which comes first in the classpath.
serviceName - the service classMap<String,Set<String>> createNameMapToAll(String serviceName)
They key of the map is the service name. The value is a list of names providing the service ordered by discovery along the classpath.
serviceName - the service classTentackle - a domain driven enterprise framework