Package weka.core
Class PluginManager
java.lang.Object
weka.core.PluginManager
Class that manages a global map of plugins. Provides static methods for
registering and instantiating plugins. The package manager looks for, and
processes, a PluginManager.props file in the top-level of a package.
- Version:
- $Revision: 12312 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addFromProperties
(File propsFile) Add all key value pairs from the supplied property filestatic void
addFromProperties
(File propsFile, boolean maintainInsertionOrder) Add all key value pairs from the supplied property filestatic void
addFromProperties
(InputStream propsStream) Add all key value pairs from the supplied properties streamstatic void
addFromProperties
(InputStream propsStream, boolean maintainInsertionOrder) Add all key value pairs from the supplied properties streamstatic void
addFromProperties
(String packageName, File propsFile) Add all key value pairs from the supplied property filestatic void
addFromProperties
(String packageName, File propsFile, boolean maintainInsertionOrder) Add all key value pairs from the supplied property filestatic void
addFromProperties
(String packageName, InputStream propsStream) Add all key value pairs from the supplied properties streamstatic void
addFromProperties
(String packageName, InputStream propsStream, boolean maintainInsertionOrder) Add all key value pairs from the supplied properties streamstatic void
addFromProperties
(String packageName, Properties props) Add all key value pairs from the supplied properties objectstatic void
addFromProperties
(String packageName, Properties props, boolean maintainInsertionOrder) Add all key value pairs from the supplied properties objectstatic void
addFromProperties
(Properties props) Add all key value pairs from the supplied properties objectstatic void
addFromProperties
(Properties props, boolean maintainInsertionOrder) Add all key value pairs from the supplied properties objectstatic void
Add a plugin.static void
Add a plugin.static void
addPluginResource
(String resourceGroupID, String resourceDescription, String resourcePath) Add a resource.static void
addPluginResource
(String packageName, String resourceGroupID, String resourceDescription, String resourcePath) Add a resource.static void
addPluginResourcesFromProperty
(String resourceList) Add resources from a list.static void
addToDisabledList
(String classname) Add the supplied fully qualified class name to the list of disabled pluginsstatic void
addToDisabledList
(List<String> classnames) Add the supplied list of fully qualified class names to the disabled liststatic Object
getPluginInstance
(String interfaceType, String name) Get an instance of a concrete implementation of a plugin typegetPluginNamesOfType
(String interfaceName) Get a set of names of plugins that implement the supplied interface.getPluginNamesOfTypeList
(String interfaceName) Get a sorted list of names of plugins that implement the supplied interface.static InputStream
getPluginResourceAsStream
(String resourceGroupID, String resourceDescription) Get an input stream for a named resource under a given resource group ID.getResourcesWithGroupID
(String resourceGroupID) Get a map of resources (description,path) registered under a given resource group ID.static boolean
isInDisabledList
(String classname) Returns true if the supplied fully qualified class name is in the disabled liststatic int
numResourcesForWithGroupID
(String resourceGroupID) Get the number of resources available under a given resource group ID.static boolean
pluginRegistered
(String interfaceType, String name) Checks if a named plugin exists in the map of registered pluginsstatic void
removeFromDisabledList
(String classname) Remove the supplied fully qualified class name from the list of disabled pluginsstatic void
removeFromDisabledList
(List<String> classnames) Remove the supplied list of fully qualified class names to the disabled liststatic void
removePlugin
(String interfaceName, String name) Remove a plugin.static void
removePlugins
(String interfaceName, List<String> names) Remove plugins of a specific type.
-
Constructor Details
-
PluginManager
public PluginManager()
-
-
Method Details
-
addToDisabledList
Add the supplied list of fully qualified class names to the disabled list- Parameters:
classnames
- a list of class names to add
-
addToDisabledList
Add the supplied fully qualified class name to the list of disabled plugins- Parameters:
classname
- the fully qualified name of a class to add
-
removeFromDisabledList
Remove the supplied list of fully qualified class names to the disabled list- Parameters:
classnames
- a list of class names to remove
-
removeFromDisabledList
Remove the supplied fully qualified class name from the list of disabled plugins- Parameters:
classname
- the fully qualified name of a class to remove
-
isInDisabledList
Returns true if the supplied fully qualified class name is in the disabled list- Parameters:
classname
- the name of the class to check- Returns:
- true if the supplied class name is in the disabled list
-
addFromProperties
Add all key value pairs from the supplied property file- Parameters:
propsFile
- the properties file to add- Throws:
Exception
- if a problem occurs
-
addFromProperties
Add all key value pairs from the supplied property file- Parameters:
packageName
- the name of the Weka package that owns this properties object. Can be null if not owned by a Weka packagepropsFile
- the properties file to add- Throws:
Exception
- if a problem occurs
-
addFromProperties
public static void addFromProperties(File propsFile, boolean maintainInsertionOrder) throws Exception Add all key value pairs from the supplied property file- Parameters:
propsFile
- the properties file to addmaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)- Throws:
Exception
- if a problem occurs
-
addFromProperties
public static void addFromProperties(String packageName, File propsFile, boolean maintainInsertionOrder) throws Exception Add all key value pairs from the supplied property file- Parameters:
packageName
- the name of the Weka package that owns this properties object. Can be null if not owned by a Weka packagepropsFile
- the properties file to addmaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)- Throws:
Exception
- if a problem occurs
-
addFromProperties
Add all key value pairs from the supplied properties stream- Parameters:
propsStream
- an input stream to a properties file- Throws:
Exception
- if a problem occurs
-
addFromProperties
Add all key value pairs from the supplied properties stream- Parameters:
packageName
- the name of the Weka package that owns this properties object. Can be null if not owned by a Weka packagepropsStream
- an input stream to a properties file- Throws:
Exception
- if a problem occurs
-
addFromProperties
public static void addFromProperties(InputStream propsStream, boolean maintainInsertionOrder) throws Exception Add all key value pairs from the supplied properties stream- Parameters:
propsStream
- an input stream to a properties filemaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)- Throws:
Exception
- if a problem occurs
-
addFromProperties
public static void addFromProperties(String packageName, InputStream propsStream, boolean maintainInsertionOrder) throws Exception Add all key value pairs from the supplied properties stream- Parameters:
packageName
- the name of the Weka package that owns this properties object. Can be null if not owned by a Weka packagepropsStream
- an input stream to a properties filemaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)- Throws:
Exception
- if a problem occurs
-
addFromProperties
Add all key value pairs from the supplied properties object- Parameters:
props
- a Properties object- Throws:
Exception
- if a problem occurs
-
addFromProperties
Add all key value pairs from the supplied properties object- Parameters:
packageName
- the name of the Weka package that owns this properties object. Can be null if not owned by a Weka packageprops
- a Properties object- Throws:
Exception
- if a problem occurs
-
addFromProperties
public static void addFromProperties(Properties props, boolean maintainInsertionOrder) throws Exception Add all key value pairs from the supplied properties object- Parameters:
props
- a Properties objectmaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)- Throws:
Exception
- if a problem occurs
-
addFromProperties
public static void addFromProperties(String packageName, Properties props, boolean maintainInsertionOrder) throws Exception Add all key value pairs from the supplied properties object- Parameters:
packageName
- the name of the Weka package that owns this properties object. Can be null if not owned by a Weka packageprops
- a Properties objectmaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)- Throws:
Exception
- if a problem occurs
-
addPluginResourcesFromProperty
Add resources from a list. String format for a list of resources (as might be supplied from a *resources* entry in an property file:
[groupID|description|path],[groupID|description|path],...
- Parameters:
resourceList
- a list of resources to add
-
addPluginResource
public static void addPluginResource(String resourceGroupID, String resourceDescription, String resourcePath) Add a resource.- Parameters:
resourceGroupID
- the ID of the group under which the resource should be storedresourceDescription
- the description/ID of the resourceresourcePath
- the path to the resource
-
addPluginResource
public static void addPluginResource(String packageName, String resourceGroupID, String resourceDescription, String resourcePath) Add a resource.- Parameters:
packageName
- the name of the package that owns this resource. Can be null if not owned by a package, in which case the current classloader will be used to load the resource.resourceGroupID
- the ID of the group under which the resource should be storedresourceDescription
- the description/ID of the resourceresourcePath
- the path to the resource
-
getPluginResourceAsStream
public static InputStream getPluginResourceAsStream(String resourceGroupID, String resourceDescription) throws IOException Get an input stream for a named resource under a given resource group ID.- Parameters:
resourceGroupID
- the group ID that the resource falls underresourceDescription
- the description/ID of the resource- Returns:
- an InputStream for the resource
- Throws:
IOException
- if the group ID or resource description/ID are not known to the PluginManager, or a problem occurs while trying to open an input stream
-
numResourcesForWithGroupID
Get the number of resources available under a given resource group ID.- Parameters:
resourceGroupID
- the group ID of the resources- Returns:
- the number of resources registered under the supplied group ID
-
getResourcesWithGroupID
Get a map of resources (description,path) registered under a given resource group ID.- Parameters:
resourceGroupID
- the group ID of the resources to get- Returns:
- a map of resources registered under the supplied group ID, or null if the resourceGroupID is not known to the plugin manager
-
getPluginNamesOfType
Get a set of names of plugins that implement the supplied interface.- Parameters:
interfaceName
- the fully qualified name of the interface to list plugins for- Returns:
- a set of names of plugins
-
getPluginNamesOfTypeList
Get a sorted list of names of plugins that implement the supplied interface.- Parameters:
interfaceName
- the fully qualified name of the interface to list plugins for- Returns:
- a set of names of plugins
-
addPlugin
Add a plugin.- Parameters:
interfaceName
- the fully qualified interface name that the plugin implementsname
- the name/short description of the pluginconcreteType
- the fully qualified class name of the actual concrete implementation
-
addPlugin
public static void addPlugin(String interfaceName, String name, String concreteType, boolean maintainInsertionOrder) Add a plugin.- Parameters:
interfaceName
- the fully qualified interface name that the plugin implementsname
- the name/short description of the pluginconcreteType
- the fully qualified class name of the actual concrete implementationmaintainInsertionOrder
- true if the order of insertion of implementations is to be preserved (rather than sorted order)
-
removePlugins
Remove plugins of a specific type.- Parameters:
interfaceName
- the fully qualified interface name that the plugins to be remove implementnames
- a list of named plugins to remove
-
removePlugin
Remove a plugin.- Parameters:
interfaceName
- the fully qualified interface name that the plugin implementsname
- the name/short description of the plugin
-
pluginRegistered
Checks if a named plugin exists in the map of registered plugins- Parameters:
interfaceType
- the fully qualified interface name of the plugin typename
- the name/short description of the plugin to get- Returns:
- true if the named plugin exists
-
getPluginInstance
Get an instance of a concrete implementation of a plugin type- Parameters:
interfaceType
- the fully qualified interface name of the plugin typename
- the name/short description of the plugin to get- Returns:
- the concrete plugin or null if the plugin is disabled
- Throws:
Exception
- if the plugin can't be found or instantiated
-