org.datanucleus.plugin
Class NonManagedPluginRegistry

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

public class NonManagedPluginRegistry
extends java.lang.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 Summary
protected static Localiser LOCALISER
           
 
Constructor Summary
NonManagedPluginRegistry(ClassLoaderResolver clr, java.lang.String bundleCheckType)
          Constructor.
 
Method Summary
 java.lang.Object createExecutableExtension(ConfigurationElement confElm, java.lang.String name, java.lang.Class[] argsClass, java.lang.Object[] args)
          Loads a class (do not initialize) from an attribute of ConfigurationElement
 Bundle[] getBundles()
          Accessor for all registered bundles
 ExtensionPoint getExtensionPoint(java.lang.String id)
          Accessor for the ExtensionPoint with the specified id.
 ExtensionPoint[] getExtensionPoints()
          Accessor for the currently registered ExtensionPoints.
 java.lang.Class loadClass(java.lang.String pluginId, java.lang.String className)
          Loads a class (do not initialize)
protected  Bundle registerBundle(java.util.jar.Manifest mf, java.net.URL manifest)
          Register the plugin bundle.
protected  Bundle registerBundle(java.net.URL manifest)
          Register the plugin bundle.
 void registerExtensionPoints()
          Look for Bundles/Plugins and register them.
protected  void registerExtensionPointsForPluginInternal(java.util.List extPoints, boolean updateExtensionPointsArray)
          Register extension-points for the specified plugin.
 void registerExtensions()
          Look for Bundles/Plugins and register them.
 void registerExtensionsForPlugin(java.net.URL pluginURL, Bundle bundle)
          Register extension and extension points for the specified plugin.
 void resolveConstraints()
          Resolve constraints declared in bundle manifest.mf files.
 java.net.URL resolveURLAsFileURL(java.net.URL url)
          Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Constructor Detail

NonManagedPluginRegistry

public NonManagedPluginRegistry(ClassLoaderResolver clr,
                                java.lang.String bundleCheckType)
Constructor.

Parameters:
clr - the ClassLoaderResolver
bundleCheckType - Type of check on bundles (EXCEPTION, LOG, NONE)
Method Detail

getExtensionPoint

public ExtensionPoint getExtensionPoint(java.lang.String id)
Accessor for the ExtensionPoint with the specified id.

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()
Accessor for the currently registered ExtensionPoints.

Specified by:
getExtensionPoints in interface PluginRegistry
Returns:
array of ExtensionPoints

registerExtensionPoints

public void registerExtensionPoints()
Look for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml files

Specified by:
registerExtensionPoints in interface PluginRegistry

registerExtensionsForPlugin

public void registerExtensionsForPlugin(java.net.URL pluginURL,
                                        Bundle bundle)
Register extension and extension points for the specified plugin.

Parameters:
pluginURL - the URL to the plugin
bundle - the bundle

registerExtensions

public void registerExtensions()
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(java.util.List 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(java.net.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(java.util.jar.Manifest mf,
                                java.net.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

createExecutableExtension

public java.lang.Object createExecutableExtension(ConfigurationElement confElm,
                                                  java.lang.String name,
                                                  java.lang.Class[] argsClass,
                                                  java.lang.Object[] args)
                                           throws java.lang.ClassNotFoundException,
                                                  java.lang.SecurityException,
                                                  java.lang.NoSuchMethodException,
                                                  java.lang.IllegalArgumentException,
                                                  java.lang.InstantiationException,
                                                  java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException
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
Returns:
the Class
Throws:
java.lang.ClassNotFoundException
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

loadClass

public java.lang.Class loadClass(java.lang.String pluginId,
                                 java.lang.String className)
                          throws java.lang.ClassNotFoundException
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:
java.lang.ClassNotFoundException

resolveURLAsFileURL

public java.net.URL resolveURLAsFileURL(java.net.URL url)
                                 throws java.io.IOException
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:
java.io.IOException

resolveConstraints

public void resolveConstraints()
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

getBundles

public Bundle[] getBundles()
Accessor for all registered bundles

Specified by:
getBundles in interface PluginRegistry
Returns:
the bundles
Throws:
java.lang.UnsupportedOperationException - if this operation is not supported by the implementation


Copyright © 2010. All Rights Reserved.