Package org.datanucleus.plugin
Class OSGiPluginRegistry
- java.lang.Object
-
- org.datanucleus.plugin.OSGiPluginRegistry
-
- All Implemented Interfaces:
PluginRegistry
public class OSGiPluginRegistry extends java.lang.Object implements PluginRegistry
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
OSGiPluginRegistry.ExtensionSorter
Sorter for extensions that puts DataNucleus extensions first, then any vendor extension.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DATANUCLEUS_PKG
DataNucleus package to define whether to check for deps, etc.(package private) ExtensionPoint[]
extensionPoints
extension points(package private) java.util.Map<java.lang.String,ExtensionPoint>
extensionPointsByUniqueId
extension points keyed by Unique Id (plugin.id +"."+ id)(package private) java.util.Map<java.lang.String,Bundle>
registeredPluginByPluginId
registered bundles files keyed by bundle symbolic name
-
Constructor Summary
Constructors Constructor Description OSGiPluginRegistry(ClassLoaderResolver clr)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
createExecutableExtension(ConfigurationElement confElm, java.lang.String name, java.lang.Class[] argTypes, java.lang.Object[] args)
Loads a class (do not initialize) from an attribute ofConfigurationElement
Bundle[]
getBundles()
Accessor for all registered bundlesExtensionPoint
getExtensionPoint(java.lang.String id)
Acessor for the ExtensionPointExtensionPoint[]
getExtensionPoints()
Acessor for the currently registed ExtensionPointsprivate org.osgi.framework.Bundle
getOsgiBundle(java.lang.String symbolicName)
java.lang.Class
loadClass(java.lang.String pluginId, java.lang.String className)
Loads a class (do not initialize)private Bundle
registerBundle(org.osgi.framework.Bundle osgiBundle)
Register the plugin bundle.void
registerExtensionPoints()
Look for Bundles/Plugins and register them.protected void
registerExtensionPointsForPluginInternal(java.util.List<ExtensionPoint> extPoints, boolean updateExtensionPointsArray)
Register extension-points for the specified plugin.void
registerExtensions()
Look for Bundles/Plugins and register them.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.
-
-
-
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
-
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
-
-
Constructor Detail
-
OSGiPluginRegistry
public OSGiPluginRegistry(ClassLoaderResolver clr)
Constructor- Parameters:
clr
- the ClassLoaderResolver
-
-
Method Detail
-
getExtensionPoint
public ExtensionPoint getExtensionPoint(java.lang.String id)
Description copied from interface:PluginRegistry
Acessor for the ExtensionPoint- 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()
Description copied from interface:PluginRegistry
Acessor for the currently registed ExtensionPoints- Specified by:
getExtensionPoints
in interfacePluginRegistry
- 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 interfacePluginRegistry
-
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 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
private Bundle registerBundle(org.osgi.framework.Bundle osgiBundle)
Register the plugin bundle.- Parameters:
osgiBundle
- the OSGi bundle- Returns:
- the Plugin
-
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:PluginRegistry
Loads a class (do not initialize) from an attribute ofConfigurationElement
- Specified by:
createExecutableExtension
in 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.ClassNotFoundException
Description copied from interface:PluginRegistry
Loads a class (do not initialize)- Specified by:
loadClass
in 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.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 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: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 interfacePluginRegistry
-
getBundles
public Bundle[] getBundles()
Description copied from interface:PluginRegistry
Accessor for all registered bundles- Specified by:
getBundles
in interfacePluginRegistry
- Returns:
- the bundles
-
getOsgiBundle
private org.osgi.framework.Bundle getOsgiBundle(java.lang.String symbolicName)
-
-