Package org.java.plugin.registry.xml
Class PluginRegistryImpl
java.lang.Object
org.java.plugin.registry.xml.PluginRegistryImpl
- All Implemented Interfaces:
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
registering
orun-registering
plug-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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.java.plugin.registry.PluginRegistry
PluginRegistry.RegistryChangeData, PluginRegistry.RegistryChangeListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckIntegrity
(PathResolver pathResolver) Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.checkIntegrity
(PathResolver pathResolver, boolean includeRegistrationReport) Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.void
configure
(ExtendedProperties config) Configures this registry instance.Extracts plug-in element ID from some unique identifier.extractPluginId
(String uniqueId) Extracts plug-in ID from some unique identifier.extractVersion
(String uniqueId) Extracts plug-in version identifier from some unique identifier (plug-in or plug-in fragment).Utility method that recursively collects all plug-ins that depends on the given plug-in.getExtensionPoint
(String uniqueId) Looks for extension point.getExtensionPoint
(String pluginId, String pointId) Looks for extension point.getPluginDescriptor
(String pluginId) Returns descriptor of plug-in with given ID.Returns collection of descriptors of all plug-ins that was successfully populated by this registry.Returns collection of descriptors of all plug-in fragments that was successfully populated by this registry.boolean
isExtensionPointAvailable
(String uniqueId) Checks if extension point exists and is in valid state.boolean
isExtensionPointAvailable
(String pluginId, String pointId) Checks if extension point exists and is in valid state.boolean
isPluginDescriptorAvailable
(String pluginId) Checks if plug-in exists and is in valid state.makeUniqueId
(String pluginId, String id) Constructs unique identifier for some plug-in element from it's ID.makeUniqueId
(String pluginId, Version version) Constructs unique identifier for plug-in with given ID.readManifestInfo
(URL url) Reads basic information from a plug-in or plug-in fragment manifest.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.void
Registers plug-in registry change event listener.unregister
(String[] ids) Unregisters plug-ins and plug-in fragments with given ID's (including depending plug-ins and plug-in fragments).void
Unregisters registry change event listener.
-
Constructor Details
-
PluginRegistryImpl
public PluginRegistryImpl()Creates plug-in registry object.
-
-
Method Details
-
configure
Description copied from interface:PluginRegistry
Configures this registry instance. Usually this method is called fromobject factory
implementation.- Specified by:
configure
in interfacePluginRegistry
- Parameters:
config
- registry configuration data- See Also:
-
readManifestInfo
Description copied from interface:PluginRegistry
Reads basic information from a plug-in or plug-in fragment manifest.- Specified by:
readManifestInfo
in interfacePluginRegistry
- Parameters:
url
- manifest data URL- Returns:
- manifest info
- Throws:
ManifestProcessingException
- if manifest data can't be read- See Also:
-
register
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:
register
in 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:
-
unregister
Description copied from interface:PluginRegistry
Unregisters plug-ins and plug-in fragments with given ID's (including depending plug-ins and plug-in fragments).- Specified by:
unregister
in 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:
-
getExtensionPoint
Description copied from interface:PluginRegistry
Looks for extension point. This method have throw anIllegalArgumentException
if requested extension point can't be found or is in invalid state.- Specified by:
getExtensionPoint
in interfacePluginRegistry
- Parameters:
pluginId
- plug-in IDpointId
- extension point ID- Returns:
- plug-in extension point
- See Also:
-
getExtensionPoint
Description copied from interface:PluginRegistry
Looks for extension point.- Specified by:
getExtensionPoint
in interfacePluginRegistry
- Parameters:
uniqueId
- extension point unique ID- Returns:
- plug-in extension point
- See Also:
-
isExtensionPointAvailable
Description copied from interface:PluginRegistry
Checks 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:
isExtensionPointAvailable
in interfacePluginRegistry
- Parameters:
pluginId
- plug-in IDpointId
- extension point ID- Returns:
true
if extension point exists and valid- See Also:
-
isExtensionPointAvailable
Description copied from interface:PluginRegistry
Checks if extension point exists and is in valid state.- Specified by:
isExtensionPointAvailable
in interfacePluginRegistry
- Parameters:
uniqueId
- extension point unique ID- Returns:
true
if extension point exists and valid- See Also:
-
getPluginDescriptor
Description copied from interface:PluginRegistry
Returns 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:
getPluginDescriptor
in interfacePluginRegistry
- Parameters:
pluginId
- plug-id ID- Returns:
- plug-in descriptor
- See Also:
-
isPluginDescriptorAvailable
Description copied from interface:PluginRegistry
Checks 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:
isPluginDescriptorAvailable
in interfacePluginRegistry
- Parameters:
pluginId
- plug-in ID- Returns:
true
if plug-in exists and valid- See Also:
-
getPluginDescriptors
Description copied from interface:PluginRegistry
Returns collection of descriptors of all plug-ins that was successfully populated by this registry.- Specified by:
getPluginDescriptors
in interfacePluginRegistry
- Returns:
- collection of
PluginDescriptor
objects - See Also:
-
getPluginFragments
Description copied from interface:PluginRegistry
Returns collection of descriptors of all plug-in fragments that was successfully populated by this registry.- Specified by:
getPluginFragments
in interfacePluginRegistry
- Returns:
- collection of
PluginFragment
objects - See Also:
-
getDependingPlugins
Description copied from interface:PluginRegistry
Utility method that recursively collects all plug-ins that depends on the given plug-in.- Specified by:
getDependingPlugins
in interfacePluginRegistry
- Parameters:
descr
- descriptor of plug-in to collect dependencies for- Returns:
- collection of
plug-in descriptors
that depend on given plug-in - See Also:
-
checkIntegrity
Description copied from interface:PluginRegistry
Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.- Specified by:
checkIntegrity
in interfacePluginRegistry
- Parameters:
pathResolver
- optional path resolver- Returns:
- integrity check report
- See Also:
-
checkIntegrity
public IntegrityCheckReport checkIntegrity(PathResolver pathResolver, boolean includeRegistrationReport) Description copied from interface:PluginRegistry
Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.- Specified by:
checkIntegrity
in interfacePluginRegistry
- Parameters:
pathResolver
- optional path resolverincludeRegistrationReport
- iftrue
, the plug-ins registration report will be included into resulting report- Returns:
- integrity check report
- See Also:
-
getRegistrationReport
- Specified by:
getRegistrationReport
in interfacePluginRegistry
- Returns:
- plug-ins registration report for this registry
- See Also:
-
makeUniqueId
Description copied from interface:PluginRegistry
Constructs unique identifier for some plug-in element from it's ID.- Specified by:
makeUniqueId
in interfacePluginRegistry
- Parameters:
pluginId
- plug-in IDid
- element ID- Returns:
- unique ID
- See Also:
-
makeUniqueId
Description copied from interface:PluginRegistry
Constructs unique identifier for plug-in with given ID.- Specified by:
makeUniqueId
in interfacePluginRegistry
- Parameters:
pluginId
- plug-in IDversion
- plug-in version identifier- Returns:
- unique plug-in ID
- See Also:
-
extractPluginId
Description copied from interface:PluginRegistry
Extracts plug-in ID from some unique identifier.- Specified by:
extractPluginId
in interfacePluginRegistry
- Parameters:
uniqueId
- unique ID- Returns:
- plug-in ID
- See Also:
-
extractId
Description copied from interface:PluginRegistry
Extracts plug-in element ID from some unique identifier.- Specified by:
extractId
in interfacePluginRegistry
- Parameters:
uniqueId
- unique ID- Returns:
- element ID
- See Also:
-
extractVersion
Description copied from interface:PluginRegistry
Extracts plug-in version identifier from some unique identifier (plug-in or plug-in fragment).- Specified by:
extractVersion
in interfacePluginRegistry
- Parameters:
uniqueId
- unique ID- Returns:
- plug-in version identifier
- See Also:
-
registerListener
Description copied from interface:PluginRegistry
Registers plug-in registry change event listener. If given listener has been registered before, this method should throw anIllegalArgumentException
.- Specified by:
registerListener
in interfacePluginRegistry
- Parameters:
listener
- new registry change event listener- See Also:
-
unregisterListener
Description copied from interface:PluginRegistry
Unregisters registry change event listener. If given listener hasn't been registered before, this method should throw anIllegalArgumentException
.- Specified by:
unregisterListener
in interfacePluginRegistry
- Parameters:
listener
- registered listener- See Also:
-