Class NonManagedPluginRegistry

java.lang.Object
org.datanucleus.plugin.NonManagedPluginRegistry
All Implemented Interfaces:
PluginRegistry

public class NonManagedPluginRegistry extends Object implements PluginRegistry
Manages the registry of Extensions and Extension Points outside any OSGI container. This implementation cannot handle multiple versions of the same plugin, so it either raises an exception or logs the issue as a warning. This is different to that mandated by the OSGi specification 3.0 $3.5.2.
  • Field Details

    • DATANUCLEUS_PKG

      private static final String DATANUCLEUS_PKG
      DataNucleus package to define whether to check for deps, etc.
      See Also:
    • PLUGIN_DIR

      private static final String PLUGIN_DIR
      directories that are searched for plugin files
      See Also:
    • MANIFEST_FILE_FILTER

      private static final FilenameFilter MANIFEST_FILE_FILTER
      filters all accepted manifest file names
    • JAR_SEPARATOR

      private static final char JAR_SEPARATOR
      Character that is used in URLs of jars to separate the file name from the path of a resource inside the jar.
      example: jar:file:foo.jar!/META-INF/manifest.mf
      See Also:
    • clr

      private final ClassLoaderResolver clr
      ClassLoaderResolver corresponding to the persistence context.
    • extensionPointsByUniqueId

      Map<String,ExtensionPoint> extensionPointsByUniqueId
      extension points keyed by Unique Id (plugin.id +"."+ id)
    • registeredPluginByPluginId

      Map<String,Bundle> registeredPluginByPluginId
      registered bundles files keyed by bundle symbolic name
    • extensionPoints

      ExtensionPoint[] extensionPoints
      extension points
    • bundleCheckType

      private String bundleCheckType
      Type of check on bundles (EXCEPTION, LOG, NONE).
    • allowUserBundles

      private boolean allowUserBundles
      Whether to load up any user (third-party) bundles.
  • Constructor Details

    • NonManagedPluginRegistry

      public NonManagedPluginRegistry(ClassLoaderResolver clr, String bundleCheckType, boolean allowUserBundles)
      Constructor.
      Parameters:
      clr - the ClassLoaderResolver
      bundleCheckType - Type of check on bundles (EXCEPTION, LOG, NONE)
      allowUserBundles - Whether to only load DataNucleus bundles (org.datanucleus).
  • Method Details

    • getExtensionPoint

      public ExtensionPoint getExtensionPoint(String id)
      Description copied from interface: PluginRegistry
      Acessor for the ExtensionPoint
      Specified by:
      getExtensionPoint in interface PluginRegistry
      Parameters:
      id - the unique id of the extension point
      Returns:
      null if the ExtensionPoint is not registered
    • getExtensionPoints

      public ExtensionPoint[] getExtensionPoints()
      Description copied from interface: PluginRegistry
      Acessor for the currently registed ExtensionPoints
      Specified by:
      getExtensionPoints in interface PluginRegistry
      Returns:
      array of ExtensionPoints
    • registerExtensionPoints

      public void registerExtensionPoints()
      Description copied from interface: PluginRegistry
      Look for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml files
      Specified by:
      registerExtensionPoints in interface PluginRegistry
    • registerExtensions

      public void registerExtensions()
      Description copied from interface: PluginRegistry
      Look for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml files
      Specified by:
      registerExtensions in interface PluginRegistry
    • registerExtensionPointsForPluginInternal

      protected void registerExtensionPointsForPluginInternal(List<ExtensionPoint> extPoints, boolean updateExtensionPointsArray)
      Register extension-points for the specified plugin.
      Parameters:
      extPoints - ExtensionPoints for this plugin
      updateExtensionPointsArray - Whether to update "extensionPoints" array
    • registerBundle

      protected Bundle registerBundle(URL manifest)
      Register the plugin bundle.
      Parameters:
      manifest - the url to the "meta-inf/manifest.mf" file or a jar file
      Returns:
      the Plugin
    • registerBundle

      protected Bundle registerBundle(Manifest mf, URL manifest)
      Register the plugin bundle.
      Parameters:
      mf - the Manifest
      manifest - the url to the "meta-inf/manifest.mf" file or a jar file
      Returns:
      the Plugin
    • getManifestURL

      private URL getManifestURL(URL pluginURL)
      Get the URL to the "manifest.mf" file relative to the plugin URL ($pluginurl/meta-inf/manifest.mf)
      Parameters:
      pluginURL - the url to the "plugin.xml" file
      Returns:
      a URL to the "manifest.mf" file or a URL for a jar file
    • createExecutableExtension

      public Object createExecutableExtension(ConfigurationElement confElm, String name, Class[] argTypes, Object[] args) throws ClassNotFoundException, SecurityException
      Description copied from interface: PluginRegistry
      Loads a class (do not initialize) from an attribute of ConfigurationElement
      Specified by:
      createExecutableExtension in interface PluginRegistry
      Parameters:
      confElm - the configuration element
      name - the attribute name
      argTypes - Types of the constructor arguments
      args - The arguments
      Returns:
      the instance
      Throws:
      ClassNotFoundException - If an error occurs
      SecurityException - If an error occurs
    • loadClass

      public Class loadClass(String pluginId, String className) throws ClassNotFoundException
      Description copied from interface: PluginRegistry
      Loads a class (do not initialize)
      Specified by:
      loadClass in interface PluginRegistry
      Parameters:
      pluginId - the plugin id
      className - the class name
      Returns:
      the Class
      Throws:
      ClassNotFoundException - if an error occurs in loading
    • resolveURLAsFileURL

      public URL resolveURLAsFileURL(URL url) throws IOException
      Description copied from interface: PluginRegistry
      Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.
      Specified by:
      resolveURLAsFileURL in interface PluginRegistry
      Parameters:
      url - the url to be converted
      Returns:
      the converted URL
      Throws:
      IOException - if an error occurs
    • resolveConstraints

      public void resolveConstraints()
      Description copied from interface: PluginRegistry
      Resolve constraints declared in bundle manifest.mf files. This must be invoked after registering all bundles. Should log errors if bundles are not resolvable, or raise runtime exceptions.
      Specified by:
      resolveConstraints in interface PluginRegistry
    • isVersionInInterval

      private boolean isVersionInInterval(String version, String interval)
      Check if the version is in interval
      Parameters:
      version - The version
      interval - The interval definition
      Returns:
      Whether the version is in this interval
    • getBundles

      public Bundle[] getBundles()
      Description copied from interface: PluginRegistry
      Accessor for all registered bundles
      Specified by:
      getBundles in interface PluginRegistry
      Returns:
      the bundles
    • registerExtensionsForPlugin

      public void registerExtensionsForPlugin(URL pluginURL, Bundle bundle)
      Register extension and extension points for the specified plugin. Note that this is only present for testing purposes, hence also why it is public.
      Parameters:
      pluginURL - the URL to the plugin
      bundle - the bundle