Package org.pentaho.di.core.plugins
Class PluginRegistry
- java.lang.Object
-
- org.pentaho.di.core.plugins.PluginRegistry
-
public class PluginRegistry extends Object
This singleton provides access to all the plugins in the Kettle universe.
It allows you to register types and plugins, query plugin lists per category, list plugins per type, etc.- Author:
- matt
-
-
Field Summary
Fields Modifier and Type Field Description static LogChannelInterface
log
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
addClassFactory(Class<? extends PluginTypeInterface> pluginType, Class<T> tClass, String id, Callable<T> callable)
Add a Class Mapping + factory for a plugin.void
addClassLoader(URLClassLoader ucl, PluginInterface plugin)
void
addParentClassLoaderPatterns(PluginInterface plugin, String[] patterns)
<T extends PluginTypeInterface>
voidaddPluginListener(Class<T> typeToTrack, PluginTypeListener listener)
Allows the tracking of plugins as they come and go.static void
addPluginType(PluginTypeInterface type)
Add a PluginType to be managed by the registryList<PluginInterface>
findPluginsByFolder(URL folder)
PluginInterface
findPluginWithDescription(Class<? extends PluginTypeInterface> pluginType, String pluginDescription)
Find the plugin ID based on the description of the pluginPluginInterface
findPluginWithId(Class<? extends PluginTypeInterface> pluginType, String pluginId)
Find the plugin ID based on the name of the pluginPluginInterface
findPluginWithId(Class<? extends PluginTypeInterface> pluginType, String pluginId, boolean waitForPluginToBeAvailable)
PluginInterface
findPluginWithName(Class<? extends PluginTypeInterface> pluginType, String pluginName)
Find the plugin ID based on the name of the pluginstatic List<PluginTypeInterface>
getAddedPluginTypes()
Added so we can tell when types have been added (but not necessarily registered)List<String>
getCategories(Class<? extends PluginTypeInterface> pluginType)
Retrieve a list of all categories for a certain plugin type.<T> T
getClass(PluginInterface plugin, String className)
Load the class with a certain name using the class loader of certain plugin.<T> T
getClass(PluginInterface plugin, T classType)
Load the class with a certain name using the class loader of certain plugin.ClassLoader
getClassLoader(PluginInterface plugin)
Create or retrieve the class loader for the specified pluginstatic PluginRegistry
getInstance()
PluginInterface
getPlugin(Class<? extends PluginTypeInterface> pluginType, Object pluginClass)
Retrieve the Plugin for a given classPluginInterface
getPlugin(Class<? extends PluginTypeInterface> pluginType, String id)
Get a plugin from the registryString
getPluginId(Class<? extends PluginTypeInterface> pluginType, Object pluginClass)
Find the plugin ID based on the classString
getPluginId(Object pluginClass)
Find the plugin ID based on the classRowBuffer
getPluginInformation(Class<? extends PluginTypeInterface> pluginType)
List<String>
getPluginPackages(Class<? extends PluginTypeInterface> pluginType)
<T extends PluginInterface,K extends PluginTypeInterface>
List<T>getPlugins(Class<K> type)
<T extends PluginTypeInterface>
List<PluginInterface>getPluginsByCategory(Class<T> pluginType, String pluginCategory)
Retrieve a list of plugins per category.PluginTypeInterface
getPluginType(Class<? extends PluginTypeInterface> pluginTypeClass)
List<Class<? extends PluginTypeInterface>>
getPluginTypes()
static void
init()
static void
init(boolean keepCache)
This method registers plugin types and loads their respective plugins<T> T
loadClass(Class<? extends PluginTypeInterface> pluginType, Object object, Class<T> classType)
Load the class of the type specified for the plugin that owns the class of the specified object.<T> T
loadClass(Class<? extends PluginTypeInterface> pluginType, String pluginId, Class<T> classType)
Load the class of the type specified for the plugin with the ID specified.Object
loadClass(PluginInterface plugin)
Load and instantiate the main class of the plugin specified.<T> T
loadClass(PluginInterface plugin, Class<T> pluginClass)
Load and instantiate the plugin class specifiedvoid
registerPlugin(Class<? extends PluginTypeInterface> pluginType, PluginInterface plugin)
void
registerPluginType(Class<? extends PluginTypeInterface> pluginType)
void
removePlugin(Class<? extends PluginTypeInterface> pluginType, PluginInterface plugin)
void
reset()
-
-
-
Field Detail
-
log
public static final LogChannelInterface log
-
-
Method Detail
-
getInstance
public static PluginRegistry getInstance()
- Returns:
- The one and only PluginRegistry instance
-
registerPluginType
public void registerPluginType(Class<? extends PluginTypeInterface> pluginType)
-
removePlugin
public void removePlugin(Class<? extends PluginTypeInterface> pluginType, PluginInterface plugin)
-
addParentClassLoaderPatterns
public void addParentClassLoaderPatterns(PluginInterface plugin, String[] patterns)
-
registerPlugin
public void registerPlugin(Class<? extends PluginTypeInterface> pluginType, PluginInterface plugin) throws KettlePluginException
- Throws:
KettlePluginException
-
getPluginTypes
public List<Class<? extends PluginTypeInterface>> getPluginTypes()
- Returns:
- An unmodifiable list of plugin types
-
getPlugins
public <T extends PluginInterface,K extends PluginTypeInterface> List<T> getPlugins(Class<K> type)
- Parameters:
type
- The plugin type to query- Returns:
- The list of plugins
-
getPlugin
public PluginInterface getPlugin(Class<? extends PluginTypeInterface> pluginType, String id)
Get a plugin from the registry- Parameters:
pluginType
- The type of plugin to look forid
- The ID to scan for- Returns:
- the plugin or null if nothing was found.
-
getPluginsByCategory
public <T extends PluginTypeInterface> List<PluginInterface> getPluginsByCategory(Class<T> pluginType, String pluginCategory)
Retrieve a list of plugins per category.- Parameters:
pluginType
- The type of plugins to searchpluginCategory
- The category to look in- Returns:
- An unmodifiable list of plugins that belong to the specified type and category.
-
getCategories
public List<String> getCategories(Class<? extends PluginTypeInterface> pluginType)
Retrieve a list of all categories for a certain plugin type.- Parameters:
pluginType
- The plugin type to search categories for.- Returns:
- The list of categories for this plugin type. The list can be modified (sorted etc) but will not impact the registry in any way.
-
loadClass
public Object loadClass(PluginInterface plugin) throws KettlePluginException
Load and instantiate the main class of the plugin specified.- Parameters:
plugin
- The plugin to load the main class for.- Returns:
- The instantiated class
- Throws:
KettlePluginException
- In case there was a loading problem.
-
loadClass
public <T> T loadClass(Class<? extends PluginTypeInterface> pluginType, Object object, Class<T> classType) throws KettlePluginException
Load the class of the type specified for the plugin that owns the class of the specified object.- Parameters:
pluginType
- the type of pluginobject
- The object for which we want to search the class to find the pluginclassType
- The type of class to load- Returns:
- the instantiated class.
- Throws:
KettlePluginException
-
loadClass
public <T> T loadClass(Class<? extends PluginTypeInterface> pluginType, String pluginId, Class<T> classType) throws KettlePluginException
Load the class of the type specified for the plugin with the ID specified.- Parameters:
pluginType
- the type of pluginpluginId
- The plugin id to useclassType
- The type of class to load- Returns:
- the instantiated class.
- Throws:
KettlePluginException
-
addClassFactory
public <T> void addClassFactory(Class<? extends PluginTypeInterface> pluginType, Class<T> tClass, String id, Callable<T> callable) throws KettlePluginException
Add a Class Mapping + factory for a plugin. This allows extra classes to be added to existing plugins.- Type Parameters:
T
- Type of the object factoried- Parameters:
pluginType
- Type of plugintClass
- Class to factoryid
- ID of the plugin to extendcallable
- Factory Callable- Throws:
KettlePluginException
-
loadClass
public <T> T loadClass(PluginInterface plugin, Class<T> pluginClass) throws KettlePluginException
Load and instantiate the plugin class specified- Parameters:
plugin
- the plugin to loadpluginClass
- the class to be loaded- Returns:
- The instantiated class
- Throws:
KettlePluginException
- In case there was a class loading problem somehow
-
addPluginType
public static void addPluginType(PluginTypeInterface type)
Add a PluginType to be managed by the registry- Parameters:
type
-
-
getAddedPluginTypes
public static List<PluginTypeInterface> getAddedPluginTypes()
Added so we can tell when types have been added (but not necessarily registered)- Returns:
- the list of added plugin types
-
init
public static void init() throws KettlePluginException
- Throws:
KettlePluginException
-
init
public static void init(boolean keepCache) throws KettlePluginException
This method registers plugin types and loads their respective plugins- Throws:
KettlePluginException
-
getPluginId
public String getPluginId(Object pluginClass)
Find the plugin ID based on the class- Parameters:
pluginClass
-- Returns:
- The ID of the plugin to which this class belongs (checks the plugin class maps)
-
getPluginId
public String getPluginId(Class<? extends PluginTypeInterface> pluginType, Object pluginClass)
Find the plugin ID based on the class- Parameters:
pluginType
- the type of pluginpluginClass
- The class to look for- Returns:
- The ID of the plugin to which this class belongs (checks the plugin class maps) or null if nothing was found.
-
getPlugin
public PluginInterface getPlugin(Class<? extends PluginTypeInterface> pluginType, Object pluginClass)
Retrieve the Plugin for a given class- Parameters:
pluginType
- The type of plugin to search forpluginClass
- The class of this object is used to look around- Returns:
- the plugin or null if nothing could be found
-
findPluginWithName
public PluginInterface findPluginWithName(Class<? extends PluginTypeInterface> pluginType, String pluginName)
Find the plugin ID based on the name of the plugin- Parameters:
pluginType
- the type of pluginpluginName
- The name to look for- Returns:
- The plugin with the specified name or null if nothing was found.
-
findPluginWithDescription
public PluginInterface findPluginWithDescription(Class<? extends PluginTypeInterface> pluginType, String pluginDescription)
Find the plugin ID based on the description of the plugin- Parameters:
pluginType
- the type of pluginpluginDescription
- The description to look for- Returns:
- The plugin with the specified description or null if nothing was found.
-
findPluginWithId
public PluginInterface findPluginWithId(Class<? extends PluginTypeInterface> pluginType, String pluginId)
Find the plugin ID based on the name of the plugin- Parameters:
pluginType
- the type of pluginpluginId
- The name to look for- Returns:
- The plugin with the specified name or null if nothing was found.
-
getPluginPackages
public List<String> getPluginPackages(Class<? extends PluginTypeInterface> pluginType)
- Returns:
- a unique list of all the step plugin package names
-
getPluginInformation
public RowBuffer getPluginInformation(Class<? extends PluginTypeInterface> pluginType) throws KettlePluginException
- Parameters:
pluginType
- the type of plugin to get information for- Returns:
- a row buffer containing plugin information for the given plugin type
- Throws:
KettlePluginException
-
getClass
public <T> T getClass(PluginInterface plugin, String className) throws KettlePluginException
Load the class with a certain name using the class loader of certain plugin.- Parameters:
plugin
- The plugin for which we want to use the class loaderclassName
- The name of the class to load- Returns:
- the name of the class
- Throws:
KettlePluginException
- In case there is something wrong
-
getClass
public <T> T getClass(PluginInterface plugin, T classType) throws KettlePluginException
Load the class with a certain name using the class loader of certain plugin.- Parameters:
plugin
- The plugin for which we want to use the class loaderclassType
- The type of class to load- Returns:
- the name of the class
- Throws:
KettlePluginException
- In case there is something wrong
-
getClassLoader
public ClassLoader getClassLoader(PluginInterface plugin) throws KettlePluginException
Create or retrieve the class loader for the specified plugin- Parameters:
plugin
- the plugin to use- Returns:
- The class loader
- Throws:
KettlePluginException
- In case there was a problem getClassLoader();
-
addPluginListener
public <T extends PluginTypeInterface> void addPluginListener(Class<T> typeToTrack, PluginTypeListener listener)
Allows the tracking of plugins as they come and go.- Type Parameters:
T
- extension of PluginTypeInterface- Parameters:
typeToTrack
- extension of PluginTypeInterface to track.listener
- receives notification when a plugin of the specified type is added/removed/modified
-
addClassLoader
public void addClassLoader(URLClassLoader ucl, PluginInterface plugin)
-
getPluginType
public PluginTypeInterface getPluginType(Class<? extends PluginTypeInterface> pluginTypeClass) throws KettlePluginException
- Throws:
KettlePluginException
-
findPluginsByFolder
public List<PluginInterface> findPluginsByFolder(URL folder)
-
reset
public void reset()
-
findPluginWithId
public PluginInterface findPluginWithId(Class<? extends PluginTypeInterface> pluginType, String pluginId, boolean waitForPluginToBeAvailable)
-
-