org.universAAL.maven
Class LaunchOrderDependencyNodeVisitor

Package class diagram package LaunchOrderDependencyNodeVisitor
java.lang.Object
  extended by org.universAAL.maven.FilteringVisitorSupport
      extended by org.universAAL.maven.LaunchOrderDependencyNodeVisitor
All Implemented Interfaces:
org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor

public class LaunchOrderDependencyNodeVisitor
extends FilteringVisitorSupport
implements org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor

This DepepdencyVistor traverses depedency tree in depth-first manner. Visitor needs two collections: nodesByArtifactId and versionsByArtifactId which map respective stringified artifact representations to DependencyNodes. If visitor encounters node which was omitted, then it checks the reason for omitting. If it was omitted because of duplication then visitor looks up the kept node and continues traversing from it. If it was omitted because of conflict then an exception with meaningful message is thrown, unless the visitor is instructed to not throw exception by passing throwExceptionOnConflict parameter to the constructor. After ending a visit to node which was not ommitted the node's artifact is converted to mvn url and aded to mvnUrls list. If the artifact is not a bundle then mvn url is preceded with "wrap:" protocol. After visit is ended all mvnUrls in required launch order are contained in mvnUrl list.

Author:
rotgier

Constructor Summary
LaunchOrderDependencyNodeVisitor(org.apache.maven.plugin.logging.Log log, Map nodesByArtifactId, Map versionsByArtifactId, boolean throwExceptionOnConflict, org.apache.maven.artifact.repository.ArtifactRepository localRepository, org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver, org.apache.maven.artifact.Artifact dontResolve, StartSpec[] startSpecs)
          Constructor of LaunchOrderDependencyNodeVisitor.
 
Method Summary
protected  void addNode(org.apache.maven.shared.dependency.tree.DependencyNode node)
          Adds node to the execution list.
 boolean endVisit(org.apache.maven.shared.dependency.tree.DependencyNode node)
          If this method returns true then it means that the next sibling should be visited.
 List getMvnUrls()
          Gets execution list containing mvn urls.
 void setExcludedCoreArtifacts(List<org.apache.maven.artifact.resolver.ResolutionNode> excludedCoreArtifacts)
          Sets core uAAL artifacts which should be excluded from created execution list.
 boolean visit(org.apache.maven.shared.dependency.tree.DependencyNode node)
          If this method returns true then it means that nodes children should be visited.
 
Methods inherited from class org.universAAL.maven.FilteringVisitorSupport
getLog, getVisited, isInScope, stringify, stringify, stringifyNoVersion, stringifyNoVersion, wasVisited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LaunchOrderDependencyNodeVisitor

public LaunchOrderDependencyNodeVisitor(org.apache.maven.plugin.logging.Log log,
                                        Map nodesByArtifactId,
                                        Map versionsByArtifactId,
                                        boolean throwExceptionOnConflict,
                                        org.apache.maven.artifact.repository.ArtifactRepository localRepository,
                                        org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver,
                                        org.apache.maven.artifact.Artifact dontResolve,
                                        StartSpec[] startSpecs)
Constructor of LaunchOrderDependencyNodeVisitor.

Parameters:
log - object for logging
nodesByArtifactId - mapping of stringified artifacts (groupId + artifactId + version) to nodes in the dependency tree. Nodes contain information about children. Duplicates of nodes are not included in the mapping.
versionsByArtifactId - mapping of stringified artifacts without version (groupId + artifactId) to stringified artifacts with version.
throwExceptionOnConflict - flag which turns turning exception on conflict
localRepository - maven local repository
artifactResolver - maven artifact resolver
dontResolve - artifact which should not be resolved
Method Detail

addNode

protected final void addNode(org.apache.maven.shared.dependency.tree.DependencyNode node)
Adds node to the execution list.

Parameters:
node - which should be added.

visit

public final boolean visit(org.apache.maven.shared.dependency.tree.DependencyNode node)
If this method returns true then it means that nodes children should be visited. True is returned only if node is in scope and if it was not ommited. It is ensured that node with given groupId, artifactId and version is visited only once. When visiting node omitted because of conflict, exception is thrown if throwExceptionOnConflict property is true. In case throwExceptionOnConflict is false, the conflict is resolved as suggested by the tree and kept artifact is finally added to mvnUrls list.

Specified by:
visit in interface org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor
Parameters:
node - which should be checked for need of visiting
Returns:
true if node needs visiting, false otherwise

endVisit

public final boolean endVisit(org.apache.maven.shared.dependency.tree.DependencyNode node)
If this method returns true then it means that the next sibling should be visited. Because all nodes should be visited this methods always returns true. If node wasn't visited, it is in the scope, and was not omitted then it is added to mvnUrls list.

Specified by:
endVisit in interface org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor
Parameters:
node - which visiting should be finished
Returns:
this method always returns true

getMvnUrls

public final List getMvnUrls()
Gets execution list containing mvn urls.

Returns:
execution list.

setExcludedCoreArtifacts

public final void setExcludedCoreArtifacts(List<org.apache.maven.artifact.resolver.ResolutionNode> excludedCoreArtifacts)
Sets core uAAL artifacts which should be excluded from created execution list.

Parameters:
excludedCoreArtifacts - list of artifacts to be excluded.


Copyright © 2014 universAAL Consortium. All Rights Reserved.