Package org.java.plugin.registry.xml
Class PluginRegistryImpl
- java.lang.Object
-
- org.java.plugin.registry.xml.PluginRegistryImpl
-
- All Implemented Interfaces:
PluginRegistry
public final class PluginRegistryImpl extends java.lang.Object implements PluginRegistry
This is an implementation of plug-in registry of XML syntax plug-in manifests. Manifests should be prepared according to plug-in DTD.Configuration parameters
This registry implementation supports following configuration parameters:
- isValidating
- Regulates is registry should use validating parser when loading
plug-in manifests. The default parameter value is
true. - stopOnError
- Regulates is registry should stop and throw RuntimeException if an
error occurred while
registeringorun-registeringplug-ins. If this isfalse, the registration errors will be stored in the internal report that is available withPluginRegistry.checkIntegrity(PathResolver)method. The default parameter value isfalse.
- Version:
- $Id: PluginRegistryImpl.java,v 1.6 2007/05/13 16:10:51 ddimon Exp $
- See Also:
ObjectFactory.createRegistry()
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.java.plugin.registry.PluginRegistry
PluginRegistry.RegistryChangeData, PluginRegistry.RegistryChangeListener
-
-
Constructor Summary
Constructors Constructor Description PluginRegistryImpl()Creates plug-in registry object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntegrityCheckReportcheckIntegrity(PathResolver pathResolver)Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.IntegrityCheckReportcheckIntegrity(PathResolver pathResolver, boolean includeRegistrationReport)Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.voidconfigure(ExtendedProperties config)Configures this registry instance.java.lang.StringextractId(java.lang.String uniqueId)Extracts plug-in element ID from some unique identifier.java.lang.StringextractPluginId(java.lang.String uniqueId)Extracts plug-in ID from some unique identifier.VersionextractVersion(java.lang.String uniqueId)Extracts plug-in version identifier from some unique identifier (plug-in or plug-in fragment).java.util.Collection<PluginDescriptor>getDependingPlugins(PluginDescriptor descr)Utility method that recursively collects all plug-ins that depends on the given plug-in.ExtensionPointgetExtensionPoint(java.lang.String uniqueId)Looks for extension point.ExtensionPointgetExtensionPoint(java.lang.String pluginId, java.lang.String pointId)Looks for extension point.PluginDescriptorgetPluginDescriptor(java.lang.String pluginId)Returns descriptor of plug-in with given ID.java.util.Collection<PluginDescriptor>getPluginDescriptors()Returns collection of descriptors of all plug-ins that was successfully populated by this registry.java.util.Collection<PluginFragment>getPluginFragments()Returns collection of descriptors of all plug-in fragments that was successfully populated by this registry.IntegrityCheckReportgetRegistrationReport()booleanisExtensionPointAvailable(java.lang.String uniqueId)Checks if extension point exists and is in valid state.booleanisExtensionPointAvailable(java.lang.String pluginId, java.lang.String pointId)Checks if extension point exists and is in valid state.booleanisPluginDescriptorAvailable(java.lang.String pluginId)Checks if plug-in exists and is in valid state.java.lang.StringmakeUniqueId(java.lang.String pluginId, java.lang.String id)Constructs unique identifier for some plug-in element from it's ID.java.lang.StringmakeUniqueId(java.lang.String pluginId, Version version)Constructs unique identifier for plug-in with given ID.ManifestInforeadManifestInfo(java.net.URL url)Reads basic information from a plug-in or plug-in fragment manifest.java.util.Map<java.lang.String,Identity>register(java.net.URL[] manifests)General algorithm: Collect all currently registered extension points. Parse given URL's as XML content files and separate them on plug-in and plug-in fragment descriptors. Process new plug-in descriptors first: Instantiate new PluginDescriptorImpl object. Handle versions correctly - register new descriptor as most recent version or as an old version. If other versions of the same plug-in already registered, take their fragments and register them with this version. Process new plug-in fragments next: Instantiate new PluginFragmentImpl object. Check if older version of the same fragment already registered.voidregisterListener(PluginRegistry.RegistryChangeListener listener)Registers plug-in registry change event listener.java.util.Collection<java.lang.String>unregister(java.lang.String[] ids)Unregisters plug-ins and plug-in fragments with given ID's (including depending plug-ins and plug-in fragments).voidunregisterListener(PluginRegistry.RegistryChangeListener listener)Unregisters registry change event listener.
-
-
-
Method Detail
-
configure
public void configure(ExtendedProperties config)
Description copied from interface:PluginRegistryConfigures this registry instance. Usually this method is called fromobject factoryimplementation.- Specified by:
configurein interfacePluginRegistry- Parameters:
config- registry configuration data- See Also:
PluginRegistry.configure( ExtendedProperties)
-
readManifestInfo
public ManifestInfo readManifestInfo(java.net.URL url) throws ManifestProcessingException
Description copied from interface:PluginRegistryReads basic information from a plug-in or plug-in fragment manifest.- Specified by:
readManifestInfoin interfacePluginRegistry- Parameters:
url- manifest data URL- Returns:
- manifest info
- Throws:
ManifestProcessingException- if manifest data can't be read- See Also:
PluginRegistry.readManifestInfo( java.net.URL)
-
register
public java.util.Map<java.lang.String,Identity> register(java.net.URL[] manifests) throws ManifestProcessingException
General algorithm:- Collect all currently registered extension points.
- Parse given URL's as XML content files and separate them on plug-in and plug-in fragment descriptors.
- Process new plug-in descriptors first:
- Instantiate new PluginDescriptorImpl object.
- Handle versions correctly - register new descriptor as most recent version or as an old version.
- If other versions of the same plug-in already registered, take their fragments and register them with this version.
- Process new plug-in fragments next:
- Instantiate new PluginFragmentImpl object.
- Check if older version of the same fragment already registered. If yes, un-register it and move to old plug-in fragments collection.
- Register new fragment with all matches plug-in descriptors (if this fragment is of most recent version).
- Notify collected extension points about potential changes in extensions set.
- Propagate events about registry changes.
- Specified by:
registerin interfacePluginRegistry- Parameters:
manifests- array of manifest locations- Returns:
- map where keys are URL's and values are registered plug-ins or plug-in fragments, URL's for unprocessed manifests are not included
- Throws:
ManifestProcessingException- if manifest processing error has occurred (optional behavior)- See Also:
PluginRegistry.register(java.net.URL[])
-
unregister
public java.util.Collection<java.lang.String> unregister(java.lang.String[] ids)
Description copied from interface:PluginRegistryUnregisters plug-ins and plug-in fragments with given ID's (including depending plug-ins and plug-in fragments).- Specified by:
unregisterin interfacePluginRegistry- Parameters:
ids- ID's of plug-ins and plug-in fragments to be unregistered- Returns:
- collection of UID's of actually unregistered plug-ins and plug-in fragments
- See Also:
PluginRegistry.unregister(java.lang.String[])
-
getExtensionPoint
public ExtensionPoint getExtensionPoint(java.lang.String pluginId, java.lang.String pointId)
Description copied from interface:PluginRegistryLooks for extension point. This method have throw anIllegalArgumentExceptionif requested extension point can't be found or is in invalid state.- Specified by:
getExtensionPointin interfacePluginRegistry- Parameters:
pluginId- plug-in IDpointId- extension point ID- Returns:
- plug-in extension point
- See Also:
PluginRegistry.getExtensionPoint( java.lang.String, java.lang.String)
-
getExtensionPoint
public ExtensionPoint getExtensionPoint(java.lang.String uniqueId)
Description copied from interface:PluginRegistryLooks for extension point.- Specified by:
getExtensionPointin interfacePluginRegistry- Parameters:
uniqueId- extension point unique ID- Returns:
- plug-in extension point
- See Also:
PluginRegistry.getExtensionPoint(java.lang.String)
-
isExtensionPointAvailable
public boolean isExtensionPointAvailable(java.lang.String pluginId, java.lang.String pointId)Description copied from interface:PluginRegistryChecks if extension point exists and is in valid state. If this method returnstrue, the methodPluginRegistry.getExtensionPoint(String, String)should always return valid extension point.- Specified by:
isExtensionPointAvailablein interfacePluginRegistry- Parameters:
pluginId- plug-in IDpointId- extension point ID- Returns:
trueif extension point exists and valid- See Also:
PluginRegistry.isExtensionPointAvailable( java.lang.String, java.lang.String)
-
isExtensionPointAvailable
public boolean isExtensionPointAvailable(java.lang.String uniqueId)
Description copied from interface:PluginRegistryChecks if extension point exists and is in valid state.- Specified by:
isExtensionPointAvailablein interfacePluginRegistry- Parameters:
uniqueId- extension point unique ID- Returns:
trueif extension point exists and valid- See Also:
PluginRegistry.isExtensionPointAvailable( java.lang.String)
-
getPluginDescriptor
public PluginDescriptor getPluginDescriptor(java.lang.String pluginId)
Description copied from interface:PluginRegistryReturns descriptor of plug-in with given ID.
If plug-in descriptor with given ID can't be found or such plug-in exists but is damaged this method have to throw anIllegalArgumentException. In other words, this method shouldn't returnnull.- Specified by:
getPluginDescriptorin interfacePluginRegistry- Parameters:
pluginId- plug-id ID- Returns:
- plug-in descriptor
- See Also:
PluginRegistry.getPluginDescriptor(java.lang.String)
-
isPluginDescriptorAvailable
public boolean isPluginDescriptorAvailable(java.lang.String pluginId)
Description copied from interface:PluginRegistryChecks if plug-in exists and is in valid state. If this method returnstrue, the methodPluginRegistry.getPluginDescriptor(String)should always return valid plug-in descriptor.- Specified by:
isPluginDescriptorAvailablein interfacePluginRegistry- Parameters:
pluginId- plug-in ID- Returns:
trueif plug-in exists and valid- See Also:
PluginRegistry.isPluginDescriptorAvailable(java.lang.String)
-
getPluginDescriptors
public java.util.Collection<PluginDescriptor> getPluginDescriptors()
Description copied from interface:PluginRegistryReturns collection of descriptors of all plug-ins that was successfully populated by this registry.- Specified by:
getPluginDescriptorsin interfacePluginRegistry- Returns:
- collection of
PluginDescriptorobjects - See Also:
PluginRegistry.getPluginDescriptors()
-
getPluginFragments
public java.util.Collection<PluginFragment> getPluginFragments()
Description copied from interface:PluginRegistryReturns collection of descriptors of all plug-in fragments that was successfully populated by this registry.- Specified by:
getPluginFragmentsin interfacePluginRegistry- Returns:
- collection of
PluginFragmentobjects - See Also:
PluginRegistry.getPluginFragments()
-
getDependingPlugins
public java.util.Collection<PluginDescriptor> getDependingPlugins(PluginDescriptor descr)
Description copied from interface:PluginRegistryUtility method that recursively collects all plug-ins that depends on the given plug-in.- Specified by:
getDependingPluginsin interfacePluginRegistry- Parameters:
descr- descriptor of plug-in to collect dependencies for- Returns:
- collection of
plug-in descriptorsthat depend on given plug-in - See Also:
PluginRegistry.getDependingPlugins( org.java.plugin.registry.PluginDescriptor)
-
checkIntegrity
public IntegrityCheckReport checkIntegrity(PathResolver pathResolver)
Description copied from interface:PluginRegistryPerforms integrity check of all registered plug-ins and generates result as a collection of standard report items.- Specified by:
checkIntegrityin interfacePluginRegistry- Parameters:
pathResolver- optional path resolver- Returns:
- integrity check report
- See Also:
PluginRegistry.checkIntegrity( org.java.plugin.PathResolver)
-
checkIntegrity
public IntegrityCheckReport checkIntegrity(PathResolver pathResolver, boolean includeRegistrationReport)
Description copied from interface:PluginRegistryPerforms integrity check of all registered plug-ins and generates result as a collection of standard report items.- Specified by:
checkIntegrityin interfacePluginRegistry- Parameters:
pathResolver- optional path resolverincludeRegistrationReport- iftrue, the plug-ins registration report will be included into resulting report- Returns:
- integrity check report
- See Also:
PluginRegistry.checkIntegrity( org.java.plugin.PathResolver, boolean)
-
getRegistrationReport
public IntegrityCheckReport getRegistrationReport()
- Specified by:
getRegistrationReportin interfacePluginRegistry- Returns:
- plug-ins registration report for this registry
- See Also:
PluginRegistry.getRegistrationReport()
-
makeUniqueId
public java.lang.String makeUniqueId(java.lang.String pluginId, java.lang.String id)Description copied from interface:PluginRegistryConstructs unique identifier for some plug-in element from it's ID.- Specified by:
makeUniqueIdin interfacePluginRegistry- Parameters:
pluginId- plug-in IDid- element ID- Returns:
- unique ID
- See Also:
PluginRegistry.makeUniqueId( java.lang.String, java.lang.String)
-
makeUniqueId
public java.lang.String makeUniqueId(java.lang.String pluginId, Version version)Description copied from interface:PluginRegistryConstructs unique identifier for plug-in with given ID.- Specified by:
makeUniqueIdin interfacePluginRegistry- Parameters:
pluginId- plug-in IDversion- plug-in version identifier- Returns:
- unique plug-in ID
- See Also:
PluginRegistry.makeUniqueId( java.lang.String, org.java.plugin.registry.Version)
-
extractPluginId
public java.lang.String extractPluginId(java.lang.String uniqueId)
Description copied from interface:PluginRegistryExtracts plug-in ID from some unique identifier.- Specified by:
extractPluginIdin interfacePluginRegistry- Parameters:
uniqueId- unique ID- Returns:
- plug-in ID
- See Also:
PluginRegistry.extractPluginId(java.lang.String)
-
extractId
public java.lang.String extractId(java.lang.String uniqueId)
Description copied from interface:PluginRegistryExtracts plug-in element ID from some unique identifier.- Specified by:
extractIdin interfacePluginRegistry- Parameters:
uniqueId- unique ID- Returns:
- element ID
- See Also:
PluginRegistry.extractId(java.lang.String)
-
extractVersion
public Version extractVersion(java.lang.String uniqueId)
Description copied from interface:PluginRegistryExtracts plug-in version identifier from some unique identifier (plug-in or plug-in fragment).- Specified by:
extractVersionin interfacePluginRegistry- Parameters:
uniqueId- unique ID- Returns:
- plug-in version identifier
- See Also:
PluginRegistry.extractVersion(java.lang.String)
-
registerListener
public void registerListener(PluginRegistry.RegistryChangeListener listener)
Description copied from interface:PluginRegistryRegisters plug-in registry change event listener. If given listener has been registered before, this method should throw anIllegalArgumentException.- Specified by:
registerListenerin interfacePluginRegistry- Parameters:
listener- new registry change event listener- See Also:
PluginRegistry.registerListener( org.java.plugin.registry.PluginRegistry.RegistryChangeListener)
-
unregisterListener
public void unregisterListener(PluginRegistry.RegistryChangeListener listener)
Description copied from interface:PluginRegistryUnregisters registry change event listener. If given listener hasn't been registered before, this method should throw anIllegalArgumentException.- Specified by:
unregisterListenerin interfacePluginRegistry- Parameters:
listener- registered listener- See Also:
PluginRegistry.unregisterListener( org.java.plugin.registry.PluginRegistry.RegistryChangeListener)
-
-