@ThreadSafe public class PluginLoader extends Object
PluginLoader
is used by the PluginManager
to load a single plugin. It is
essentially a combination of a PluginClassLoader
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> Iterator<P> |
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> 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–2021 The Apache Software Foundation. All rights reserved.