public interface ServiceLoader
All service are required to have a non-argument public constructor.
All ServiceLoader are required to handle registration of services implemented as Enums. See SpiServiceLoader
for default implementation.
| Modifier and Type | Method and Description |
|---|---|
<T> Collection<T> |
all(Class<T> serviceClass)
Loads all registered services for given
serviceClass |
<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. |
<T> Collection<T> all(Class<T> serviceClass) throws IllegalArgumentException
serviceClassIllegalArgumentException - If either classLoader or serviceClass is null<T> T onlyOne(Class<T> serviceClass) throws IllegalArgumentException, IllegalStateException
serviceClassIllegalArgumentException - If serviceClass is nullIllegalStateException - If more than a single service is registered<T> T onlyOne(Class<T> serviceClass, Class<? extends T> defaultImplementationClass) throws IllegalArgumentException, IllegalStateException
serviceClass. Reverts to the defaultImplementationClass if no
other service is registered. If defaultImplemenationClass is registered as well, it simply ignores it
during
resolution.IllegalArgumentException - If either serviceClass or defaultImplementationClass is nullIllegalStateException - If more than a single service is registeredCopyright © 2017 JBoss by Red Hat. All rights reserved.