- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
NonManagedPluginRegistry.ExtensionSorter
Sorter for extensions that puts DataNucleus extensions first, then any vendor extension.
-
Constructor Summary
Constructors Constructor Description NonManagedPluginRegistry(ClassLoaderResolver clr, String bundleCheckType, boolean allowUserBundles)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
createExecutableExtension(ConfigurationElement confElm, String name, Class[] argsClass, Object[] args)
Loads a class (do not initialize) from an attribute ofConfigurationElement
Bundle[]
getBundles()
Accessor for all registered bundlesExtensionPoint
getExtensionPoint(String id)
Accessor for the ExtensionPoint with the specified id.ExtensionPoint[]
getExtensionPoints()
Accessor for the currently registered ExtensionPoints.Class
loadClass(String pluginId, String className)
Loads a class (do not initialize)protected Bundle
registerBundle(URL manifest)
Register the plugin bundle.protected Bundle
registerBundle(Manifest mf, URL manifest)
Register the plugin bundle.void
registerExtensionPoints()
Look for Bundles/Plugins and register them.protected void
registerExtensionPointsForPluginInternal(List extPoints, boolean updateExtensionPointsArray)
Register extension-points for the specified plugin.void
registerExtensions()
Look for Bundles/Plugins and register them.void
registerExtensionsForPlugin(URL pluginURL, Bundle bundle)
Register extension and extension points for the specified plugin.void
resolveConstraints()
Resolve constraints declared in bundle manifest.mf files.URL
resolveURLAsFileURL(URL url)
Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.
-
-
-
Constructor Detail
-
NonManagedPluginRegistry
public NonManagedPluginRegistry(ClassLoaderResolver clr, String bundleCheckType, boolean allowUserBundles)
Constructor.- Parameters:
clr
- the ClassLoaderResolverbundleCheckType
- Type of check on bundles (EXCEPTION, LOG, NONE)allowUserBundles
- Whether to only load DataNucleus bundles (org.datanucleus).
-
-
Method Detail
-
getExtensionPoint
public ExtensionPoint getExtensionPoint(String id)
Accessor for the ExtensionPoint with the specified id.- Specified by:
getExtensionPoint
in interfacePluginRegistry
- 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 interfacePluginRegistry
- 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 interfacePluginRegistry
-
registerExtensionsForPlugin
public void registerExtensionsForPlugin(URL pluginURL, Bundle bundle)
Register extension and extension points for the specified plugin.- Parameters:
pluginURL
- the URL to the pluginbundle
- 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 interfacePluginRegistry
-
registerExtensionPointsForPluginInternal
protected void registerExtensionPointsForPluginInternal(List extPoints, boolean updateExtensionPointsArray)
Register extension-points for the specified plugin.- Parameters:
extPoints
- ExtensionPoints for this pluginupdateExtensionPointsArray
- 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 Manifestmanifest
- the url to the "meta-inf/manifest.mf" file or a jar file- Returns:
- the Plugin
-
createExecutableExtension
public Object createExecutableExtension(ConfigurationElement confElm, String name, Class[] argsClass, Object[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
Loads a class (do not initialize) from an attribute ofConfigurationElement
- Specified by:
createExecutableExtension
in interfacePluginRegistry
- Parameters:
confElm
- the configuration elementname
- the attribute nameargsClass
- Classes of the argsargs
- The arguments- Returns:
- the Class
- Throws:
ClassNotFoundException
- If an error occursSecurityException
- If an error occursNoSuchMethodException
- If an error occursIllegalArgumentException
- If an error occursInstantiationException
- If an error occursIllegalAccessException
- If an error occursInvocationTargetException
- If an error occurs
-
loadClass
public Class loadClass(String pluginId, String className) throws ClassNotFoundException
Loads a class (do not initialize)- Specified by:
loadClass
in interfacePluginRegistry
- Parameters:
pluginId
- the plugin idclassName
- the class name- Returns:
- the Class
- Throws:
ClassNotFoundException
- if an error occurs in loading
-
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.- Specified by:
resolveURLAsFileURL
in interfacePluginRegistry
- Parameters:
url
- the url to be converted- Returns:
- the converted URL
- Throws:
IOException
- if an error occurs
-
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 interfacePluginRegistry
-
getBundles
public Bundle[] getBundles()
Accessor for all registered bundles- Specified by:
getBundles
in interfacePluginRegistry
- Returns:
- the bundles
- Throws:
UnsupportedOperationException
- if this operation is not supported by the implementation
-
-