|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.core.clientapi.agent.metadata.PluginDependencyGraph
public class PluginDependencyGraph
This class determines the deployment order for plugins by building the dependency graph of the plugins. You use this
class by first 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.
| Nested Class Summary | |
|---|---|
static class |
PluginDependencyGraph.PluginDependency
|
| Constructor Summary | |
|---|---|
PluginDependencyGraph()
|
|
| Method Summary | |
|---|---|
void |
addPlugin(String pluginName,
List<PluginDependencyGraph.PluginDependency> dependencies)
Adds a plugin to the graph. |
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PluginDependencyGraph()
| Method Detail |
|---|
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 plugin
null if there is no required dependencypublic Set<String> getPlugins()
public List<String> getPluginDependencies(String pluginName)
null will be returned if the plugin does not exist in this graph.
Note that if a dependency is not required to exist, and it does not exist, it will not be returned
in the list. This is to say that if a plugin was configured to depend on another plugin, but that
dependency was not required, that other plugin will not be in the returned list if it hasn't been added
to this graph yet.
pluginName - the plugin name
null if the plugin doesn't exist yet in the graph)public List<String> getOptionalDependents(String pluginName)
pluginName - the plugin whose dependents are to be returned
public 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 missing
true if there are no missing dependencies and getDeploymentOrder() can be called
IllegalStateException - if a circular dependency has been detected
public List<String> getDeploymentOrder()
throws IllegalStateException,
IllegalArgumentException
IllegalStateException - if a circular dependency has been detected
IllegalArgumentException - 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.
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||