@ThreadSafe public class PluginLoader extends Object
PluginLoader
is used by the PluginManager
to load a single plugin. It is essentially a combination
of a ChildFirstClassLoader
and ServiceLoader
. This class can locate and load service implementations
from the plugin for a given SPI. The PluginDescriptor
, which among other information contains the resource
URLs, is provided at construction.Constructor and Description |
---|
PluginLoader(ClassLoader pluginClassLoader) |
Modifier and Type | Method and Description |
---|---|
static PluginLoader |
create(PluginDescriptor pluginDescriptor,
ClassLoader parentClassLoader,
String[] alwaysParentFirstPatterns) |
static ClassLoader |
createPluginClassLoader(PluginDescriptor pluginDescriptor,
ClassLoader parentClassLoader,
String[] alwaysParentFirstPatterns) |
<P extends Plugin> |
load(Class<P> service)
Returns in iterator over all available implementations of the given service interface (SPI) for the plugin.
|
@VisibleForTesting public PluginLoader(ClassLoader pluginClassLoader)
@VisibleForTesting public static ClassLoader createPluginClassLoader(PluginDescriptor pluginDescriptor, ClassLoader parentClassLoader, String[] alwaysParentFirstPatterns)
public static PluginLoader create(PluginDescriptor pluginDescriptor, ClassLoader parentClassLoader, String[] alwaysParentFirstPatterns)
public <P extends Plugin> Iterator<P> load(Class<P> service)
P
- Type of the requested plugin service.service
- the service interface (SPI) for which implementations are requested.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.