JPF 1.5.1

org.java.plugin.registry.xml
Class PluginRegistryImpl

java.lang.Object
  extended by 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 registering or un-registering plug-ins. If this is false, the registration errors will be stored in the internal report that is available with PluginRegistry.checkIntegrity(PathResolver) method. The default parameter value is false.

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
PluginRegistryImpl()
          Creates plug-in registry object.
 
Method Summary
 IntegrityCheckReport checkIntegrity(PathResolver pathResolver)
          Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.
 IntegrityCheckReport 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.
 java.lang.String extractId(java.lang.String uniqueId)
          Extracts plug-in element ID from some unique identifier.
 java.lang.String extractPluginId(java.lang.String uniqueId)
          Extracts plug-in ID from some unique identifier.
 Version extractVersion(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.
 ExtensionPoint getExtensionPoint(java.lang.String uniqueId)
          Looks for extension point.
 ExtensionPoint getExtensionPoint(java.lang.String pluginId, java.lang.String pointId)
          Looks for extension point.
 PluginDescriptor getPluginDescriptor(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.
 IntegrityCheckReport getRegistrationReport()
           
 boolean isExtensionPointAvailable(java.lang.String uniqueId)
          Checks if extension point exists and is in valid state.
 boolean isExtensionPointAvailable(java.lang.String pluginId, java.lang.String pointId)
          Checks if extension point exists and is in valid state.
 boolean isPluginDescriptorAvailable(java.lang.String pluginId)
          Checks if plug-in exists and is in valid state.
 java.lang.String makeUniqueId(java.lang.String pluginId, java.lang.String id)
          Constructs unique identifier for some plug-in element from it's ID.
 java.lang.String makeUniqueId(java.lang.String pluginId, Version version)
          Constructs unique identifier for plug-in with given ID.
 ManifestInfo readManifestInfo(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.
 void registerListener(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).
 void unregisterListener(PluginRegistry.RegistryChangeListener listener)
          Unregisters registry change event listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginRegistryImpl

public PluginRegistryImpl()
Creates plug-in registry object.

Method Detail

configure

public void configure(ExtendedProperties config)
Description copied from interface: PluginRegistry
Configures this registry instance. Usually this method is called from object factory implementation.

Specified by:
configure in interface PluginRegistry
Parameters:
config - registry configuration data
See Also:
PluginRegistry.configure( ExtendedProperties)

readManifestInfo

public ManifestInfo readManifestInfo(java.net.URL url)
                              throws ManifestProcessingException
Description copied from interface: PluginRegistry
Reads basic information from a plug-in or plug-in fragment manifest.

Specified by:
readManifestInfo in interface PluginRegistry
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:
  1. Collect all currently registered extension points.
  2. Parse given URL's as XML content files and separate them on plug-in and plug-in fragment descriptors.
  3. Process new plug-in descriptors first:
    1. Instantiate new PluginDescriptorImpl object.
    2. Handle versions correctly - register new descriptor as most recent version or as an old version.
    3. If other versions of the same plug-in already registered, take their fragments and register them with this version.
  4. Process new plug-in fragments next:
    1. Instantiate new PluginFragmentImpl object.
    2. Check if older version of the same fragment already registered. If yes, un-register it and move to old plug-in fragments collection.
    3. Register new fragment with all matches plug-in descriptors (if this fragment is of most recent version).
  5. Notify collected extension points about potential changes in extensions set.
  6. Propagate events about registry changes.

Specified by:
register in interface PluginRegistry
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: PluginRegistry
Unregisters plug-ins and plug-in fragments with given ID's (including depending plug-ins and plug-in fragments).

Specified by:
unregister in interface PluginRegistry
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: PluginRegistry
Looks for extension point. This method have throw an IllegalArgumentException if requested extension point can't be found or is in invalid state.

Specified by:
getExtensionPoint in interface PluginRegistry
Parameters:
pluginId - plug-in ID
pointId - 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: PluginRegistry
Looks for extension point.

Specified by:
getExtensionPoint in interface PluginRegistry
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: PluginRegistry
Checks if extension point exists and is in valid state. If this method returns true, the method PluginRegistry.getExtensionPoint(String, String) should always return valid extension point.

Specified by:
isExtensionPointAvailable in interface PluginRegistry
Parameters:
pluginId - plug-in ID
pointId - extension point ID
Returns:
true if 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: PluginRegistry
Checks if extension point exists and is in valid state.

Specified by:
isExtensionPointAvailable in interface PluginRegistry
Parameters:
uniqueId - extension point unique ID
Returns:
true if extension point exists and valid
See Also:
PluginRegistry.isExtensionPointAvailable( java.lang.String)

getPluginDescriptor

public PluginDescriptor getPluginDescriptor(java.lang.String pluginId)
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 an IllegalArgumentException. In other words, this method shouldn't return null.

Specified by:
getPluginDescriptor in interface PluginRegistry
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: PluginRegistry
Checks if plug-in exists and is in valid state. If this method returns true, the method PluginRegistry.getPluginDescriptor(String) should always return valid plug-in descriptor.

Specified by:
isPluginDescriptorAvailable in interface PluginRegistry
Parameters:
pluginId - plug-in ID
Returns:
true if plug-in exists and valid
See Also:
PluginRegistry.isPluginDescriptorAvailable(java.lang.String)

getPluginDescriptors

public java.util.Collection<PluginDescriptor> 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 interface PluginRegistry
Returns:
collection of PluginDescriptor objects
See Also:
PluginRegistry.getPluginDescriptors()

getPluginFragments

public java.util.Collection<PluginFragment> 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 interface PluginRegistry
Returns:
collection of PluginFragment objects
See Also:
PluginRegistry.getPluginFragments()

getDependingPlugins

public java.util.Collection<PluginDescriptor> getDependingPlugins(PluginDescriptor descr)
Description copied from interface: PluginRegistry
Utility method that recursively collects all plug-ins that depends on the given plug-in.

Specified by:
getDependingPlugins in interface PluginRegistry
Parameters:
descr - descriptor of plug-in to collect dependencies for
Returns:
collection of plug-in descriptors that depend on given plug-in
See Also:
PluginRegistry.getDependingPlugins( org.java.plugin.registry.PluginDescriptor)

checkIntegrity

public IntegrityCheckReport checkIntegrity(PathResolver pathResolver)
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 interface PluginRegistry
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: PluginRegistry
Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.

Specified by:
checkIntegrity in interface PluginRegistry
Parameters:
pathResolver - optional path resolver
includeRegistrationReport - if true, 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:
getRegistrationReport in interface PluginRegistry
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: PluginRegistry
Constructs unique identifier for some plug-in element from it's ID.

Specified by:
makeUniqueId in interface PluginRegistry
Parameters:
pluginId - plug-in ID
id - 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: PluginRegistry
Constructs unique identifier for plug-in with given ID.

Specified by:
makeUniqueId in interface PluginRegistry
Parameters:
pluginId - plug-in ID
version - 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: PluginRegistry
Extracts plug-in ID from some unique identifier.

Specified by:
extractPluginId in interface PluginRegistry
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: PluginRegistry
Extracts plug-in element ID from some unique identifier.

Specified by:
extractId in interface PluginRegistry
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: PluginRegistry
Extracts plug-in version identifier from some unique identifier (plug-in or plug-in fragment).

Specified by:
extractVersion in interface PluginRegistry
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: PluginRegistry
Registers plug-in registry change event listener. If given listener has been registered before, this method should throw an IllegalArgumentException.

Specified by:
registerListener in interface PluginRegistry
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: PluginRegistry
Unregisters registry change event listener. If given listener hasn't been registered before, this method should throw an IllegalArgumentException.

Specified by:
unregisterListener in interface PluginRegistry
Parameters:
listener - registered listener
See Also:
PluginRegistry.unregisterListener( org.java.plugin.registry.PluginRegistry.RegistryChangeListener)

JPF 1.5.1

Copyright © 2004-2007 Dmitry Olshansky. All Rights Reserved.