public class ServiceRegistryLoader extends java.lang.Object implements ServiceLoader
Modifier and Type | Field and Description |
---|---|
private Injector |
injector |
private ServiceRegistry |
registry |
Constructor and Description |
---|
ServiceRegistryLoader(Injector injector,
ServiceRegistry registry) |
Modifier and Type | Method and Description |
---|---|
<T> java.util.Collection<T> |
all(java.lang.Class<T> serviceClass)
Load multiple service implementations.
|
private <T> T |
createServiceInstance(java.lang.Class<T> service) |
<T> T |
onlyOne(java.lang.Class<T> serviceClass)
Load a single service implementation.
|
<T> T |
onlyOne(java.lang.Class<T> serviceClass,
java.lang.Class<? extends T> defaultServiceClass)
Load a single service implementation.
|
private <T> java.lang.String |
toClassString(java.util.Collection<T> providers) |
private Injector injector
private ServiceRegistry registry
public ServiceRegistryLoader(Injector injector, ServiceRegistry registry)
public <T> java.util.Collection<T> all(java.lang.Class<T> serviceClass)
ServiceLoader
all
in interface ServiceLoader
serviceClass
- The service interface to load a implementations forCollection
of all instances of serviceClasspublic <T> T onlyOne(java.lang.Class<T> serviceClass)
ServiceLoader
IllegalStateException
if multiple instances of serviceClass found.onlyOne
in interface ServiceLoader
serviceClass
- The service interface to load a implementation forpublic <T> T onlyOne(java.lang.Class<T> serviceClass, java.lang.Class<? extends T> defaultServiceClass)
ServiceLoader
onlyOne
in interface ServiceLoader
serviceClass
- The service interface to load a implementation fordefaultServiceClass
- If no other implementations found, create a instance of this classprivate <T> T createServiceInstance(java.lang.Class<T> service)
private <T> java.lang.String toClassString(java.util.Collection<T> providers)