public class SingleProviderResolver extends Object
This class is in principle similar to the ServiceLoader.
The design is a little bit simpler, because there is always one provider for each
interface. The java own ServiceLoader has troubles in Android, because the
the META-INF contents are not merged automatically when building an Android
application.
The implementation falls back to the normal ServiceLoader mechanism, if the custom
mechanism is not working. This is needed for OSGi environments to resolve the implementation
from the API package.
| Constructor and Description |
|---|
SingleProviderResolver() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
resolve(Class<T> c)
Return a provider for this interface.
|
static <T> T |
resolve(Class<T> c,
Class<? extends T> defaultImpl)
Return a provider for this interface.
|
static <T> T |
resolveMandatory(Class<T> c)
Return a provider for this interface.
|
public static <T> T resolveMandatory(Class<T> c)
T - type of provider interfacec - the provider interface that is implementedLinkageError - if there is a problem instantiating the provider
or no provider was specifiedpublic static <T> T resolve(Class<T> c)
T - type of provider interfacec - the provider interface that is implementednull if not foundLinkageError - if there is a problem instantiating the providerpublic static <T> T resolve(Class<T> c, Class<? extends T> defaultImpl)
T - type of provider interfacec - the provider interface that is implementeddefaultImpl - if no provider is found, instantiate the default implementationnull if not foundLinkageError - if there is a problem instantiating the providercache2k API documentation. Copyright © 2000–2019 headissue GmbH, Munich.