public abstract class ServiceLoader extends Object
lookupProviderInstances(java.lang.Class<T>)
which can find META-INF/services being part of OSGi bundles.
This class has been carefully coded to avoid any reference to OSGi classes so that
it can be called in a non-OSGi environment as well. In such an environment,
it simply returns null.
In an OSGi environment, we expect the class to be initialized by the bundle activator.#lookupProviderInstances}
Modifier and Type | Class and Description |
---|---|
static interface |
ServiceLoader.ProviderFactory<T> |
Modifier and Type | Method and Description |
---|---|
static void |
initialize(ServiceLoader singleton) |
static <T> Iterable<Class> |
lookupProviderClasses(Class<T> serviceClass)
It is not clear why one needs this method, but it is provided just in case one needs it.
|
static <T> Iterable<? extends T> |
lookupProviderInstances(Class<T> serviceClass)
Calling this method is equivalent to calling
lookupProviderInstances(Class, ProviderFactory)
with a null factory object. |
static <T> Iterable<? extends T> |
lookupProviderInstances(Class<T> serviceClass,
ServiceLoader.ProviderFactory<T> factory) |
static void |
reset() |
public static void initialize(ServiceLoader singleton)
public static void reset()
public static <T> Iterable<? extends T> lookupProviderInstances(Class<T> serviceClass)
lookupProviderInstances(Class, ProviderFactory)
with a null factory object.public static <T> Iterable<? extends T> lookupProviderInstances(Class<T> serviceClass, ServiceLoader.ProviderFactory<T> factory)
T
- serviceClass
- type of service requestedfactory
- ProviderFactory used to instantiate provider instance from a provider class. If null is supplied,
it calls Class.newInstance to obtain a provider instance from provider class.public static <T> Iterable<Class> lookupProviderClasses(Class<T> serviceClass)
T
- serviceClass
- type of service requestedCopyright © 2009–2023 Oracle Corporation. All rights reserved.