Package org.datanucleus.plugin
Class NonManagedPluginRegistry
- java.lang.Object
-
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classNonManagedPluginRegistry.ExtensionSorterSorter for extensions that puts DataNucleus extensions first, then any vendor extension.
-
Field Summary
Fields Modifier and Type Field Description private booleanallowUserBundlesWhether to load up any user (third-party) bundles.private java.lang.StringbundleCheckTypeType of check on bundles (EXCEPTION, LOG, NONE).private ClassLoaderResolverclrClassLoaderResolver corresponding to the persistence context.private static java.lang.StringDATANUCLEUS_PKGDataNucleus package to define whether to check for deps, etc.(package private) ExtensionPoint[]extensionPointsextension points(package private) java.util.Map<java.lang.String,ExtensionPoint>extensionPointsByUniqueIdextension points keyed by Unique Id (plugin.id +"."+ id)private static charJAR_SEPARATORCharacter 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.mfprivate static java.io.FilenameFilterMANIFEST_FILE_FILTERfilters all accepted manifest file namesprivate static java.lang.StringPLUGIN_DIRdirectories that are searched for plugin files(package private) java.util.Map<java.lang.String,Bundle>registeredPluginByPluginIdregistered bundles files keyed by bundle symbolic name
-
Constructor Summary
Constructors Constructor Description NonManagedPluginRegistry(ClassLoaderResolver clr, java.lang.String bundleCheckType, boolean allowUserBundles)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcreateExecutableExtension(ConfigurationElement confElm, java.lang.String name, java.lang.Class[] argTypes, java.lang.Object[] args)Loads a class (do not initialize) from an attribute ofConfigurationElementBundle[]getBundles()Accessor for all registered bundlesExtensionPointgetExtensionPoint(java.lang.String id)Acessor for the ExtensionPointExtensionPoint[]getExtensionPoints()Acessor for the currently registed ExtensionPointsprivate java.net.URLgetManifestURL(java.net.URL pluginURL)Get the URL to the "manifest.mf" file relative to the plugin URL ($pluginurl/meta-inf/manifest.mf)private booleanisVersionInInterval(java.lang.String version, java.lang.String interval)Check if the version is in intervaljava.lang.ClassloadClass(java.lang.String pluginId, java.lang.String className)Loads a class (do not initialize)protected BundleregisterBundle(java.net.URL manifest)Register the plugin bundle.protected BundleregisterBundle(java.util.jar.Manifest mf, java.net.URL manifest)Register the plugin bundle.voidregisterExtensionPoints()Look for Bundles/Plugins and register them.protected voidregisterExtensionPointsForPluginInternal(java.util.List<ExtensionPoint> extPoints, boolean updateExtensionPointsArray)Register extension-points for the specified plugin.voidregisterExtensions()Look for Bundles/Plugins and register them.voidregisterExtensionsForPlugin(java.net.URL pluginURL, Bundle bundle)Register extension and extension points for the specified plugin.voidresolveConstraints()Resolve constraints declared in bundle manifest.mf files.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
-
DATANUCLEUS_PKG
private static final java.lang.String DATANUCLEUS_PKG
DataNucleus package to define whether to check for deps, etc.- See Also:
- Constant Field Values
-
PLUGIN_DIR
private static final java.lang.String PLUGIN_DIR
directories that are searched for plugin files- See Also:
- Constant Field Values
-
MANIFEST_FILE_FILTER
private static final java.io.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:
- Constant Field Values
-
clr
private final ClassLoaderResolver clr
ClassLoaderResolver corresponding to the persistence context.
-
extensionPointsByUniqueId
java.util.Map<java.lang.String,ExtensionPoint> extensionPointsByUniqueId
extension points keyed by Unique Id (plugin.id +"."+ id)
-
registeredPluginByPluginId
java.util.Map<java.lang.String,Bundle> registeredPluginByPluginId
registered bundles files keyed by bundle symbolic name
-
extensionPoints
ExtensionPoint[] extensionPoints
extension points
-
bundleCheckType
private java.lang.String bundleCheckType
Type of check on bundles (EXCEPTION, LOG, NONE).
-
allowUserBundles
private boolean allowUserBundles
Whether to load up any user (third-party) bundles.
-
-
Constructor Detail
-
NonManagedPluginRegistry
public NonManagedPluginRegistry(ClassLoaderResolver clr, java.lang.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(java.lang.String id)
Description copied from interface:PluginRegistryAcessor for the ExtensionPoint- Specified by:
getExtensionPointin interfacePluginRegistry- 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:PluginRegistryAcessor for the currently registed ExtensionPoints- Specified by:
getExtensionPointsin interfacePluginRegistry- Returns:
- array of ExtensionPoints
-
registerExtensionPoints
public void registerExtensionPoints()
Description copied from interface:PluginRegistryLook for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml files- Specified by:
registerExtensionPointsin interfacePluginRegistry
-
registerExtensions
public void registerExtensions()
Description copied from interface:PluginRegistryLook for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml files- Specified by:
registerExtensionsin interfacePluginRegistry
-
registerExtensionPointsForPluginInternal
protected void registerExtensionPointsForPluginInternal(java.util.List<ExtensionPoint> 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(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 Manifestmanifest- the url to the "meta-inf/manifest.mf" file or a jar file- Returns:
- the Plugin
-
getManifestURL
private java.net.URL getManifestURL(java.net.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 java.lang.Object createExecutableExtension(ConfigurationElement confElm, java.lang.String name, java.lang.Class[] argTypes, java.lang.Object[] args) throws java.lang.ClassNotFoundException, java.lang.SecurityException
Description copied from interface:PluginRegistryLoads a class (do not initialize) from an attribute ofConfigurationElement- Specified by:
createExecutableExtensionin interfacePluginRegistry- Parameters:
confElm- the configuration elementname- the attribute nameargTypes- Types of the constructor argumentsargs- The arguments- Returns:
- the instance
- Throws:
java.lang.ClassNotFoundException- If an error occursjava.lang.SecurityException- If an error occurs
-
loadClass
public java.lang.Class loadClass(java.lang.String pluginId, java.lang.String className) throws java.lang.ClassNotFoundExceptionDescription copied from interface:PluginRegistryLoads a class (do not initialize)- Specified by:
loadClassin interfacePluginRegistry- Parameters:
pluginId- the plugin idclassName- the class name- Returns:
- the Class
- Throws:
java.lang.ClassNotFoundException- if an error occurs in loading
-
resolveURLAsFileURL
public java.net.URL resolveURLAsFileURL(java.net.URL url) throws java.io.IOExceptionDescription copied from interface:PluginRegistryConverts a URL that uses a user-defined protocol into a URL that uses the file protocol.- Specified by:
resolveURLAsFileURLin interfacePluginRegistry- Parameters:
url- the url to be converted- Returns:
- the converted URL
- Throws:
java.io.IOException- if an error occurs
-
resolveConstraints
public void resolveConstraints()
Description copied from interface:PluginRegistryResolve 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:
resolveConstraintsin interfacePluginRegistry
-
isVersionInInterval
private boolean isVersionInInterval(java.lang.String version, java.lang.String interval)Check if the version is in interval- Parameters:
version- The versioninterval- The interval definition- Returns:
- Whether the version is in this interval
-
getBundles
public Bundle[] getBundles()
Description copied from interface:PluginRegistryAccessor for all registered bundles- Specified by:
getBundlesin interfacePluginRegistry- Returns:
- the bundles
-
registerExtensionsForPlugin
public void registerExtensionsForPlugin(java.net.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 pluginbundle- the bundle
-
-