@NoImplement public interface ServiceRegistry
ServiceLoader
directly are the ability to inject a different lookup mechanism and to facilitate testing.Modifier and Type | Method and Description |
---|---|
<T> T |
lookupProvider(Class<T> providerClass,
ClassLoader loader)
Searches for implementations of a particular service class.
|
<T> Collection<T> |
lookupProviders(Class<T> providerClass,
ClassLoader loader)
Searches for implementations of a particular service class using the given class loader.
|
<T> Collection<T> lookupProviders(Class<T> providerClass, ClassLoader loader)
providerClass
- a Class
object indicating the class or interface of the service providers being detected.loader
- the class loader to be used to load provider/configuration files and instantiate provider instances. If
null
, it will be up to the implementation to choose a ClassLoader
Collection
that yields provider objects for the given service, in some arbitrary order.<T> T lookupProvider(Class<T> providerClass, ClassLoader loader)
providerClass
- a Class
object indicating the class or interface of the service providers being detected.loader
- the class loader to be used to load provider/configuration files and instantiate provider instances. If
null
, it will be up to the implementation to choose a ClassLoader
{@link
- IllegalStateException} if there's no provider found or there's more than one provider.Copyright © 2018. All rights reserved.