JPF 1.5.1

org.java.plugin.registry
Interface PluginRegistry

All Known Implementing Classes:
MockPluginRegistry, PluginRegistryImpl

public interface PluginRegistry

Root interface to get access to all meta-information about discovered plug-ins. All objects accessible from the registry are immutable. You can imagine registry as a read-only storage of full information about discovered plug-ins. There is only one exception from this rule: internal state of registry, plug-in descriptors and plug-in elements can be modified indirectly by registering or un-registering plug-ins with this registry. If your code is interested to be notified on all modifications of plug-ins set, you can register an implementation of PluginRegistry.RegistryChangeListener with this registry.

Notes on unique ID's (UID's)

There are two types of identifiers in the API: ID's and UID's. ID is an identifier that is unique within set of elements of the same type. UID is an identifier that unique globally within registry space. ID is usually defined by developer in plug-in manifest. UID always combined automatically from several other plug-in "parts". All plug-in elements have method getId() that come from basic Identity interface, but not all elements have UID - only those that inherits UniqueIdentityinterface.

There are several utility methods available in this interface that aimed to build UID from different plug-in "parts" and also split UID to it's original elements: makeUniqueId(String, Version), makeUniqueId(String, String), extractPluginId(String), extractId(String) and extractVersion(String).

Version:
$Id: PluginRegistry.java,v 1.5 2007/03/03 17:16:26 ddimon Exp $
See Also:
ObjectFactory.createRegistry()

Nested Class Summary
static interface PluginRegistry.RegistryChangeData
          Registry changes data holder interface.
static interface PluginRegistry.RegistryChangeListener
          Plug-in registry changes callback interface.
 
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 elementId)
          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 manifest)
          Reads basic information from a plug-in or plug-in fragment manifest.
 java.util.Map<java.lang.String,Identity> register(java.net.URL[] manifests)
          Registers plug-ins and plug-in fragments in this registry.
 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.
 

Method Detail

register

java.util.Map<java.lang.String,Identity> register(java.net.URL[] manifests)
                                                  throws ManifestProcessingException
Registers plug-ins and plug-in fragments in this registry. Note that this method not makes plug-ins available for activation by any PluginManager instance as it is not aware of any manager. Using this method just makes plug-in meta-data available for reading from this registry.

If more than one version of the same plug-in or plug-in fragment given, the only latest version should be registered. If some plug-in or plug-in fragment already registered it should be ignored by this method. Client application have to un-register such plug-ins first before registering their newest versions.

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:
PluginManager.publishPlugins(PluginManager.PluginLocation[])

readManifestInfo

ManifestInfo readManifestInfo(java.net.URL manifest)
                              throws ManifestProcessingException
Reads basic information from a plug-in or plug-in fragment manifest.

Parameters:
manifest - manifest data URL
Returns:
manifest info
Throws:
ManifestProcessingException - if manifest data can't be read

unregister

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).

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

getPluginDescriptor

PluginDescriptor getPluginDescriptor(java.lang.String pluginId)
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.

Parameters:
pluginId - plug-id ID
Returns:
plug-in descriptor

isPluginDescriptorAvailable

boolean isPluginDescriptorAvailable(java.lang.String pluginId)
Checks if plug-in exists and is in valid state. If this method returns true, the method getPluginDescriptor(String) should always return valid plug-in descriptor.

Parameters:
pluginId - plug-in ID
Returns:
true if plug-in exists and valid

getPluginDescriptors

java.util.Collection<PluginDescriptor> getPluginDescriptors()
Returns collection of descriptors of all plug-ins that was successfully populated by this registry.

Returns:
collection of PluginDescriptor objects

getExtensionPoint

ExtensionPoint getExtensionPoint(java.lang.String pluginId,
                                 java.lang.String pointId)
Looks for extension point. This method have throw an IllegalArgumentException if requested extension point can't be found or is in invalid state.

Parameters:
pluginId - plug-in ID
pointId - extension point ID
Returns:
plug-in extension point
See Also:
ExtensionPoint.isValid()

