Package org.datanucleus.plugin
Class PluginManager
- java.lang.Object
-
- org.datanucleus.plugin.PluginManager
-
public class PluginManager extends java.lang.ObjectManages the registry of Extensions and Extension Points for the plugin mechanism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPluginManager.ConfigurationElementPriorityComparatorComparator for comparing ConfigurationElements by their priority attribute.
-
Field Summary
Fields Modifier and Type Field Description private PluginRegistryregistry
-
Constructor Summary
Constructors Constructor Description PluginManager(java.lang.String registryClassName, ClassLoaderResolver clr, java.util.Properties props)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcreateExecutableExtension(java.lang.String extensionPoint, java.lang.String[] discrimAttrName, java.lang.String[] discrimAttrValue, java.lang.String attributeName, java.lang.Class[] argsClass, java.lang.Object[] args)Convenience accessor for getting the Class of an attribute for an extension (of an extension point).java.lang.ObjectcreateExecutableExtension(java.lang.String extensionPoint, java.lang.String discrimAttrName, java.lang.String discrimAttrValue, java.lang.String attributeName, java.lang.Class[] argsClass, java.lang.Object[] args)Convenience accessor for getting the Class of an attribute for an extension (of an extension point).static PluginManagercreatePluginManager(java.util.Map props, java.lang.ClassLoader loader)Convenience method that will create and return a PluginManager using any passed in properties.java.lang.StringgetAttributeValueForExtension(java.lang.String extensionPoint, java.lang.String[] discrimAttrName, java.lang.String[] discrimAttrValue, java.lang.String attributeName)Convenience accessor for getting the value of an attribute for an extension (of an extension point).java.lang.StringgetAttributeValueForExtension(java.lang.String extensionPoint, java.lang.String discrimAttrName, java.lang.String discrimAttrValue, java.lang.String attributeName)Convenience accessor for getting the value of an attribute for an extension (of an extension point).java.lang.String[]getAttributeValuesForExtension(java.lang.String extensionPoint, java.lang.String discrimAttrName, java.lang.String discrimAttrValue, java.lang.String attributeName)Convenience accessor for getting the value of an attribute for an extension (of an extension point).ConfigurationElementgetConfigurationElementForExtension(java.lang.String extensionPointName, java.lang.String[] discrimAttrName, java.lang.String[] discrimAttrValue)Convenience accessor for getting the ConfigurationElement for an extension (of an extension point).ConfigurationElementgetConfigurationElementForExtension(java.lang.String extensionPointName, java.lang.String discrimAttrName, java.lang.String discrimAttrValue)Convenience accessor for getting the (first) ConfigurationElement for an extension (of an extension point).private java.util.List<ConfigurationElement>getConfigurationElementsForExtension(java.lang.String extensionPointName, java.lang.String[] discrimAttrName, java.lang.String[] discrimAttrValue)Internal accessor for getting getting the ConfigurationElement(s) for an extension (of an extension point), sorted by their priority attribute (if defined).ConfigurationElement[]getConfigurationElementsForExtension(java.lang.String extensionPointName, java.lang.String discrimAttrName, java.lang.String discrimAttrValue)Convenience accessor for getting the ConfigurationElement(s) for an extension (of an extension point).ExtensionPointgetExtensionPoint(java.lang.String id)Acessor for the ExtensionPointjava.lang.StringgetRegistryClassName()Accessor for the PluginRegistry class name.java.lang.StringgetVersionForBundle(java.lang.String bundleName)Accessor for the version of a particular bundle (or null if not registered).java.lang.ClassloadClass(java.lang.String pluginId, java.lang.String className)Loads a class (do not initialize)java.net.URLresolveURLAsFileURL(java.net.URL url)Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.
-
-
-
Field Detail
-
registry
private PluginRegistry registry
-
-
Constructor Detail
-
PluginManager
public PluginManager(java.lang.String registryClassName, ClassLoaderResolver clr, java.util.Properties props)Constructor.- Parameters:
registryClassName- Name of the registryclr- the ClassLoaderResolverprops- Configuration properties for the plugin system
-
-
Method Detail
-
getRegistryClassName
public java.lang.String getRegistryClassName()
Accessor for the PluginRegistry class name.- Returns:
- Name of the plugin registry
-
getExtensionPoint
public ExtensionPoint getExtensionPoint(java.lang.String id)
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(java.lang.String extensionPointName, java.lang.String discrimAttrName, java.lang.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(java.lang.String extensionPointName, java.lang.String discrimAttrName, java.lang.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(java.lang.String extensionPointName, java.lang.String[] discrimAttrName, java.lang.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 java.util.List<ConfigurationElement> getConfigurationElementsForExtension(java.lang.String extensionPointName, java.lang.String[] discrimAttrName, java.lang.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 java.lang.String getAttributeValueForExtension(java.lang.String extensionPoint, java.lang.String discrimAttrName, java.lang.String discrimAttrValue, java.lang.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 java.lang.String[] getAttributeValuesForExtension(java.lang.String extensionPoint, java.lang.String discrimAttrName, java.lang.String discrimAttrValue, java.lang.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 java.lang.String getAttributeValueForExtension(java.lang.String extensionPoint, java.lang.String[] discrimAttrName, java.lang.String[] discrimAttrValue, java.lang.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 java.lang.Object createExecutableExtension(java.lang.String extensionPoint, java.lang.String discrimAttrName, java.lang.String discrimAttrValue, java.lang.String attributeName, java.lang.Class[] argsClass, java.lang.Object[] args) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionConvenience 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:
java.lang.ClassNotFoundException- if an error occursjava.lang.NoSuchMethodException- if an error occursjava.lang.InstantiationException- if an error occursjava.lang.IllegalAccessException- if an error occursjava.lang.reflect.InvocationTargetException- if an error occurs
-
createExecutableExtension
public java.lang.Object createExecutableExtension(java.lang.String extensionPoint, java.lang.String[] discrimAttrName, java.lang.String[] discrimAttrValue, java.lang.String attributeName, java.lang.Class[] argsClass, java.lang.Object[] args) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionConvenience 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:
java.lang.ClassNotFoundException- if an error occursjava.lang.NoSuchMethodException- if an error occursjava.lang.InstantiationException- if an error occursjava.lang.IllegalAccessException- if an error occursjava.lang.reflect.InvocationTargetException- if an error occurs
-
loadClass
public java.lang.Class loadClass(java.lang.String pluginId, java.lang.String className) throws ClassNotResolvedExceptionLoads a class (do not initialize)- Parameters:
pluginId- the plugin idclassName- the class name- Returns:
- the Class
- Throws:
ClassNotResolvedException- if an error occurs
-
resolveURLAsFileURL
public java.net.URL resolveURLAsFileURL(java.net.URL url) throws java.io.IOExceptionConverts 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:
java.io.IOException- if an error occurs
-
getVersionForBundle
public java.lang.String getVersionForBundle(java.lang.String bundleName)
Accessor for the version of a particular bundle (or null if not registered).- Parameters:
bundleName- Name of the bundle- Returns:
- The version
-
createPluginManager
public static PluginManager createPluginManager(java.util.Map props, java.lang.ClassLoader loader)
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
-
-