Package org.apache.flink.core.plugin
Class PluginLoader
- java.lang.Object
-
- org.apache.flink.core.plugin.PluginLoader
-
- All Implemented Interfaces:
AutoCloseable
@ThreadSafe public class PluginLoader extends Object implements AutoCloseable
APluginLoader
is used by thePluginManager
to load a single plugin. It is essentially a combination of aPluginLoader.PluginClassLoader
andServiceLoader
. This class can locate and load service implementations from the plugin for a given SPI. ThePluginDescriptor
, which among other information contains the resource URLs, is provided at construction.
-
-
Constructor Summary
Constructors Constructor Description PluginLoader(String pluginId, URLClassLoader pluginClassLoader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static PluginLoader
create(PluginDescriptor pluginDescriptor, ClassLoader parentClassLoader, String[] alwaysParentFirstPatterns)
static URLClassLoader
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.
-
-
-
Constructor Detail
-
PluginLoader
@VisibleForTesting public PluginLoader(String pluginId, URLClassLoader pluginClassLoader)
-
-
Method Detail
-
createPluginClassLoader
@VisibleForTesting public static URLClassLoader createPluginClassLoader(PluginDescriptor pluginDescriptor, ClassLoader parentClassLoader, String[] alwaysParentFirstPatterns)
-
create
public static PluginLoader create(PluginDescriptor pluginDescriptor, ClassLoader parentClassLoader, String[] alwaysParentFirstPatterns)
-
load
public <P> Iterator<P> load(Class<P> service)
Returns in iterator over all available implementations of the given service interface (SPI) for the plugin.- Type Parameters:
P
- Type of the requested plugin service.- Parameters:
service
- the service interface (SPI) for which implementations are requested.- Returns:
- An iterator of all implementations of the given service interface that could be loaded from the plugin.
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-