JPF 1.5.1

org.java.plugin.tools.mocks
Class MockPluginRegistry

java.lang.Object
  extended by org.java.plugin.tools.mocks.MockPluginRegistry
All Implemented Interfaces:
PluginRegistry

public class MockPluginRegistry
extends java.lang.Object
implements PluginRegistry

Version:
$Id: MockPluginRegistry.java,v 1.4 2007/03/03 17:16:22 ddimon Exp $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.java.plugin.registry.PluginRegistry
PluginRegistry.RegistryChangeData, PluginRegistry.RegistryChangeListener
 
Constructor Summary
MockPluginRegistry()
           
 
Method Summary
 MockPluginRegistry addExtensionPoint(ExtensionPoint extPoint)
           
 MockPluginRegistry addPluginDescriptor(PluginDescriptor descr)
           
 MockPluginRegistry addPluginFragment(PluginFragment fragment)
           
 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.
 MockPluginRegistry setIntegrityCheckReport(IntegrityCheckReport value)
           
 MockPluginRegistry setRegistrationReport(IntegrityCheckReport value)
           
 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

MockPluginRegistry

public MockPluginRegistry()
Method Detail

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)

setIntegrityCheckReport

public MockPluginRegistry setIntegrityCheckReport(IntegrityCheckReport value)
Parameters:
value - the integrity check report to set
Returns:
this instance

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( org.java.plugin.util.ExtendedProperties)

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)

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)

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)

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)

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)

addExtensionPoint

public MockPluginRegistry addExtensionPoint(ExtensionPoint extPoint)
Parameters:
extPoint - extension point to add
Returns:
this instance

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)

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

addPluginDescriptor

public MockPluginRegistry addPluginDescriptor(PluginDescriptor descr)
Parameters:
descr - plug-in descriptor to add
Returns:
this instance

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

addPluginFragment

public MockPluginRegistry addPluginFragment(PluginFragment fragment)
Parameters:
fragment - plug-in fragment to add
Returns:
this instance

getRegistrationReport

public IntegrityCheckReport getRegistrationReport()
Specified by:
getRegistrationReport in interface PluginRegistry
Returns:
plug-ins registration report for this registry
See Also:
PluginRegistry.getRegistrationReport()

setRegistrationReport

public MockPluginRegistry setRegistrationReport(IntegrityCheckReport value)
Parameters:
value - the registration report to set
Returns:
this instance

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)

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)

makeUniqueId

public java.lang.String makeUniqueId(java.lang.String pluginId,
                                     java.lang.String elementId)
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
elementId - 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)

readManifestInfo

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

Specified by:
readManifestInfo in interface PluginRegistry
Parameters:
manifest - manifest data URL
Returns:
manifest info
See Also:
PluginRegistry.readManifestInfo( java.net.URL)

register

public java.util.Map<java.lang.String,Identity> register(java.net.URL[] manifests)
Description copied from interface: PluginRegistry
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.

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
See Also:
PluginRegistry.register(java.net.URL[])

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)

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[])

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.