public class PluginDependencyGraph extends Object
adding plugins to the graph, and then when all plugins have been
added you can get the deployment order that lists all the plugins in the order in which
they should be deployed.
Note that circular dependencies are NOT allowed nor supported.
| Modifier and Type | Class and Description |
|---|---|
static class |
PluginDependencyGraph.PluginDependency |
| Constructor and Description |
|---|
PluginDependencyGraph() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPlugin(String pluginName,
List<PluginDependencyGraph.PluginDependency> dependencies)
Adds a plugin to the graph.
|
Collection<String> |
getAllDependencies(String pluginName)
Given a plugin that is in this dependency graph, this will return all those plugins
the plugin either directly or indirectly depends on it.
|
Collection<String> |
getAllDependents(String pluginName)
Given a plugin that is in this dependency graph, this will return all those plugins
that either directly or indirectly depend on it (both optional and required dependencies).
|
List<String> |
getDeploymentOrder()
Returns the deployment order for all added plugins.
|
List<String> |
getOptionalDependents(String pluginName)
Given a plugin that is in this dependency graph, this will return all those plugins
that optionally depend on it.
|
List<String> |
getPluginDependencies(String pluginName)
Given a plugin that is in this dependency graph, this will return the list of its direct dependencies (the
plugins this plugin explicitly depends on).
|
Set<String> |
getPlugins()
Returns the set of plugin names that have been added to the dependency graph.
|
String |
getUseClassesDependency(String pluginName)
Returns the name of the plugin who's classloader will be used as the parent of this plugin.
|
boolean |
isComplete(StringBuilder errorBuffer)
Returns
true if the dependency graph has no missing required plugins. |
PluginDependencyGraph |
reduceGraph()
If the current dependency graph is not yet
complete, you can call
this method to reduce the graph such that plugins with missing required dependencies are removed and
only those plugins whose dependencies exist are in the returned graph. |
String |
toString() |
public void addPlugin(String pluginName, List<PluginDependencyGraph.PluginDependency> dependencies)
If the plugin already exists, it will be overridden such that the given dependencies replace its old ones.
pluginName - the name of the plugin getting added to the graphdependencies - list of plugin names that are dependencies of this pluginpublic String getUseClassesDependency(String pluginName)
the - name of the plugin whose required dependency contains classes that are to be accessible by the pluginnull if there is no required dependencypublic Set<String> getPlugins()
public List<String> getPluginDependencies(String pluginName)
pluginName - the plugin namepublic List<String> getOptionalDependents(String pluginName)
pluginName - the plugin whose dependents are to be returnedpublic Collection<String> getAllDependencies(String pluginName)
getPluginDependencies(String) because this method does a deep
dive and returns all direct dependencies and dependencies of those dependencies.pluginName - the plugin whose dependencies are to be returnedpublic Collection<String> getAllDependents(String pluginName)
pluginName - the plugin whose dependents are to be returnedpublic boolean isComplete(StringBuilder errorBuffer) throws IllegalStateException
true if the dependency graph has no missing required plugins.
That is to say, all required dependencies of all plugins can be found in this graph. If this returns true,
you can safely call getDeploymentOrder() and expect it to return an ordered list of plugins.
This will return false if one or more required dependencies are missing and still need to be
added. This will throw an exception if a circular dependency has been
detected.errorBuffer - if not null and this method returns false, this will be appended
with the error message that will contain information on the first plugin found to be missingtrue if there are no missing dependencies and getDeploymentOrder() can be calledIllegalStateException - if a circular dependency has been detectedpublic List<String> getDeploymentOrder() throws IllegalStateException, IllegalArgumentException
IllegalStateException - if a circular dependency has been detectedIllegalArgumentException - if one or more plugins depend on other plugins that are missing from the graphpublic PluginDependencyGraph reduceGraph()
complete, you can call
this method to reduce the graph such that plugins with missing required dependencies are removed and
only those plugins whose dependencies exist are in the returned graph. In other words, this method will
return a dependency graph that is guaranteed to be complete and return a
getDeploymentOrder() - albeit with only those plugins that currently have all dependencies.Copyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.