|
ShrinkWrap Resolver SPI 2.0.0-cr-1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.shrinkwrap.resolver.spi.loader.ServiceRegistry
public class ServiceRegistry
A simple singleton (application scoped} registry that fulfills ServiceLoader contract. This registry uses underlying
ServiceLoader implementation to load the service while storing cached instances in a local map.
| Constructor Summary | |
|---|---|
ServiceRegistry(ServiceLoader serviceLoader)
Creates a service registry with a ServiceLoader to load service instances until they are cached |
|
| Method Summary | ||
|---|---|---|
|
all(Class<T> serviceClass)
Loads all registered services for given serviceClass |
|
static ServiceRegistry |
getInstance()
Returns ServiceRegistry instance. |
|
|
onlyOne(Class<T> serviceClass)
Loads a registered service for given serviceClass |
|
|
onlyOne(Class<T> serviceClass,
Class<? extends T> defaultImplementationClass)
Loads a registered service for given serviceClass. |
|
static void |
register(ServiceRegistry registry)
Registers an instance of ServiceRegistry. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ServiceRegistry(ServiceLoader serviceLoader)
ServiceLoader to load service instances until they are cached
serviceLoader - | Method Detail |
|---|
public static ServiceRegistry getInstance()
throws IllegalStateException
ServiceRegistry instance. Instance must be registered first.
IllegalStateException - If no service registry was registered yetpublic static void register(ServiceRegistry registry)
ServiceRegistry.
registry -
public <T> Collection<T> all(Class<T> serviceClass)
throws IllegalArgumentException
serviceClass
all in interface ServiceLoaderserviceClass -
IllegalArgumentException - If serviceClass is null
public <T> T onlyOne(Class<T> serviceClass)
throws IllegalArgumentException,
IllegalStateException
serviceClass
onlyOne in interface ServiceLoaderserviceClass -
IllegalArgumentException - If either classLoader or serviceClass is null
IllegalStateException - If more than a single service is registered
public <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.
onlyOne in interface ServiceLoaderserviceClass - defaultImplementationClass -
IllegalArgumentException - If either serviceClass or defaultImplementationClass is null
IllegalStateException - If more than a single service is registered
|
ShrinkWrap Resolver SPI 2.0.0-cr-1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||