org.apache.commons.jjar
Class DependencyEngine

java.lang.Object
  extended by org.apache.commons.jjar.DependencyEngine

public class DependencyEngine
extends Object

Simple class to figure out ordered dependency lists. Basic idea is that you load it with datum consisting of a set consisting of a package name and list of packages that it's dependent upon.

Then, you should be able to ask for the dependencies for any package placed in there.

will detect loops at 'runtime', not loadtime. Just punts when that happens

This thing isn't close to threadsafe :)

Version:
$Id: DependencyEngine.java 155454 2005-02-26 13:23:34Z dirkv $
Author:
Geir Magnusson Jr.

Constructor Summary
DependencyEngine()
          CTOR
 
Method Summary
 void addProject(String project, List dependencies)
           
 void addProject(String project, List dependencies, Object cookie)
          Adds a project and it's associated dependencies.
 List generateCookielist()
          from previous use - generates a dependency list spanning the entire tree.
 List generateNamelist()
          from previous use - generates a dependency list spanning the entire tree.
 List getDependencies(List packages)
          Generates a dependency list for a set of packages.
 List getDependencies(List packages, boolean excludeTarget)
          Generates a dependency list for a set of packages where there is the option to exclude/include the target packages.
 List getDependencies(String pkg)
          returns a list of dependencies for a given package with the target being excluded from the list.
 List getDependencies(String pkg, boolean excludeTarget)
          returns a list of dependencies for a given package allowing the exclusion/inclusion of the target package.
 void reset()
          Reset the dependency engine, clear all entries and start from scratch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyEngine

public DependencyEngine()
CTOR

Method Detail

reset

public void reset()
Reset the dependency engine, clear all entries and start from scratch.


getDependencies

public List getDependencies(String pkg)
returns a list of dependencies for a given package with the target being excluded from the list.

Parameters:
pkg - package to get dependency list for
Returns:
List list of dependencies, in order

getDependencies

public List getDependencies(String pkg,
                            boolean excludeTarget)
returns a list of dependencies for a given package allowing the exclusion/inclusion of the target package.

Parameters:
pkg - package to get dependency list for
excludeTarget - boolean to control exclusion of target package
Returns:
List list of dependencies, in order

getDependencies

public List getDependencies(List packages)
Generates a dependency list for a set of packages.

Parameters:
packages - List of strings, each string is a package name
Returns:
list of dependencies, in order

getDependencies

public List getDependencies(List packages,
                            boolean excludeTarget)
Generates a dependency list for a set of packages where there is the option to exclude/include the target packages.

Parameters:
packages - List of strings, each string is a package name
excludeTarget - boolean to exclude target
Returns:
List list of dependencies, in order

generateNamelist

public List generateNamelist()
                      throws Exception
from previous use - generates a dependency list spanning the entire tree. Returns a list of names.

Throws:
Exception

generateCookielist

public List generateCookielist()
                        throws Exception
from previous use - generates a dependency list spanning the entire tree. Returns a list of cookies.

Throws:
Exception

addProject

public void addProject(String project,
                       List dependencies)
                throws Exception
Throws:
Exception

addProject

public void addProject(String project,
                       List dependencies,
                       Object cookie)
                throws Exception
Adds a project and it's associated dependencies. The dependencies currently do not have to be projects themselves.

Parameters:
project - Name of project to add
dependencies - java.util.List of project dependencies
Throws:
Exception - in the even that it already has the project in the list


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.