Class CommitOrderCalculator

java.lang.Object
org.eclipse.persistence.internal.sessions.CommitOrderCalculator

public class CommitOrderCalculator extends Object
This class calculates a commit order for a series of classes based on the dependencies between them. It builds up a graph of dependencies (CommitOrderDependencyNodes) then applies topological sort to them to get an ordering. This is a throwaway class, which exists only for the lifetime of the calculation. The algorithm is described in the method comment for orderCommits(). This class also includes static methods for quicksort, copied from the standard libraries and adapted for these objects, since that seemed like the easiest way to sort.
  • Field Details

  • Constructor Details

    • CommitOrderCalculator

      public CommitOrderCalculator(AbstractSession session)
  • Method Details

    • addNode

      protected void addNode(ClassDescriptor d)
    • addNodes

      public void addNodes(Vector descriptors)
    • calculateMappingDependencies

      public void calculateMappingDependencies()
      Add to each node the dependent nodes
    • calculateSpecifiedDependencies

      public void calculateSpecifiedDependencies()
      Add to each node the dependent nodes
    • depthFirstSearch

      public void depthFirstSearch()
    • getNextTime

      public int getNextTime()
    • getNodes

      public Vector<CommitOrderDependencyNode> getNodes()
    • getOrderedClasses

      public Vector getOrderedClasses()
      Return the constraint ordered classes.
    • getOrderedDescriptors

      public Vector getOrderedDescriptors()
      Return the constraint ordered descriptors.
    • nodeFor

      public CommitOrderDependencyNode nodeFor(Class<?> c)
    • nodeFor

    • orderCommits

      public void orderCommits()
      Calculate the commit order. Do a depth first search on the graph, skipping nodes that we have already visited or are in the process of visiting. Keep a counter and note when we first encounter a node and when we finish visiting it. Once we've visited everything, sort nodes by finishing time