public class SpiServiceLoader extends Object implements ServiceLoader
ServiceLoader implementation which uses META-INF/services registration.
In order to register a service, create a file META-INF/services/${service.interface.name}. The content of the file should
list fully qualified names of interface implementations, separated by new line character.| Constructor and Description |
|---|
SpiServiceLoader()
Create an instance of SPI service loader
|
SpiServiceLoader(ClassLoader classLoader)
Creates an instance of SPI service loader.
|
| Modifier and Type | Method and Description |
|---|---|
<T> Collection<T> |
all(Class<T> serviceClass)
Loads all registered services for given
serviceClass |
ClassLoader |
getClassLoader() |
<T> T |
onlyOne(Class<T> serviceClass)
Loads a registered service for given
serviceClass |
<T> T |
onlyOne(Class<T> serviceClass,
Class<? extends T> defaultImplementationClass)
Loads a registered service for given
serviceClass. |
void |
setClassLoader(ClassLoader classLoader) |
public SpiServiceLoader()
public SpiServiceLoader(ClassLoader classLoader)
ClassLoader to load service implementations.classLoader - public <T> Collection<T> all(Class<T> serviceClass)
ServiceLoaderserviceClassall in interface ServiceLoaderpublic <T> T onlyOne(Class<T> serviceClass)
ServiceLoaderserviceClassonlyOne in interface ServiceLoaderpublic <T> T onlyOne(Class<T> serviceClass, Class<? extends T> defaultImplementationClass)
ServiceLoaderserviceClass. Reverts to the defaultImplementationClass if no
other service is registered. If defaultImplemenationClass is registered as well, it simply ignores it during
resolution.onlyOne in interface ServiceLoaderpublic ClassLoader getClassLoader()
public void setClassLoader(ClassLoader classLoader)
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.