[jboss-dev-forums] [Design the new POJO MicroContainer] - Scoped Kernels

adrian@jboss.org do-not-reply at jboss.com
Mon Feb 12 08:56:56 EST 2007


Based on the discussion here:
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015013#4015013

I want to fork off part of the discussion which is how to implement the scoped kernel.

Let's start with how the current singleton kernel controller works.
The alogorithm goes something like (uninstall is mainly the reverse):


  | atEveryInstall()
  | {
  |     do
  |     {
  |       // Go through the states in order from lowest (NotInstalled) to highest (Installed)
  |       for (State state : statesInOrder)
  |       {
  |             // Get the contexts that are ready for the next state
  |             // i.e. dependencies are satisifed
  |             for (Context c : readyToPromoteToNextState(s))
  |             {
  |                // Double check because of "manual" and recursive calls
  |                if (notAlreadyPromoted(c))
  |                   promoteToNextState(c);
  |             }
  |        }
  |    }
  |    // We loop because promotions in later states can satisfy dependencies
  |    // in earlier states.
  |    until (nothing changes state);
  | }
  | 

With scoped kernels the parent kernel needs to know about its children.
A context in the scoped kernel can depend upon the parent kernel
but not vice-versa.

So as well as going through the contexts in this kernel
there needs to be an additional:

  | for (Controller child : childControllers)
  | {
  |     child.atEveryInstall(c); 
  | }
  | 

i.e. Once we have no more changes in the parent controller
(i.e. the do until loop exits) we invoke the children.

This alogorithm will avoid any problems with recursion or deadlocks
since everything is done in one order parent -> child.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015020#4015020

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015020



More information about the jboss-dev-forums mailing list