--- projects/cms/source/server/uk/org/iscream/cms/server/componentmanager/ComponentManager.java 2001/03/01 16:49:49 1.32 +++ projects/cms/source/server/uk/org/iscream/cms/server/componentmanager/ComponentManager.java 2001/03/14 01:34:25 1.33 @@ -14,8 +14,8 @@ import uk.ac.ukc.iscream.util.*; * components as specified in the default.properties under * uk.ac.ukc.iscream.ComponentList * - * @author $Author: ajm $ - * @version $Id: ComponentManager.java,v 1.32 2001/03/01 16:49:49 ajm Exp $ + * @author $Author: tdb $ + * @version $Id: ComponentManager.java,v 1.33 2001/03/14 01:34:25 tdb Exp $ */ public class ComponentManager { @@ -24,7 +24,7 @@ public class ComponentManager { /** * The current CVS revision of this class */ - public static final String REVISION = "$Revision: 1.32 $"; + public static final String REVISION = "$Revision: 1.33 $"; /** * The toString() of this class @@ -98,7 +98,7 @@ public class ComponentManager { // get the list of components String componentList = System.getProperty("uk.ac.ukc.iscream.ComponentList"); StringTokenizer st = new StringTokenizer(componentList, ";"); - _componentsToStart = new ArrayList(); + _componentsToStart = new LinkedList(); // this could be done using reflection // but..well..we don't ;-p @@ -130,7 +130,7 @@ public class ComponentManager { if (component != null) { _componentsToStart.add(component); } else { - System.err.println(toString + ": WARNING unsupported component not started"); + System.err.println(toString + ": WARNING unsupported component not started: "+componentName); } } @@ -154,6 +154,7 @@ public class ComponentManager { // block on the ORB...in time, management functionality can be placed here. // if we detect a CORBA communication error, we'll restart all the components. + // !! this doesn't appear to work !! while(true) { try { refman.getORB().run(); @@ -184,30 +185,33 @@ public class ComponentManager { // maybe add support for a limited number of retries while(tryAgain) { Iterator i = _componentsToStart.iterator(); - ArrayList failedComponents = new ArrayList(); + LinkedList failedComponents = new LinkedList(); // go through all the components while(i.hasNext()) { - try { - component = (Component) i.next(); - System.out.println(toString + ": starting component - " + component.toString()); - - // start the component - component.start(); - - // if we get this then there was a problem - // that we can't recover from - } catch (ComponentStartException e) { - System.err.println(toString + ": ERROR starting component - " + component.toString()); - System.err.println(toString + ": component reports - " + e.getMessage()); - System.exit(1); - - // if we get this exception then we've tried - // to talk to something which may not be up yet - // so we want to try again in a minute - } catch(ComponentCORBAException e2) { - System.err.println(toString + ": WARNING Component reported CORBA communications failure"); + // get a refence to the component + component = (Component) i.next(); + System.out.println(toString + ": starting component - " + component.toString()); + + // check it's dependencies + boolean depOK = component.depCheck(); + if(depOK) { + // it should be ok to start the component + try { + // start the component + component.start(); + } catch (ComponentStartException e) { + // if we get this then there was a problem + // that we can't recover from + System.err.println(toString + ": ERROR starting component - " + component.toString()); + System.err.println(toString + ": component reports - " + e.getMessage()); + System.exit(1); + } + } + else { + // it seems the depedencies failed + // so we want to try again after a delay + System.err.println(toString + ": WARNING Component reported dependency failure"); System.err.println(toString + ": This could be because it can't communicate with components it needs."); - System.err.println(toString + ": component reports - " + e2.getMessage()); // make a list of the failed components failedComponents.add(component); @@ -267,7 +271,7 @@ public class ComponentManager { //---STATIC ATTRIBUTES--- - private static ArrayList _componentsToStart; + private static LinkedList _componentsToStart; private static int _startTimeout = 0; }