Class PluginManager


  • public class PluginManager
    extends Object
    Manages the registry of Extensions and Extension Points for the plugin mechanism.
    • Constructor Detail

      • PluginManager

        public PluginManager​(String registryClassName,
                             ClassLoaderResolver clr,
                             Properties props)
        Constructor.
        Parameters:
        registryClassName - Name of the registry
        clr - the ClassLoaderResolver
        props - Configuration properties for the plugin system
    • Method Detail

      • getRegistryClassName

        public String getRegistryClassName()
        Accessor for the PluginRegistry class name.
        Returns:
        Name of the plugin registry
      • getExtensionPoint

        public ExtensionPoint getExtensionPoint​(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​(String extensionPointName,
                                                                        String discrimAttrName,
                                                                        String discrimAttrValue)
        Convenience accessor for getting the (first) ConfigurationElement for an extension (of an extension point).
        Parameters:
        extensionPointName - The extension point
        discrimAttrName - Attribute on the extension to use as discriminator
        discrimAttrValue - 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 point
        discrimAttrName - Attribute on the extension to use as discriminator
        discrimAttrValue - 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 point
        discrimAttrName - Attribute on the extension to use as discriminator1
        discrimAttrValue - Value for discriminator1 attribute
        Returns:
        Configuration Element
      • 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 point
        discrimAttrName - Attribute on the extension to use as discriminator
        discrimAttrValue - Value for discriminator attribute
        attributeName - 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 point
        discrimAttrName - Attribute on the extension to use as discriminator
        discrimAttrValue - Value for discriminator attribute
        attributeName - 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 point
        discrimAttrName - Attribute on the extension to use as discriminator1
        discrimAttrValue - Value for discriminator1 attribute
        attributeName - Name of the attribute whose value we want
        Returns:
        The value of the attribute
      • resolveURLAsFileURL

        public URL resolveURLAsFileURL​(URL url)
                                throws IOException
        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

        public String getVersionForBundle​(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​(Map props,
                                                        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 capabilities
        loader - Any class loader to make use of when loading
        Returns:
        The PluginManager