org.apache.hivemind.order
Class Orderer

java.lang.Object
  extended by org.apache.hivemind.order.Orderer

public class Orderer
extends java.lang.Object

Used to order objects into an "execution" order. Each object must have a name. It may specify a list of pre-requisites and a list of post-requisites.

Author:
Howard Lewis Ship

Constructor Summary
Orderer(ErrorHandler errorHandler, java.lang.String objectType)
          Creates an instance using org.apache.hivemind.order.Orderer as the Log.
Orderer(ErrorLog errorLog, java.lang.String objectType)
          Creates a new instance.
Orderer(org.apache.commons.logging.Log log, ErrorHandler errorHandler, java.lang.String objectType)
          Creates a new instance, but directs all debug and error logging output to the provided log.
 
Method Summary
 void add(java.lang.Object object, java.lang.String name, java.lang.String prereqs, java.lang.String postreqs)
          Adds a new object.
 java.util.List getOrderedObjects()
          Uses the information provided by add(Object, String, String, String) to order the objects into an appropriate order based on the pre- and post-reqts provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Orderer

public Orderer(ErrorHandler errorHandler,
               java.lang.String objectType)
Creates an instance using org.apache.hivemind.order.Orderer as the Log.


Orderer

public Orderer(org.apache.commons.logging.Log log,
               ErrorHandler errorHandler,
               java.lang.String objectType)
Creates a new instance, but directs all debug and error logging output to the provided log.

Parameters:
log - Used for logging any errors
objectType - user presentable name for the type of object to be ordered; used in some error messages

Orderer

public Orderer(ErrorLog errorLog,
               java.lang.String objectType)
Creates a new instance.

Parameters:
errorLog - Used for log any recoverable errors.
objectType - user presentable name for the type of object to be ordered; used in some error messages
Method Detail

add

public void add(java.lang.Object object,
                java.lang.String name,
                java.lang.String prereqs,
                java.lang.String postreqs)
Adds a new object. All invocations of add(Object, String, String, String) should occur before invoking getOrderedObjects().

Parameters:
object - an object to be sorted into order based on prereqs and postreqs
name - a unique name for the
prereqs - a comma-separated list of the names of objects that should precede this object in the list (or null)
postreqs - a comma-separated list of the names of objects that should follow this object in the list (or null)

getOrderedObjects

public java.util.List getOrderedObjects()
Uses the information provided by add(Object, String, String, String) to order the objects into an appropriate order based on the pre- and post-reqts provided. Errors such as cyclic dependencies or unrecognized names are logged and ignored.



Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.