gr.uoa.di.madgik.commons.configuration.parameter.elements.graph
Class DependencyGraph

java.lang.Object
  extended by gr.uoa.di.madgik.commons.configuration.parameter.elements.graph.DependencyGraph

public class DependencyGraph
extends java.lang.Object

This class creates a graph representing the dependencies that are marked in the parsed configuration file. The configuration markup allows parameter items to declare that they are dependant from other parameters if they use their values. Typicaly the parameters that can declare such dependencies are those of type IParameter.ParameterType.Object. Respectivly, parameters can declare that they are generated and so they are dependent on the evaluation of the parameter that creates them. Typically, the parameters that can generate values are the ones of type IParameter.ParameterType.Object. The dependencies that this graph can resolve are the ones between parameters. It cannot handle dependencies of a parameter of type IParameter.ParameterType.Object that are generated in a method of the same parameter and are needed in a subsequent method of the same parameter. The graph then resolves the dependencies by evaluating each parameter and generating their values if they are marked as generated or they are of type IParameter.ParameterType.Object and their evaluation creates instnaces that are either the target of the configuration markup or are used internally to instnatiate other parameters. The dependency resolve process is terinated once all parameters are evaluated. If this process cannot be completed due to either incomplete markup or because of cyclic references, the process stops with error. TODO Handle dependencies of an ObjectParameter that are generated in a method of the parameter and are needed by a subsequent method of the same parameter s * @author gpapanikos


Constructor Summary
DependencyGraph(java.util.Map<java.lang.String,IParameter> Params)
          Creates a new instance
 
Method Summary
 java.lang.Boolean AllChecked()
          Checks if all GraphElement entriues have been evaluated
 void ConstructGraph()
          Creates the graph based on the provided parameters
 void ResolveDependencies()
          Resolved the graph nodes dependencies.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyGraph

public DependencyGraph(java.util.Map<java.lang.String,IParameter> Params)
Creates a new instance

Parameters:
Params - the parameters that can be used to retrieve and set values
Method Detail

ConstructGraph

public void ConstructGraph()
                    throws java.lang.Exception
Creates the graph based on the provided parameters

Throws:
java.lang.Exception - The graph could not be constructed

ResolveDependencies

public void ResolveDependencies()
                         throws java.lang.Exception
Resolved the graph nodes dependencies. This method iterrates over all GraphElement nodes and evaluates their values. This process is repeated untill their is no GraphElement that has not been succesfully evaluated. A GraphElement is evaluated only if all the parameters that the GraphElement depends on have already been evaluated. If during the process of a full iteration no GraphElement has been successfully evaluated, the process stops

Throws:
java.lang.Exception - The dependencies could not be resolved

AllChecked

public java.lang.Boolean AllChecked()
Checks if all GraphElement entriues have been evaluated

Returns:
true if all GraphElement entries are evaluated, false otherwise