|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.qrmedia.commons.multispi.MultiSpi
@ThreadSafe public final class MultiSpi
One-stop shop for users of MultiSpi. Instances should be created via dependency
injection or using the MultiSpiBuilder.
ServiceLoader| Constructor Summary | |
|---|---|
MultiSpi(Set<ServiceImplementationProvider> providers)
|
|
| Method Summary | ||
|---|---|---|
boolean |
equals(Object obj)
|
|
Set<String> |
findImplementationNames(Class<?> serviceClass)
Shorthand for findImplementationNames(serviceClass, defaultClassLoader)
where defaultClassLoader is
Thread.currentThread().getContextClassLoader() if non-null
ClassLoader.getSystemClassLoader() if non-null
the bootstrap classloader otherwise
|
|
Set<String> |
findImplementationNames(Class<?> serviceClass,
ClassLoader classpathResourceLoader)
Finds the names of classes implementing the requested service, as determined by the available providers. |
|
|
findImplementations(Class<S> serviceClass)
Shorthand for findImplementations(serviceClass, defaultClassLoader)
where defaultClassLoader is
Thread.currentThread().getContextClassLoader() if non-null
ClassLoader.getSystemClassLoader() if non-null
the bootstrap classloader otherwise
|
|
|
findImplementations(Class<S> serviceClass,
ClassLoader implementationLoader)
Finds the classes implementing the requested service, as determined by the available providers. |
|
int |
hashCode()
|
|
|
loadImplementations(Class<S> serviceClass)
Shorthand for loadImplementations(serviceClass, defaultClassLoader). |
|
|
loadImplementations(Class<S> serviceClass,
ClassLoader implementationLoader)
Finds the classes implementing the requested service, as determined by the available providers, and loads an instance of each implementation. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
@Inject
public MultiSpi(@Nonnull
Set<ServiceImplementationProvider> providers)
| Method Detail |
|---|
@Nonnull
public Set<String> findImplementationNames(@Nonnull
Class<?> serviceClass)
findImplementationNames(serviceClass, defaultClassLoader)
where defaultClassLoader is
Thread.currentThread().getContextClassLoader() if non-null
ClassLoader.getSystemClassLoader() if non-null
serviceClass - the class of the service
@Nonnull
public Set<String> findImplementationNames(@Nonnull
Class<?> serviceClass,
@Nonnull
ClassLoader classpathResourceLoader)
Note that individual providers may or may not guarantee that the classes returned actually implement the interface!
serviceClass - the class of the serviceclasspathResourceLoader - the class loader to be used to locate classpath resources
@Nonnull
public <S> Set<Class<? extends S>> findImplementations(@Nonnull
Class<S> serviceClass)
throws ClassCastException,
ClassNotFoundException
findImplementations(serviceClass, defaultClassLoader)
where defaultClassLoader is
Thread.currentThread().getContextClassLoader() if non-null
ClassLoader.getSystemClassLoader() if non-null
S - the type of the serviceserviceClass - the class of the service
ClassCastException - if any of the classes are not actually implementations
of the requested service
ClassNotFoundException - if any of the classes cannot be loadedfindImplementations(Class, ClassLoader)
@Nonnull
public <S> Set<Class<? extends S>> findImplementations(@Nonnull
Class<S> serviceClass,
@Nonnull
ClassLoader implementationLoader)
throws ClassCastException,
ClassNotFoundException
This method will check whether the classes found do, in fact, implement the
requested service, and a ClassCastException will be thrown if any
of the classes does not.
If more lenient behaviour is desired (e.g. skipping any classes that cannot be
found, or do not actually implement the interface), use
findImplementationNames(Class) instead.
S - the type of the serviceserviceClass - the class of the serviceimplementationLoader - the class loader to be used to attempt to load the classes
ClassCastException - if any of the classes are not actually implementations
of the requested service
ClassNotFoundException - if any of the classes cannot be loadedfindImplementations(Class)
@Nonnull
public <S> Set<S> loadImplementations(@Nonnull
Class<S> serviceClass)
throws ClassNotFoundException,
InstantiationException
loadImplementations(serviceClass, defaultClassLoader).
where defaultClassLoader is
Thread.currentThread().getContextClassLoader() if non-null
ClassLoader.getSystemClassLoader() if non-null
S - the type of the serviceserviceClass - the class of the service
ClassNotFoundException - if any of the classes cannot be loaded
InstantiationException - if any of the classes are not actually implementations
of the requested service, or cannot be instantiated using a public no-argument
constructorloadImplementations(Class, ClassLoader)
@Nonnull
public <S> Set<S> loadImplementations(@Nonnull
Class<S> serviceClass,
@Nonnull
ClassLoader implementationLoader)
throws ClassNotFoundException,
InstantiationException
This method will check whether the classes found do, in fact, implement the
requested service, and an InstantiationException will be thrown if any
of the classes does not.
Service classes are expected to provide a public, no-argument constructor, which
will be invoked to create instances of the implementation classes found. An
InstantiationException is thrown if the class cannot be instantiated.
If more lenient behaviour is desired (e.g. skipping any classes that cannot be
found, or do not actually implement the interface), use
findImplementationNames(Class) instead.
S - the type of the serviceserviceClass - the class of the serviceimplementationLoader - the class loader to be used to attempt to load the classes
ClassNotFoundException - if any of the classes cannot be loaded
InstantiationException - if any of the classes are not actually implementations
of the requested service, or cannot be instantiated using a public no-argument
constructorloadImplementations(Class)public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||