Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

javax.ide.extension
Class ExtensionRegistry

java.lang.Object
  extended by javax.ide.Service
      extended by javax.ide.extension.ExtensionRegistry
Direct Known Subclasses:
ExtensionRegistry

public abstract class ExtensionRegistry
extends Service

The extension registry provides access to information about installed extensions.


Constructor Summary
ExtensionRegistry()
           
 
Method Summary
static void addEventListener(ExtensionRegistrationListener l)
           
protected  void addToClassPath(javax.ide.extension.spi.ExtensionSource source)
          Deprecated. since 2.0 this method is no longer called during the processing of extension sources; the source will be added to the classpath using the BaseExtensionVisitor.addToClasspath(ElementContext,Extension,URI) method.
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  javax.ide.extension.spi.MinimalExtensionVisitor createMinimalExtensionVisitor()
          Creates the MinimalExtensionVisitor instance used for the minimal parse of all extension sources.
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.
 Extension findMinimalExtension(java.lang.String extensionId)
          Get the minimal Extension object for the given extension id.
protected  void fireRegistrationAborted(java.lang.String message)
           
protected  void fireRegistrationCompleted()
           
protected  void fireRegistrationException(java.lang.Exception ex)
           
protected  void fireRegistrationProgress(int totalcount, int currentcount, java.lang.String message)
           
protected  void fireRegistrationStarted()
           
protected  void fireRegistrationUpdate(java.lang.String message)
           
protected  javax.ide.extension.spi.DependencyTree getAllExtensionsDependencyTree()
          Returns the DependencyTree created for all extension sources during loadExtensions().
 java.lang.ClassLoader getClassLoader(java.lang.String extensionId)
          Returns the class loader to use for the specified extension.
static ExtensionRegistry getExtensionRegistry()
          Get the extension registry implementation for this IDE.
 java.util.Collection<Extension> getExtensions()
          Get a collection of registered extensions.
 ExtensionHook getHook(ElementName hookElement)
          Get the hook for the specified element name.
abstract  java.net.URI getInstallRoot(Extension extension)
          Get the install root of the specified extension.
protected  void initialize()
          Initializes the extension registry.
protected  boolean isExtensionEnabled(java.lang.String id, 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, int totalCount, int currentCount)
           
protected  java.util.Collection loadExtensions()
          Loads all extensions.
protected  java.util.Collection loadExtensions(java.util.Collection orderedSources)
          Load extensions in the specified order.
static void removeEventListener(ExtensionRegistrationListener l)
           
protected  void unsatisfiedExtensionDependencies(Extension ext, java.util.Collection deps)
          An extension with unsatisfied dependencies was encountered.
 
Methods inherited from class javax.ide.Service
getService, resetAllServices
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionRegistry

public ExtensionRegistry()
Method Detail

findExtension

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

Parameters:
id - the id of an extension.
Returns:
the specified extension, or null if no such extension is registered.

getExtensions

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

Returns:
a collection of all registered extensions.

getHook

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

Parameters:
hookElement - the element name of a hook to retrieve. Must not be null.
Returns:
the hook for the specified element, or null if no such hook is defined.

findMinimalExtension

public Extension findMinimalExtension(java.lang.String extensionId)
Get the minimal Extension object for the given extension id.


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.

Returns:
a collection of ExtensionSource instances, one for every potential extension.

createInitialContext

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

Returns:
the initial parsing context.

loadExtensions

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

This implementation obtains the collection of extension sources by calling findAllExtensionSources(). 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 ). It also calls cycleEncountered( Collection ) if any cyclic dependencies were found and unsatisfiedExtensionDependencies( Extension, Collection ) if unsatisfied dependencies were found.

Returns:
a collection of all available extensions.

createMinimalExtensionVisitor

protected javax.ide.extension.spi.MinimalExtensionVisitor createMinimalExtensionVisitor()
Creates the MinimalExtensionVisitor instance used for the minimal parse of all extension sources.


getAllExtensionsDependencyTree

protected javax.ide.extension.spi.DependencyTree getAllExtensionsDependencyTree()
Returns the DependencyTree created for all extension sources during loadExtensions(). Returns null if called prior to loadExtensions().


isExtensionEnabled

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

This implementation always returns true.

Parameters:
id - the id of an extension
version - the version of an extension
Returns:
true if the specified extension is enabled in this IDE.

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.

Parameters:
cycle - a collection of Extensions that have a cyclic dependency.

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.

Parameters:
ext - an extension which was not loaded due to unresolved dependencies on other extensions.
deps - a collection of ExtensionDependency objects, one for each dependency that was not satisfied.

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.

Parameters:
orderedSources - a collection of ExtensionSource instances. The iterator order of this collection is the correct order to load the extensions based on their dependencies.
Returns:
a collection of fully loaded Extensions.

loadExtension

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

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.

Returns:
a logger implementation which will log validation and error messages.

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.

Parameters:
hookVisitorFactory - the visitor factory for the hooks section of the manifest.
Returns:
an element visitor implementation for visiting the root element in extension manifests. Typically, this will be a subclass of ExtensionVisitor.

addToClassPath

protected void addToClassPath(javax.ide.extension.spi.ExtensionSource source)
Deprecated. since 2.0 this method is no longer called during the processing of extension sources; the source will be added to the classpath using the BaseExtensionVisitor.addToClasspath(ElementContext,Extension,URI) method.

Add the specified extension source to the classpath, if required.

Parameters:
source - the source of an extension. E.g if this is a JAR, it needs to be added to the classpath.

createHookVisitorFactory

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

Returns:
an ElementVisitorFactory for hooks.

initialize

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

Overrides:
initialize in class Service

getExtensionRegistry

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

Returns:
the extension registry implementation for this ide.

getInstallRoot

public abstract java.net.URI getInstallRoot(Extension extension)
Get the install root of the specified extension. The install root is a directory containing extension specific files. It is conventionally in the same location as the extension jar and named after the extension id.

Parameters:
extension - an extension to get the install root for. Must not be null.
Returns:
the URI of the install root for the specified extension. This URI may or may not exist - callers should use VirtualFileSystem.getVirtualFileSystem().isDirectory() on the returned URI to verify that it exists. Must not return null.

getClassLoader

public java.lang.ClassLoader getClassLoader(java.lang.String extensionId)
Returns the class loader to use for the specified extension. The current context class loader is returned by default.

Parameters:
extensionId - the id of an extension.
Returns:
the class loader for the specified extension.

addEventListener

public static void addEventListener(ExtensionRegistrationListener l)

removeEventListener

public static void removeEventListener(ExtensionRegistrationListener l)

fireRegistrationStarted

protected void fireRegistrationStarted()

fireRegistrationProgress

protected void fireRegistrationProgress(int totalcount,
                                        int currentcount,
                                        java.lang.String message)

fireRegistrationUpdate

protected void fireRegistrationUpdate(java.lang.String message)

fireRegistrationCompleted

protected void fireRegistrationCompleted()

fireRegistrationAborted

protected void fireRegistrationAborted(java.lang.String message)

fireRegistrationException

protected void fireRegistrationException(java.lang.Exception ex)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

Copyright © 1997, 2011, Oracle. All rights reserved.