0 Replies Latest reply on Jan 18, 2006 5:39 AM by Adrian Brock

    JBMICROCONT-56 - create() looping

    Adrian Brock Master

      I knew about this problem and should have left an @todo in the code.
      I was planning to fix it when for the ServiceController port that does the same thing
      as what you are trying to do.

      The problem is the way it determines what contexts need "advancing"

      The controller gets a set of contexts that are ready to advance
      but doesn't change the state until after it has done the install operation.

      The algorithm works fine as long as you don't recursive through resolveContexts.
      Recursing means it will try to advance the context again.


       protected boolean resolveContexts(ControllerState fromState, ControllerState toState, boolean trace)
       boolean resolutions = false;
       Set unresolved = (Set) contextsByState.get(fromState);
       Set resolved = resolveContexts(unresolved, toState, trace);
       if (resolved.isEmpty() == false)
       for (Iterator i = resolved.iterator(); i.hasNext();)
       ControllerContext context = (ControllerContext) i.next();
       Object name = context.getName();
       if (trace)
       log.trace("Dependencies resolved " + name + " for " + toState.getStateString());
       if (incrementState(context, trace))
       resolutions = true;
       if (trace)
       log.trace(name + " " + toState.getStateString());
       return resolutions;

       public void install(ControllerState fromState, ControllerState toState) throws Throwable
       this.error = null;
       actions.install(this, fromState, toState);
       this.state = toState;

      I'll look at fixing it to work properly with recursion.