Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.ide.extension
Class ExtensionRegistry  view ExtensionRegistry download ExtensionRegistry.java

java.lang.Object
  extended byjavax.ide.Service
      extended byjavax.ide.extension.ExtensionRegistry

public abstract class ExtensionRegistry
extends javax.ide.Service

The extension registry provides access to information about installed extensions.


Field Summary
private  java.util.Map _extensions
           
private  ElementVisitorFactory _hookFactory
           
 
Fields inherited from class javax.ide.Service
 
Constructor Summary
ExtensionRegistry()
           
 
Method Summary
protected abstract  void addToClassPath(javax.ide.extension.spi.ExtensionSource source)
          Add the specified extension source to the classpath, if required.
protected  java.util.logging.Logger createExtensionLogger()
          Create a logger which will log validation and error messages while parsing manifest files.
protected abstract  javax.ide.extension.spi.ExtensionVisitor createExtensionVisitor(ElementVisitorFactory hookVisitorFactory)
          Create the element visitor that is responsible for visiting the root element in extension manifests.
protected  ElementVisitorFactory createHookVisitorFactory()
          Create the visitor factory for hooks.
protected  ElementContext createInitialContext()
          Create the initial parsing context.
protected  void cycleEncountered(java.util.Collection cycle)
          A cycle was encountered.
protected abstract  java.util.Collection findAllExtensionSources()
          Find all valid extension sources.
 Extension findExtension(java.lang.String id)
          Find the Extension identified by the given id.
static ExtensionRegistry getExtensionRegistry()
          Get the extension registry implementation for this IDE.
 java.util.Collection getExtensions()
          Get a collection of registered extensions.
 ExtensionHook getHook(ElementName hookElement)
          Get the hook for the specified element name.
protected  void initialize()
          Initializes the extension registry.
protected  boolean isExtensionEnabled(java.lang.String id, javax.ide.util.Version version)
          Gets whether the specified extension is enabled in this IDE.
protected  void loadExtension(javax.ide.extension.spi.SAXManifestParser parser, java.util.logging.Logger logger, javax.ide.extension.spi.ExtensionSource source)
           
protected  java.util.Collection loadExtensions()
          Loads all extensions.
protected  java.util.Collection loadExtensions(java.util.Collection orderedSources)
          Load extensions in the specified order.
protected  void unsatisfiedExtensionDependencies(Extension ext, java.util.Collection deps)
          An extension with unsatisfied dependencies was encountered.
 
Methods inherited from class javax.ide.Service
getService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_extensions

private java.util.Map _extensions

_hookFactory

private ElementVisitorFactory _hookFactory
Constructor Detail

ExtensionRegistry

public ExtensionRegistry()
Method Detail

findExtension

public final Extension findExtension(java.lang.String id)
Find the Extension identified by the given id.


getExtensions

public final java.util.Collection getExtensions()
Get a collection of registered extensions.


getHook

public ExtensionHook getHook(ElementName hookElement)
Get the hook for the specified element name.


findAllExtensionSources

protected abstract java.util.Collection findAllExtensionSources()
Find all valid extension sources. A source is typically a JAR file containing an extension manifest in its META-INF directory. However, this implementation is not limited to processing extensions bundled that way.


createInitialContext

protected ElementContext createInitialContext()
Create the initial parsing context. For the SAXManifestParser, this must be an instance of DefaultElementContext.


loadExtensions

protected java.util.Collection loadExtensions()
Loads all extensions.

This implementation obtains the collection of extension sources by calling findAllExtensionSources() 55 . It then refines this list to only sources which are valid (have a non-null URI).

This implementation performs dependency analysis of extensions to determine the correct load order. Given multiple extensions with the same ID but different versions, it will always choose the latest version (even if that causes a dependency from another extension to be unsatisfied).

When the list of extensions to load in order is determined, this implementation calls loadExtensions( Collection ) 55 . It also calls cycleEncountered( Collection ) 55 if any cyclic dependencies were found and unsatisfiedExtensionDependencies( Extension, Collection ) 55 if unsatisfied dependencies were found.


isExtensionEnabled

protected boolean isExtensionEnabled(java.lang.String id,
                                     javax.ide.util.Version version)
Gets whether the specified extension is enabled in this IDE.

This implementation always returns true.


cycleEncountered

protected void cycleEncountered(java.util.Collection cycle)
A cycle was encountered. This is called after all extensions have been loaded to notify the extension registry that there were cyclic dependencies between extensions. The extension loading implementation in this class will load extensions even if there are cycles. cycleEncountered() is called to give IDEs a chance to report cycles to users.

The returned collection contains partially populated Extension instances in dependency order. The last extension in the collection is a duplicate of one of the previous extensions in the collection and is the first extension on which a cycle was detected.

This implementation does nothing.


unsatisfiedExtensionDependencies

protected void unsatisfiedExtensionDependencies(Extension ext,
                                                java.util.Collection deps)
An extension with unsatisfied dependencies was encountered. This is called after all extensions have been loaded to notify the extension registry that there were extensions which had unsatisfied dependencies. The extension loading implementation in this class will not load extensions which have unsatisfied dependencies. unsatisfiedExtensionDependencies() is called to give IDEs a chance to report unsatisfied dependencies to users.

This implementation does nothing.


loadExtensions

protected java.util.Collection loadExtensions(java.util.Collection orderedSources)
Load extensions in the specified order.

This implementation uses SAXManifestParser to load each extension in turn.


loadExtension

protected void loadExtension(javax.ide.extension.spi.SAXManifestParser parser,
                             java.util.logging.Logger logger,
                             javax.ide.extension.spi.ExtensionSource source)

createExtensionLogger

protected java.util.logging.Logger createExtensionLogger()
Create a logger which will log validation and error messages while parsing manifest files.

This implementation returns a default logger created using the log manager.


createExtensionVisitor

protected abstract javax.ide.extension.spi.ExtensionVisitor createExtensionVisitor(ElementVisitorFactory hookVisitorFactory)
Create the element visitor that is responsible for visiting the root element in extension manifests.


addToClassPath

protected abstract void addToClassPath(javax.ide.extension.spi.ExtensionSource source)
Add the specified extension source to the classpath, if required.


createHookVisitorFactory

protected ElementVisitorFactory createHookVisitorFactory()
Create the visitor factory for hooks. This implementation returns a new instance of javax.ide.extension.spi.DefaultHookVisitorFactory.


initialize

protected void initialize()
Initializes the extension registry. This implementation


getExtensionRegistry

public static ExtensionRegistry getExtensionRegistry()
Get the extension registry implementation for this IDE.