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

Quick Search    Search Deep

javax.ide.extension.spi
Class DependencyTree  view DependencyTree download DependencyTree.java

java.lang.Object
  extended byjavax.ide.extension.spi.DependencyTree

public final class DependencyTree
extends java.lang.Object

DependencyTree is responsible for determining dependencies between extensions and providing a load order that satisfies those dependencies.


Nested Class Summary
static interface DependencyTree.EnabledExtensionLookup
          Mechanism used by this class to look up whether an extension is enabled.
private static class DependencyTree.MinimalExtensionVisitor
          A minimal visitor which just processes the id, version, esdk-version and dependencies of an extension.
private  class DependencyTree.TopoSortState
          The state of a topological sort.
 
Field Summary
private  java.util.List _cycles
           
private  java.util.Map _extensionsById
           
private  java.util.Map _sourcesByExtension
           
private  java.util.List _topologicalExtensionList
           
private  java.util.Map _unsatisfiedDependencies
           
private static java.lang.String SOURCE
           
private  java.lang.Object STATE_NOT_VISITED
           
private  java.lang.Object STATE_VISITED
           
private  java.lang.Object STATE_VISITING
           
 
Constructor Summary
private DependencyTree(java.util.List failedSources, java.util.Map sourcesByExtension)
           
 
Method Summary
static DependencyTree buildTree(java.util.Collection extensionSources, DependencyTree.EnabledExtensionLookup lookup, java.util.logging.Logger logger, DefaultElementContext initialContext)
          Build a dependency tree for the specified collection of extension sources.
 java.util.Collection getCycles()
          Get cycles in the dependency graph.
 javax.ide.util.Version getResolvedVersion(java.lang.String id)
          Get the resolved version of the specified extension id.
 java.util.List getSortedExtensionIDs()
          Get the list of extension ids, sorted in order of the topological sort of their dependency graph.
 ExtensionSource getSource(java.lang.String id)
          Get the source of an extension.
 java.util.Collection getUnsatisfiedDependencies(javax.ide.extension.Extension unsatisfied)
          Get the set of unsatisfied dependencies for the specified extension.
 java.util.Collection getUnsatisfiedExtensions()
          Get a collection of extensions with unsatisfied dependencies.
private  boolean isVersionSatisfied(javax.ide.extension.ExtensionDependency dep, javax.ide.extension.Extension ext)
          Get an extension which satisfies the specified dependency.
private  void removeDuplicates()
          Resolve duplicate extension ids.
private  void topologicalSort(DependencyTree.TopoSortState state, javax.ide.extension.Extension ext)
          Topologically sort the set of extensions in _sourcesByExtension based on their dependencies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE

private static final java.lang.String SOURCE
See Also:
Constant Field Values

_sourcesByExtension

private final java.util.Map _sourcesByExtension

_extensionsById

private final java.util.Map _extensionsById

_topologicalExtensionList

private java.util.List _topologicalExtensionList

_unsatisfiedDependencies

private final java.util.Map _unsatisfiedDependencies

_cycles

private final java.util.List _cycles

STATE_NOT_VISITED

private java.lang.Object STATE_NOT_VISITED

STATE_VISITING

private java.lang.Object STATE_VISITING

STATE_VISITED

private java.lang.Object STATE_VISITED
Constructor Detail

DependencyTree

private DependencyTree(java.util.List failedSources,
                       java.util.Map sourcesByExtension)
Method Detail

buildTree

public static DependencyTree buildTree(java.util.Collection extensionSources,
                                       DependencyTree.EnabledExtensionLookup lookup,
                                       java.util.logging.Logger logger,
                                       DefaultElementContext initialContext)
Build a dependency tree for the specified collection of extension sources.


removeDuplicates

private void removeDuplicates()
Resolve duplicate extension ids. If two or more extensions are present with the same id but different versions, we discard the older versions. If two or more extensions have the same version, we "arbitrarily" pick only one.


topologicalSort

private void topologicalSort(DependencyTree.TopoSortState state,
                             javax.ide.extension.Extension ext)
Topologically sort the set of extensions in _sourcesByExtension based on their dependencies. This algorithm detects cycles, but does not abort on the detection of them. Instead, it discards cyclic dependencies for the purposes of topo sorts (we should probably signal some kind of error condition so that it can be reported)


isVersionSatisfied

private boolean isVersionSatisfied(javax.ide.extension.ExtensionDependency dep,
                                   javax.ide.extension.Extension ext)
Get an extension which satisfies the specified dependency.


getSortedExtensionIDs

public java.util.List getSortedExtensionIDs()
Get the list of extension ids, sorted in order of the topological sort of their dependency graph.

This list will not contain the ids of extensions which have unsatisfied dependencies. To get a list of unsatisfied dependencies, call getUnsatisfiedExtensions() 55 .

This list may contain extensions whose dependencies are not entirely satisfied because the dependency graph contained cycles. To get a list of all identified cycles in the dependency graph, call getCycles().

IDE implementations should generally process the manifests of extensions in the order the extensions are returned by this method.


getResolvedVersion

public javax.ide.util.Version getResolvedVersion(java.lang.String id)
Get the resolved version of the specified extension id.


getCycles

public java.util.Collection getCycles()
Get cycles in the dependency graph. This method returns a collection of Lists, one for each identified cycle in the graph. Each list entry consists of Extension instances for each extension in the cycle, starting at some arbitrary extension and ending with the second encountered instance of some extension.


getUnsatisfiedExtensions

public java.util.Collection getUnsatisfiedExtensions()
Get a collection of extensions with unsatisfied dependencies.


getUnsatisfiedDependencies

public java.util.Collection getUnsatisfiedDependencies(javax.ide.extension.Extension unsatisfied)
Get the set of unsatisfied dependencies for the specified extension.


getSource

public ExtensionSource getSource(java.lang.String id)
Get the source of an extension. If there is more than one extension with the same id, this returns the most recent version of the extension.