public class ServiceLoader
extends java.lang.Object
Constructor and Description |
---|
ServiceLoader() |
ServiceLoader(java.lang.ClassLoader loader) |
ServiceLoader(java.lang.ClassLoader loader,
LoadErrorHandler handler) |
ServiceLoader(java.lang.ClassLoader loader,
LoadErrorHandler handler,
boolean dynamic) |
ServiceLoader(java.lang.ClassLoader loader,
LoadErrorHandler handler,
InitializableProblemHandler initializableProblemHandler,
boolean dynamic) |
Modifier and Type | Method and Description |
---|---|
java.util.Enumeration<java.net.URL> |
findServiceResources(java.lang.String filePattern)
Returns all the available service resources matching the
given pattern, such as all instances of tika-mimetypes.xml
on the classpath, or all org.apache.tika.parser.Parser
service files.
|
InitializableProblemHandler |
getInitializableProblemHandler()
Returns the handler for problems with initializables
|
java.lang.ClassLoader |
getLoader() |
LoadErrorHandler |
getLoadErrorHandler()
Returns the load error handler used by this loader.
|
java.io.InputStream |
getResourceAsStream(java.lang.String name)
Returns an input stream for reading the specified resource from the
configured class loader.
|
<T> java.lang.Class<? extends T> |
getServiceClass(java.lang.Class<T> iface,
java.lang.String name)
Loads and returns the named service class that's expected to implement
the given interface.
|
boolean |
isDynamic()
Returns if the service loader is static or dynamic
|
<T> java.util.List<T> |
loadDynamicServiceProviders(java.lang.Class<T> iface)
Returns the available dynamic service providers of the given type.
|
<T> java.util.List<T> |
loadServiceProviders(java.lang.Class<T> iface)
Returns all the available service providers of the given type.
|
<T> java.util.List<T> |
loadStaticServiceProviders(java.lang.Class<T> iface)
Returns the available static service providers of the given type.
|
static void |
setContextClassLoader(java.lang.ClassLoader loader)
Sets the context class loader to use for all threads that access
this class.
|
public ServiceLoader(java.lang.ClassLoader loader, LoadErrorHandler handler, InitializableProblemHandler initializableProblemHandler, boolean dynamic)
public ServiceLoader(java.lang.ClassLoader loader, LoadErrorHandler handler, boolean dynamic)
public ServiceLoader(java.lang.ClassLoader loader, LoadErrorHandler handler)
public ServiceLoader(java.lang.ClassLoader loader)
public ServiceLoader()
public static void setContextClassLoader(java.lang.ClassLoader loader)
loader
- default context class loader,
or null
to automatically pick the loaderpublic boolean isDynamic()
public LoadErrorHandler getLoadErrorHandler()
public InitializableProblemHandler getInitializableProblemHandler()
public java.io.InputStream getResourceAsStream(java.lang.String name)
name
- resource namenull
if the resource was not foundClassLoader.getResourceAsStream(String)
public java.lang.ClassLoader getLoader()
for the context's ClassLoader
public <T> java.lang.Class<? extends T> getServiceClass(java.lang.Class<T> iface, java.lang.String name) throws java.lang.ClassNotFoundException
LoadErrorHandler
, a
ClassNotFoundException
is always returned for unknown
classes or classes of the wrong typeiface
- service interfacename
- service class namejava.lang.ClassNotFoundException
- if the service class can not be found
or does not implement the given interfaceClass.forName(String, boolean, ClassLoader)
public java.util.Enumeration<java.net.URL> findServiceResources(java.lang.String filePattern)
public <T> java.util.List<T> loadServiceProviders(java.lang.Class<T> iface)
iface
- service provider interfacepublic <T> java.util.List<T> loadDynamicServiceProviders(java.lang.Class<T> iface)
iface
- service provider interfacepublic <T> java.util.List<T> loadStaticServiceProviders(java.lang.Class<T> iface)
iface
- service provider interface"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"