public class PluginRegistry extends Object
Modifier and Type | Field and Description |
---|---|
static LogChannelInterface |
log |
Modifier and Type | Method and Description |
---|---|
void |
addClassLoader(URLClassLoader ucl,
PluginInterface plugin) |
void |
addParentClassLoaderPatterns(PluginInterface plugin,
String[] patterns) |
<T extends PluginTypeInterface> |
addPluginListener(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 registry
|
List<PluginInterface> |
findPluginsByFolder(URL folder) |
PluginInterface |
findPluginWithDescription(Class<? extends PluginTypeInterface> pluginType,
String pluginDescription)
Find the plugin ID based on the description of the plugin
|
PluginInterface |
findPluginWithId(Class<? extends PluginTypeInterface> pluginType,
String pluginId)
Find the plugin ID based on the name of the plugin
|
PluginInterface |
findPluginWithName(Class<? extends PluginTypeInterface> pluginType,
String pluginName)
Find the plugin ID based on the name of the plugin
|
static 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 plugin
|
static PluginRegistry |
getInstance() |
PluginInterface |
getPlugin(Class<? extends PluginTypeInterface> pluginType,
Object pluginClass)
Retrieve the Plugin for a given class
|
PluginInterface |
getPlugin(Class<? extends PluginTypeInterface> pluginType,
String id)
Get a plugin from the registry
|
String |
getPluginId(Class<? extends PluginTypeInterface> pluginType,
Object pluginClass)
Find the plugin ID based on the class
|
String |
getPluginId(Object pluginClass)
Find the plugin ID based on the class
|
RowBuffer |
getPluginInformation(Class<? extends PluginTypeInterface> pluginType) |
List<String> |
getPluginPackages(Class<? extends PluginTypeInterface> pluginType) |
<T extends PluginInterface,K extends PluginTypeInterface> |
getPlugins(Class<K> type) |
<T extends PluginTypeInterface> |
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 specified
|
void |
registerPlugin(Class<? extends PluginTypeInterface> pluginType,
PluginInterface plugin) |
void |
registerPluginType(Class<? extends PluginTypeInterface> pluginType) |
void |
removePlugin(Class<? extends PluginTypeInterface> pluginType,
PluginInterface plugin) |
public static LogChannelInterface log
public static PluginRegistry getInstance()
public void registerPluginType(Class<? extends PluginTypeInterface> pluginType)
public void removePlugin(Class<? extends PluginTypeInterface> pluginType, PluginInterface plugin)
public void addParentClassLoaderPatterns(PluginInterface plugin, String[] patterns)
public void registerPlugin(Class<? extends PluginTypeInterface> pluginType, PluginInterface plugin) throws KettlePluginException
KettlePluginException
public List<Class<? extends PluginTypeInterface>> getPluginTypes()
public <T extends PluginInterface,K extends PluginTypeInterface> List<T> getPlugins(Class<K> type)
type
- The plugin type to querypublic PluginInterface getPlugin(Class<? extends PluginTypeInterface> pluginType, String id)
stepplugintype
- The type of plugin to look forid
- The ID to scan forpublic <T extends PluginTypeInterface> List<PluginInterface> getPluginsByCategory(Class<T> pluginType, String pluginCategory)
pluginType
- The type of plugins to searchpluginCategory
- The category to look inpublic List<String> getCategories(Class<? extends PluginTypeInterface> pluginType)
pluginType
- The plugin type to search categories for.public Object loadClass(PluginInterface plugin) throws KettlePluginException
plugin
- The plugin to load the main class for.KettlePluginException
- In case there was a loading problem.public <T> T loadClass(Class<? extends PluginTypeInterface> pluginType, Object object, Class<T> classType) throws KettlePluginException
pluginType
- the type of pluginobject
- The object for which we want to search the class to find the pluginclassType
- The type of class to loadKettlePluginException
public <T> T loadClass(Class<? extends PluginTypeInterface> pluginType, String pluginId, Class<T> classType) throws KettlePluginException
pluginType
- the type of pluginplugiId
- The plugin id to useclassType
- The type of class to loadKettlePluginException
public <T> T loadClass(PluginInterface plugin, Class<T> pluginClass) throws KettlePluginException
plugin
- the plugin to loadpluginClass
- the class to be loadedKettlePluginException
- In case there was a class loading problem somehowpublic static void addPluginType(PluginTypeInterface type)
type
- public static List<PluginTypeInterface> getAddedPluginTypes()
public static void init() throws KettlePluginException
KettlePluginException
public static void init(boolean keepCache) throws KettlePluginException
KettlePluginException
public String getPluginId(Object pluginClass)
pluginClass
- public String getPluginId(Class<? extends PluginTypeInterface> pluginType, Object pluginClass)
pluginType
- the type of pluginpluginClass
- The class to look forpublic PluginInterface getPlugin(Class<? extends PluginTypeInterface> pluginType, Object pluginClass)
pluginType
- The type of plugin to search forpluginClass
- The class of this object is used to look aroundpublic PluginInterface findPluginWithName(Class<? extends PluginTypeInterface> pluginType, String pluginName)
pluginType
- the type of pluginpluginName
- The name to look forpublic PluginInterface findPluginWithDescription(Class<? extends PluginTypeInterface> pluginType, String pluginDescription)
pluginType
- the type of pluginpluginDescription
- The description to look forpublic PluginInterface findPluginWithId(Class<? extends PluginTypeInterface> pluginType, String pluginId)
pluginType
- the type of pluginpluginName
- The name to look forpublic List<String> getPluginPackages(Class<? extends PluginTypeInterface> pluginType)
public RowBuffer getPluginInformation(Class<? extends PluginTypeInterface> pluginType) throws KettlePluginException
the
- type of plugin to get information forKettlePluginException
public <T> T getClass(PluginInterface plugin, String className) throws KettlePluginException
plugin
- The plugin for which we want to use the class loaderclassName
- The name of the class to loadKettlePluginException
- In case there is something wrongpublic <T> T getClass(PluginInterface plugin, T classType) throws KettlePluginException
plugin
- The plugin for which we want to use the class loaderclassType
- The type of class to loadKettlePluginException
- In case there is something wrongpublic ClassLoader getClassLoader(PluginInterface plugin) throws KettlePluginException
plugin
- the plugin to useKettlePluginException
- In case there was a problem
TODO: remove the similar code in the loadClass() method above with a call to getClassLoader();public <T extends PluginTypeInterface> void addPluginListener(Class<T> typeToTrack, PluginTypeListener listener)
T
- extension of PluginTypeInterfacetypeToTrack
- extension of PluginTypeInterface to track.listener
- receives notification when a plugin of the specified type is added/removed/modifiedpublic void addClassLoader(URLClassLoader ucl, PluginInterface plugin)
public PluginTypeInterface getPluginType(Class<? extends PluginTypeInterface> pluginTypeClass) throws KettlePluginException
KettlePluginException
public List<PluginInterface> findPluginsByFolder(URL folder)