Package org.datanucleus.plugin
Class PluginManager
java.lang.Object
org.datanucleus.plugin.PluginManager
Manages the registry of Extensions and Extension Points for the plugin mechanism.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Comparator for comparing ConfigurationElements by their priority attribute. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPluginManager
(String registryClassName, ClassLoaderResolver clr, Properties props) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreateExecutableExtension
(String extensionPoint, String[] discrimAttrName, String[] discrimAttrValue, String attributeName, Class[] argsClass, Object[] args) Convenience accessor for getting the Class of an attribute for an extension (of an extension point).createExecutableExtension
(String extensionPoint, String discrimAttrName, String discrimAttrValue, String attributeName, Class[] argsClass, Object[] args) Convenience accessor for getting the Class of an attribute for an extension (of an extension point).static PluginManager
createPluginManager
(Map props, ClassLoader loader) Convenience method that will create and return a PluginManager using any passed in properties.getAttributeValueForExtension
(String extensionPoint, String[] discrimAttrName, String[] discrimAttrValue, String attributeName) Convenience accessor for getting the value of an attribute for an extension (of an extension point).getAttributeValueForExtension
(String extensionPoint, String discrimAttrName, String discrimAttrValue, String attributeName) Convenience accessor for getting the value of an attribute for an extension (of an extension point).String[]
getAttributeValuesForExtension
(String extensionPoint, String discrimAttrName, String discrimAttrValue, String attributeName) Convenience accessor for getting the value of an attribute for an extension (of an extension point).getConfigurationElementForExtension
(String extensionPointName, String[] discrimAttrName, String[] discrimAttrValue) Convenience accessor for getting the ConfigurationElement for an extension (of an extension point).getConfigurationElementForExtension
(String extensionPointName, String discrimAttrName, String discrimAttrValue) Convenience accessor for getting the (first) ConfigurationElement for an extension (of an extension point).private List
<ConfigurationElement> getConfigurationElementsForExtension
(String extensionPointName, String[] discrimAttrName, String[] discrimAttrValue) Internal accessor for getting getting the ConfigurationElement(s) for an extension (of an extension point), sorted by their priority attribute (if defined).getConfigurationElementsForExtension
(String extensionPointName, String discrimAttrName, String discrimAttrValue) Convenience accessor for getting the ConfigurationElement(s) for an extension (of an extension point).Acessor for the ExtensionPointAccessor for the PluginRegistry class name.getVersionForBundle
(String bundleName) Accessor for the version of a particular bundle (or null if not registered).Loads a class (do not initialize)resolveURLAsFileURL
(URL url) Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.
-
Field Details
-
registry
-
-
Constructor Details
-
PluginManager
Constructor.- Parameters:
registryClassName
- Name of the registryclr
- the ClassLoaderResolverprops
- Configuration properties for the plugin system
-
-
Method Details
-
getRegistryClassName
Accessor for the PluginRegistry class name.- Returns:
- Name of the plugin registry
-
getExtensionPoint
Acessor for the ExtensionPoint- Parameters:
id
- the unique id of the extension point- Returns:
- null if the ExtensionPoint is not registered
-
getConfigurationElementForExtension
public ConfigurationElement getConfigurationElementForExtension(String extensionPointName, String discrimAttrName, String discrimAttrValue) Convenience accessor for getting the (first) ConfigurationElement for an extension (of an extension point).- Parameters:
extensionPointName
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminatordiscrimAttrValue
- Value for discriminator attribute- Returns:
- The configuration element
-
getConfigurationElementsForExtension
public ConfigurationElement[] getConfigurationElementsForExtension(String extensionPointName, String discrimAttrName, String discrimAttrValue) Convenience accessor for getting the ConfigurationElement(s) for an extension (of an extension point).- Parameters:
extensionPointName
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminatordiscrimAttrValue
- Value for discriminator attribute- Returns:
- Configuration elements
-
getConfigurationElementForExtension
public ConfigurationElement getConfigurationElementForExtension(String extensionPointName, String[] discrimAttrName, String[] discrimAttrValue) Convenience accessor for getting the ConfigurationElement for an extension (of an extension point).- Parameters:
extensionPointName
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminator1discrimAttrValue
- Value for discriminator1 attribute- Returns:
- Configuration Element
-
getConfigurationElementsForExtension
private List<ConfigurationElement> getConfigurationElementsForExtension(String extensionPointName, String[] discrimAttrName, String[] discrimAttrValue) Internal accessor for getting getting the ConfigurationElement(s) for an extension (of an extension point), sorted by their priority attribute (if defined).- Parameters:
extensionPointName
- The extension pointdiscrimAttrName
- Attributes on the exension to use as discriminatordiscrimAttrValue
- Values for discriminator attributes- Returns:
- Configuration elements
-
getAttributeValueForExtension
public String getAttributeValueForExtension(String extensionPoint, String discrimAttrName, String discrimAttrValue, String attributeName) Convenience accessor for getting the value of an attribute for an extension (of an extension point).- Parameters:
extensionPoint
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminatordiscrimAttrValue
- Value for discriminator attributeattributeName
- Name of the attribute whose value we want- Returns:
- The value of the attribute
-
getAttributeValuesForExtension
public String[] getAttributeValuesForExtension(String extensionPoint, String discrimAttrName, String discrimAttrValue, String attributeName) Convenience accessor for getting the value of an attribute for an extension (of an extension point).- Parameters:
extensionPoint
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminatordiscrimAttrValue
- Value for discriminator attributeattributeName
- Name of the attribute whose value we want- Returns:
- The value(s) of the attribute
-
getAttributeValueForExtension
public String getAttributeValueForExtension(String extensionPoint, String[] discrimAttrName, String[] discrimAttrValue, String attributeName) Convenience accessor for getting the value of an attribute for an extension (of an extension point).- Parameters:
extensionPoint
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminator1discrimAttrValue
- Value for discriminator1 attributeattributeName
- Name of the attribute whose value we want- Returns:
- The value of the attribute
-
createExecutableExtension
public Object createExecutableExtension(String extensionPoint, String discrimAttrName, String discrimAttrValue, String attributeName, Class[] argsClass, Object[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Convenience accessor for getting the Class of an attribute for an extension (of an extension point).- Parameters:
extensionPoint
- The extension pointdiscrimAttrName
- Attribute on the extension to use as discriminatordiscrimAttrValue
- Value for discriminator attributeattributeName
- Name of the attribute whose value we wantargsClass
- Classes of the argumentsargs
- The arguments- Returns:
- The value of the attribute
- Throws:
ClassNotFoundException
- if an error occursNoSuchMethodException
- if an error occursInstantiationException
- if an error occursIllegalAccessException
- if an error occursInvocationTargetException
- if an error occurs
-
createExecutableExtension
public Object createExecutableExtension(String extensionPoint, String[] discrimAttrName, String[] discrimAttrValue, String attributeName, Class[] argsClass, Object[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Convenience accessor for getting the Class of an attribute for an extension (of an extension point).- Parameters:
extensionPoint
- The extension pointdiscrimAttrName
- First attribute on the extension to use as discriminatordiscrimAttrValue
- Value for first discriminator attributeattributeName
- Name of the attribute whose value we wantargsClass
- Classes of the argumentsargs
- The arguments- Returns:
- The value of the attribute
- Throws:
ClassNotFoundException
- if an error occursNoSuchMethodException
- if an error occursInstantiationException
- if an error occursIllegalAccessException
- if an error occursInvocationTargetException
- if an error occurs
-
loadClass
Loads a class (do not initialize)- Parameters:
pluginId
- the plugin idclassName
- the class name- Returns:
- the Class
- Throws:
ClassNotResolvedException
- if an error occurs
-
resolveURLAsFileURL
Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.- Parameters:
url
- the url to be converted- Returns:
- the converted URL
- Throws:
IOException
- if an error occurs
-
getVersionForBundle
Accessor for the version of a particular bundle (or null if not registered).- Parameters:
bundleName
- Name of the bundle- Returns:
- The version
-
createPluginManager
Convenience method that will create and return a PluginManager using any passed in properties. Supports the following properties- datanucleus.primaryClassLoader
- datanucleus.plugin.pluginRegistryClassName
- datanucleus.plugin.pluginRegistryBundleCheck
- datanucleus.plugin.allowUserBundles
- datanucleus.plugin.validatePlugins
- Parameters:
props
- Any properties defining the plugin manager capabilitiesloader
- Any class loader to make use of when loading- Returns:
- The PluginManager
-