getExtensionPoint

ExtensionPoint getExtensionPoint(java.lang.String uniqueId)
Looks for extension point.

Parameters:
uniqueId - extension point unique ID
Returns:
plug-in extension point
See Also:
getExtensionPoint(String, String)

isExtensionPointAvailable

boolean isExtensionPointAvailable(java.lang.String pluginId,
                                  java.lang.String pointId)
Checks if extension point exists and is in valid state. If this method returns true, the method getExtensionPoint(String, String) should always return valid extension point.

Parameters:
pluginId - plug-in ID
pointId - extension point ID
Returns:
true if extension point exists and valid

isExtensionPointAvailable

boolean isExtensionPointAvailable(java.lang.String uniqueId)
Checks if extension point exists and is in valid state.

Parameters:
uniqueId - extension point unique ID
Returns:
true if extension point exists and valid
See Also:
isExtensionPointAvailable(String, String)

getPluginFragments

java.util.Collection<PluginFragment> getPluginFragments()
Returns collection of descriptors of all plug-in fragments that was successfully populated by this registry.

Returns:
collection of PluginFragment objects

getDependingPlugins

java.util.Collection<PluginDescriptor> getDependingPlugins(PluginDescriptor descr)
Utility method that recursively collects all plug-ins that depends on the given plug-in.

Parameters:
descr - descriptor of plug-in to collect dependencies for
Returns:
collection of plug-in descriptors that depend on given plug-in

checkIntegrity

IntegrityCheckReport checkIntegrity(PathResolver pathResolver)
Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.

Parameters:
pathResolver - optional path resolver
Returns:
integrity check report

checkIntegrity

IntegrityCheckReport checkIntegrity(PathResolver pathResolver,
                                    boolean includeRegistrationReport)
Performs integrity check of all registered plug-ins and generates result as a collection of standard report items.

Parameters:
pathResolver - optional path resolver
includeRegistrationReport - if true, the plug-ins registration report will be included into resulting report
Returns:
integrity check report

getRegistrationReport

IntegrityCheckReport getRegistrationReport()
Returns:
plug-ins registration report for this registry

makeUniqueId

java.lang.String makeUniqueId(java.lang.String pluginId,
                              java.lang.String elementId)
Constructs unique identifier for some plug-in element from it's ID.

Parameters:
pluginId - plug-in ID
elementId - element ID
Returns:
unique ID

makeUniqueId

java.lang.String makeUniqueId(java.lang.String pluginId,
                              Version version)
Constructs unique identifier for plug-in with given ID.

Parameters:
pluginId - plug-in ID
version - plug-in version identifier
Returns:
unique plug-in ID

extractPluginId

java.lang.String extractPluginId(java.lang.String uniqueId)
Extracts plug-in ID from some unique identifier.

Parameters:
uniqueId - unique ID
Returns:
plug-in ID

extractId

java.lang.String extractId(java.lang.String uniqueId)
Extracts plug-in element ID from some unique identifier.

Parameters:
uniqueId - unique ID
Returns:
element ID

extractVersion

Version extractVersion(java.lang.String uniqueId)
Extracts plug-in version identifier from some unique identifier (plug-in or plug-in fragment).

Parameters:
uniqueId - unique ID
Returns:
plug-in version identifier

registerListener

void registerListener(PluginRegistry.RegistryChangeListener listener)
Registers plug-in registry change event listener. If given listener has been registered before, this method should throw an IllegalArgumentException.

Parameters:
listener - new registry change event listener

unregisterListener

void unregisterListener(PluginRegistry.RegistryChangeListener listener)
Unregisters registry change event listener. If given listener hasn't been registered before, this method should throw an IllegalArgumentException.

Parameters:
listener - registered listener

configure

void configure(ExtendedProperties config)
Configures this registry instance. Usually this method is called from object factory implementation.

Parameters:
config - registry configuration data

JPF 1.5.1

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