geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r169154 [3/6] - in /geronimo/trunk: applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/ applications/jmxdebug/src/webapp/WEB-INF/ assemblies/j2ee-server/ etc/ modules/assembly/ modules/assembly/src/plan/ modules/axis-builder/ modules/axis/ modules/classloader-server/ modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/ modules/client-builder/ modules/client-builder/src/java/org/apache/geronimo/client/builder/ modules/client-builder/src/test/org/apache/geronimo/client/builder/ modules/client/ modules/connector-builder/ modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ modules/connector/ modules/connector/src/java/org/apache/geronimo/connector/ modules/connector/src/java/org/apache/geronimo/connector/outbound/ modules/connector/src/test/org/apache/geronimo/connector/ modules/connector/src/test/org/apache/geronimo/connector/outbound/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/ modules/deployment/ modules/deployment/src/java/org/apache/geronimo/deployment/ modules/deployment/src/java/org/apache/geronimo/deployment/util/ modules/interop/ modules/interop/src/test/org/apache/geronimo/interop/ modules/j2ee-builder/ modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/ modules/j2ee/ modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/ modules/j2ee/src/test/org/apache/geronimo/j2ee/management/ modules/jetty-builder/ modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/ modules/jetty/ modules/jetty/src/test/org/apache/geronimo/jetty/ modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/ modules/kernel/ modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ modules/kernel/src/java/org/apache/geronimo/kernel/ modules/kernel/src/java/org/apache/geronimo/kernel/basic/ modules/kernel/src/java/org/apache/geronimo/kernel/config/ modules/kernel/src/java/org/apache/geronimo/kernel/jmx/ modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/ modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ modules/kernel/src/java/org/apache/geronimo/kernel/registry/ modules/kernel/src/test/org/apache/geronimo/gbean/ modules/kernel/src/test/org/apache/geronimo/gbean/runtime/ modules/kernel/src/test/org/apache/geronimo/kernel/ modules/mail/ modules/mail/src/java/org/apache/geronimo/mail/ modules/mail/src/test/org/apache/geronimo/mail/ modules/naming/src/java/org/apache/geronimo/naming/reference/ modules/naming/src/test/org/apache/geronimo/naming/java/ modules/security/ modules/security/src/java/org/apache/geronimo/security/jaas/ modules/security/src/java/org/apache/geronimo/security/realm/ modules/security/src/java/org/apache/geronimo/security/realm/providers/ modules/security/src/test/org/apache/geronimo/security/ modules/security/src/test/org/apache/geronimo/security/jaas/ modules/security/src/test/org/apache/geronimo/security/remoting/jmx/ modules/service-builder/ modules/service-builder/src/java/org/apache/geronimo/deployment/service/ modules/spring-builder/ modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/ modules/spring/ modules/spring/src/java/org/apache/geronimo/spring/ modules/system/ modules/system/src/java/org/apache/geronimo/system/configuration/ modules/system/src/java/org/apache/geronimo/system/jmx/ modules/system/src/java/org/apache/geronimo/system/main/ modules/system/src/test/org/apache/geronimo/system/configuration/ modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/ modules/tomcat-builder/ modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/ modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/ modules/tomcat/ modules/tomcat/src/plan/ modules/tomcat/src/test/org/apache/geronimo/tomcat/ modules/webservices/ plugins/geronimo-packaging-plugin/ plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ plugins/maven-geronimo-plugin/ plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/
Date Sun, 08 May 2005 19:35:28 GMT
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java Sun May  8 12:35:23 2005
@@ -24,8 +24,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;
@@ -190,9 +190,9 @@
             ObjectName child = (ObjectName) iterator.next();
             try {
                 log.trace("Checking if child is running: child=" + child);
-                if (((Integer) kernel.getAttribute(child, "state")).intValue() == State.RUNNING_INDEX) {
+                if (kernel.getGBeanState(child) == State.RUNNING_INDEX) {
                     log.trace("Stopping child: child=" + child);
-                    kernel.invoke(child, "stop", null, null);
+                    kernel.stopGBean(child);
                     log.trace("Stopped child: child=" + child);
                 }
             } catch (Exception ignore) {
@@ -306,14 +306,11 @@
                 }
                 try {
                     log.trace("Checking if parent is running: parent=" + parent);
-                    if (((Integer) kernel.getAttribute(parent, "state")).intValue() != State.RUNNING_INDEX) {
+                    if (kernel.getGBeanState(parent) != State.RUNNING_INDEX) {
                         log.trace("Cannot run because parent is not running: parent=" + parent);
                         return;
                     }
                     log.trace("Parent is running: parent=" + parent);
-                } catch (NoSuchAttributeException e) {
-                    // ok -- parent is not a startable
-                    log.trace("Parent does not have a State attibute");
                 } catch (GBeanNotFoundException e) {
                     // depended on instance was removed bewteen the register check and the invoke
                     log.trace("Cannot run because parent is not registered: parent=" + parent);

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java Sun May  8 12:35:23 2005
@@ -25,8 +25,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java Sun May  8 12:35:23 2005
@@ -16,15 +16,13 @@
  */
 package org.apache.geronimo.kernel;
 
-import java.io.Serializable;
 import java.io.IOException;
-import java.io.ObjectStreamException;
+import java.io.Serializable;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ClassLoaderReference extends ClassLoader implements Serializable {
-
     private ClassLoader classloader;
 
     public ClassLoaderReference(ClassLoader parent) {
@@ -37,7 +35,7 @@
         classloader = objectInputStreamExt.getClassloader();
     }
 
-    private Object readResolve() throws ObjectStreamException {
+    private Object readResolve() {
         return classloader;
     }
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java Sun May  8 12:35:23 2005
@@ -27,7 +27,6 @@
  * @version $Rev$ $Date$
  */
 public class ClassLoading {
-
     /**
      * Load a class for the given name.
      * <p/>

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java Sun May  8 12:35:23 2005
@@ -18,72 +18,24 @@
 package org.apache.geronimo.kernel;
 
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
-import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
-import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
-
 /**
  * DependencyManager is the record keeper of the dependencies in Geronimo.  The DependencyManager
  * does not enforce any dependencies, it is simply a place where components can register their intent
- * to be dependent on another component.  Since a JMX Component can pretty much do whatever it wants
- * a component must watch the components it depends on to assure that they are following the
- * J2EE-Management state machine.
+ * to be dependent on another component.
  * <p/>
  * The DependencyManager uses the nomenclature of parent-child where a child is dependent on a parent.
  * The names parent and child have no other meaning are just a convience to make the code readable.
  *
  * @version $Rev$ $Date$
  */
-public class DependencyManager {
-    /**
-     * The lifecycleMonitor informs us when gbeans go off line,
-     * so we can clean up the lingering dependencies.
-     */
-    private final LifecycleMonitor lifecycleMonitor;
-
-    /**
-     * Listenes for GBeans to unregister and removes all dependencies associated with the dependency
-     */
-    private final LifecycleListener lifecycleListener = new DependencyManagerLifecycleListener();
-
-    /**
-     * A map from child names to a list of parents.
-     */
-    private final Map childToParentMap = new HashMap();
-
+public interface DependencyManager {
     /**
-     * A map from parent back to a list of its children.
+     * Closes the dependency manager releasing all resources
      */
-    private final Map parentToChildMap = new HashMap();
-
-    /**
-     * A map from a component's ObjectName to the list of ObjectPatterns that the component is blocking
-     * from starting.
-     */
-    private final Map startHoldsMap = new HashMap();
-
-    public DependencyManager(LifecycleMonitor lifecycleMonitor) throws Exception {
-        assert lifecycleMonitor != null;
-        this.lifecycleMonitor = lifecycleMonitor;
-        lifecycleMonitor.addLifecycleListener(lifecycleListener, new ObjectName("*:*"));
-    }
-
-    public synchronized void close() {
-        lifecycleMonitor.removeLifecycleListener(lifecycleListener);
-        childToParentMap.clear();
-        parentToChildMap.clear();
-        startHoldsMap.clear();
-    }
+    public void close();
 
     /**
      * Declares a dependency from a child to a parent.
@@ -91,21 +43,7 @@
      * @param child the dependent component
      * @param parent the component the child is depending on
      */
-    public synchronized void addDependency(ObjectName child, ObjectName parent) {
-        Set parents = (Set) childToParentMap.get(child);
-        if (parents == null) {
-            parents = new HashSet();
-            childToParentMap.put(child, parents);
-        }
-        parents.add(parent);
-
-        Set children = (Set) parentToChildMap.get(parent);
-        if (children == null) {
-            children = new HashSet();
-            parentToChildMap.put(parent, children);
-        }
-        children.add(child);
-    }
+    public void addDependency(ObjectName child, ObjectName parent);
 
     /**
      * Removes a dependency from a child to a parent
@@ -113,37 +51,14 @@
      * @param child the dependnet component
      * @param parent the component that the child wil no longer depend on
      */
-    public synchronized void removeDependency(ObjectName child, ObjectName parent) {
-        Set parents = (Set) childToParentMap.get(child);
-        if (parents != null) {
-            parents.remove(parent);
-        }
-
-        Set children = (Set) parentToChildMap.get(parent);
-        if (children != null) {
-            children.remove(child);
-        }
-    }
+    public void removeDependency(ObjectName child, ObjectName parent);
 
     /**
      * Removes all dependencies for a child
      *
      * @param child the component that will no longer depend on anything
      */
-    public synchronized void removeAllDependencies(ObjectName child) {
-        Set parents = (Set) childToParentMap.remove(child);
-        if (parents == null) {
-            return;
-        }
-        for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
-            ObjectName parent = (ObjectName) iterator.next();
-            Set children = (Set) parentToChildMap.get(parent);
-            if (children != null) {
-                children.remove(child);
-            }
-
-        }
-    }
+    public void removeAllDependencies(ObjectName child);
 
     /**
      * Adds dependencies from the child to every parent in the parents set
@@ -151,25 +66,7 @@
      * @param child the dependent component
      * @param parents the set of components the child is depending on
      */
-    public synchronized void addDependencies(ObjectName child, Set parents) {
-        Set existingParents = (Set) childToParentMap.get(child);
-        if (existingParents == null) {
-            existingParents = new HashSet(parents);
-            childToParentMap.put(child, existingParents);
-        } else {
-            existingParents.addAll(parents);
-        }
-
-        for (Iterator i = parents.iterator(); i.hasNext();) {
-            Object startParent = i.next();
-            Set children = (Set) parentToChildMap.get(startParent);
-            if (children == null) {
-                children = new HashSet();
-                parentToChildMap.put(startParent, children);
-            }
-            children.add(child);
-        }
-    }
+    public void addDependencies(ObjectName child, Set parents);
 
     /**
      * Gets the set of parents that the child is depending on
@@ -177,13 +74,7 @@
      * @param child the dependent component
      * @return a collection containing all of the components the child depends on; will never be null
      */
-    public synchronized Set getParents(ObjectName child) {
-        Set parents = (Set) childToParentMap.get(child);
-        if (parents == null) {
-            return Collections.EMPTY_SET;
-        }
-        return new HashSet(parents);
-    }
+    public Set getParents(ObjectName child);
 
     /**
      * Gets all of the MBeans that have a dependency on the specified startParent.
@@ -191,13 +82,7 @@
      * @param parent the component the returned childen set depend on
      * @return a collection containing all of the components that depend on the parent; will never be null
      */
-    public synchronized Set getChildren(ObjectName parent) {
-        Set children = (Set) parentToChildMap.get(parent);
-        if (children == null) {
-            return Collections.EMPTY_SET;
-        }
-        return new HashSet(children);
-    }
+    public Set getChildren(ObjectName parent);
 
     /**
      * Adds a hold on a collection of object name patterns.  If the name of a component matches an object name
@@ -206,15 +91,7 @@
      * @param objectName the name of the component placing the holds
      * @param holds a collection of object name patterns which should not start
      */
-    public synchronized void addStartHolds(ObjectName objectName, Collection holds) {
-        Collection currentHolds = (Collection) startHoldsMap.get(objectName);
-        if (currentHolds == null) {
-            currentHolds = new LinkedList(holds);
-            startHoldsMap.put(objectName, currentHolds);
-        } else {
-            currentHolds.addAll(holds);
-        }
-    }
+    public void addStartHolds(ObjectName objectName, Collection holds);
 
     /**
      * Removes a collection of holds.
@@ -222,50 +99,20 @@
      * @param objectName the object name of the components owning the holds
      * @param holds a collection of the holds to remove
      */
-    public synchronized void removeStartHolds(ObjectName objectName, Collection holds) {
-        Collection currentHolds = (Collection) startHoldsMap.get(objectName);
-        if (currentHolds != null) {
-            currentHolds.removeAll(holds);
-        }
-    }
+    public void removeStartHolds(ObjectName objectName, Collection holds);
 
     /**
      * Removes all of the holds owned by a component.
      *
      * @param objectName the object name of the component that will no longer have any holds
      */
-    public synchronized void removeAllStartHolds(ObjectName objectName) {
-        startHoldsMap.remove(objectName);
-    }
-
-    /**
-     * Gets the object name of the mbean blocking the start specified mbean.
-     *
-     * @param objectName the mbean to check for blockers
-     * @return the mbean blocking the specified mbean, or null if there are no blockers
-     */
-    public synchronized ObjectName checkBlocker(ObjectName objectName) {
-        // check if objectName name is on one of the hold lists
-        for (Iterator iterator = startHoldsMap.keySet().iterator(); iterator.hasNext();) {
-            ObjectName blocker = (ObjectName) iterator.next();
-            List holds = (List) startHoldsMap.get(blocker);
-            for (Iterator holdsIterator = holds.iterator(); holdsIterator.hasNext();) {
-                ObjectName pattern = (ObjectName) holdsIterator.next();
-                if (pattern.apply(objectName)) {
-                    return blocker;
-                }
-            }
-        }
-        return null;
-    }
-
-    private class DependencyManagerLifecycleListener extends LifecycleAdapter {
-        public void unloaded(ObjectName objectName) {
-            synchronized (DependencyManager.this) {
-                removeAllDependencies(objectName);
-                removeAllStartHolds(objectName);
-            }
+    public void removeAllStartHolds(ObjectName objectName);
 
-        }
-    }
+    /**
+     * Gets the object name of the bean blocking the start specified bean.
+     *
+     * @param objectName the bean to check for blockers
+     * @return the bean blocking the specified bean, or null if there are no blockers
+     */
+    public ObjectName checkBlocker(ObjectName objectName);
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java Sun May  8 12:35:23 2005
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2005 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -14,561 +14,260 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.geronimo.kernel;
 
-import java.io.IOException;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.net.URI;
-import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
-import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanName;
-import org.apache.geronimo.gbean.runtime.GBeanInstance;
-import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.NoSuchStoreException;
-import org.apache.geronimo.kernel.jmx.JMXLifecycleBroadcaster;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.lifecycle.BasicLifecycleMonitor;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
-import org.apache.geronimo.kernel.lifecycle.LifecycleMonitorFlyweight;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
-import org.apache.geronimo.kernel.registry.BasicGBeanRegistry;
-import org.apache.geronimo.kernel.registry.GBeanRegistry;
-
 
 /**
- * The core of a Geronimo instance.
- * A Kernel is responsible for managing the Configurations that comprise a
- * Geronimo system and exposing them using JMX. Each Kernel is associated
- * with an MBeanServer that is used to register the Configurations themselves
- * and the MBeans they define.
- * <p/>
- * Dependencies between MBeans are handled by a dedicated DependencyManager
- * that is responsible for tracking those dependencies and ensuring that the
- * dependent objects follow the appropriate lifecycle and receive appropriate
- * notifications.
- * <p/>
- * The Kernel also provides a ConfigurationStore which is used to stage
- * installed Configurations (providing a local filesystem based classpath) and
- * used hold the persistent state of each Configuration. This allows
- * Configurations to restart in the event of system failure.
- * 
- * TODO: Describe the order of method invocation (e.g. if loadGbean may be before boot)
- *
  * @version $Rev$ $Date$
  */
-public class Kernel {
-
+public interface Kernel {
     /**
      * The JMX name used by a Kernel to register itself when it boots.
-     * todo drop "geronimo.boot:" from this name so the kernel shows up in the kernel default domain
      */
-    public static final ObjectName KERNEL = JMXUtil.getObjectName("geronimo.boot:role=Kernel");
+    ObjectName KERNEL = JMXUtil.getObjectName(":role=Kernel");
 
     /**
-     * Index of kernel (Weak) references by kernel name
+     * Get the name of this kernel
+     *
+     * @return the name of this kernel
      */
-    private static final Map kernels = new HashMap();
+    String getKernelName();
 
     /**
-     * ReferenceQueue that watches the weak references to our kernels
+     * Gets the dependency manager kernel service
+     * @return the dependency manager or null if the kernel is not running
      */
-    private static final ReferenceQueue queue = new ReferenceQueue();
+    DependencyManager getDependencyManager();
 
     /**
-     * Helper objects for invoke and getAttribute
+     * Gets the lifecycle monitor kernel service
+     * @return the lifecycle monitor or null if the kernel is not running
      */
-    private static final String[] NO_TYPES = new String[0];
-    private static final Object[] NO_ARGS = new Object[0];
+    LifecycleMonitor getLifecycleMonitor();
 
     /**
-     * Name of the configuration manager
-     * todo drop "geronimo.boot:" from this name so the configuration manger shows up in the kernel default domain
+     * Gets the proxy manager kernel service
+     * @return the proxy manager or null if the kernel is not running
      */
-    private static final ObjectName CONFIGURATION_MANAGER_NAME = JMXUtil.getObjectName("geronimo.boot:role=ConfigurationManager");
+    ProxyManager getProxyManager();
 
     /**
-     * Te pattern we use to find all the configuation stores registered with the kernel
+     * Load a specific GBean into this kernel.
+     * This is intended for applications that are embedding the kernel.
+     *
+     * @param gbeanData the GBean to load
+     * @param classLoader the class loader to use to load the gbean
+     * @throws org.apache.geronimo.kernel.GBeanAlreadyExistsException if the name is already used
+     * @throws org.apache.geronimo.kernel.InternalKernelException if there is a problem during registration
      */
-    private static final ObjectName CONFIGURATION_STORE_PATTERN = JMXUtil.getObjectName("*:j2eeType=ConfigurationStore,*");
+    void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException;
 
     /**
-     * Name of this kernel
+     * Is there a GBean registered with the kernel under the specified name?
+     * @param name the name to check
+     * @return true if there is a gbean registered under the specified name; false otherwise
      */
-    private final String kernelName;
+    boolean isLoaded(ObjectName name);
 
     /**
-     * The log
+     * Start a specific GBean.
+     *
+     * @param name the GBean to start
+     * @throws org.apache.geronimo.kernel.GBeanNotFoundException if the GBean could not be found
+     * @throws InternalKernelException if there GBean is not state manageable or if there is a general error
+     * @throws IllegalStateException If the gbean is disabled
      */
-    private Log log;
+    void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
-     * Is this kernel running?
+     * Start a specific GBean and its children.
+     *
+     * @param name the GBean to start
+     * @throws GBeanNotFoundException if the GBean could not be found
+     * @throws InternalKernelException if there GBean is not state manageable or if there is a general error
+     * @throws IllegalStateException If the gbean is disabled
      */
-    private boolean running;
+    void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
-     * The timestamp when the kernel was started
+     * Stop a specific GBean.
+     *
+     * @param name the GBean to stop
+     * @throws GBeanNotFoundException if the GBean could not be found
+     * @throws InternalKernelException if there GBean is not state manageable or if there is a general error
+     * @throws IllegalStateException If the gbean is disabled
      */
-    private Date bootTime;
+    void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
-     * The gbean registry
+     * Unload a specific GBean.
+     * This is intended for applications that are embedding the kernel.
+     *
+     * @param name the name of the GBean to unregister
+     * @throws GBeanNotFoundException if the GBean could not be found
+     * @throws InternalKernelException if there GBean is a problem while unloading the GBean
      */
-    private final GBeanRegistry gbeanRegistry;
+    void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
-     * Listeners for when the kernel shutdown
+     * Gets the state of the specified GBean.
+     * @param name the name of the GBean
+     * @return the state of the GBean
+     * @throws GBeanNotFoundException if the GBean could not be found
      */
-    private LinkedList shutdownHooks = new LinkedList();
+    int getGBeanState(ObjectName name) throws GBeanNotFoundException;
 
     /**
-     * This manager is used by the kernel to manage dependencies between gbeans
+     * Gets the time the specified GBean was started
+     * @param name the name of the GBean
+     * @return the start time of the GBean or 0 if not running
+     * @throws GBeanNotFoundException if the GBean could not be found
      */
-    private DependencyManager dependencyManager;
+    long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException;
 
     /**
-     * The kernel uses this manager to load configurations which are collections of GBeans
+     * Is the specified GBean enabled?
+     * @param name the name if the GBean
+     * @return true if the gbean is enabled
+     * @throws GBeanNotFoundException if the GBean could not be found
      */
-    private ConfigurationManager configurationManager;
+    boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException;
 
     /**
-     * The GBeanMbean that wraps the configuration manager
+     * Sets the eneabled status of the specified GBean.  A disabled gbean can not be started, and
+     * will not be started via startRecursive.
+     * @param name the name if the GBean
+     * @param enabled the new enabled status
+     * @throws GBeanNotFoundException if the GBean could not be found
      */
-    private GBeanInstance configurationManagerInstance;
+    void setGBeanEnabled(ObjectName name, boolean enabled) throws GBeanNotFoundException;
 
     /**
-     * Monitors the lifecycle of all gbeans.
+     * Gets the ClassLoader used to register the specified GBean
+     * @param name the name of the gbean from which the class loader should be extracted
+     * @return the class loader associated with the specified GBean
+     * @throws GBeanNotFoundException if the specified GBean is not registered with the kernel
      */
-    private BasicLifecycleMonitor lifecycleMonitor;
-    private LifecycleMonitor publicLifecycleMonitor;
+    ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException;
 
     /**
-     * This factory gbean proxies, and tracks all proxies in the system
+     * Return the GBeanInfo for a registered GBean instance.
+     * @param name the name of the GBean whose info should be returned
+     * @return the info for that instance
+     * @throws GBeanNotFoundException if there is no instance with the supplied name
      */
-    private ProxyManager proxyManager;
+    GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException;
 
     /**
-     * No-arg constructor allowing this class to be used as a GBean reference.
+     * Return the GBeanData for a GBean instance.
+     * @param name the name of the GBean whose info should be returned
+     * @return the info for that instance
+     * @throws GBeanNotFoundException if there is no instance with the supplied name
      */
-    protected Kernel() {
-        kernelName = null;
-        gbeanRegistry = null;
-    }
+    GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException;
 
     /**
-     * Construct a Kernel with the specified name and GBeanRegistry implementation.
-     *
-     * @param kernelName the name of the kernel
-     * @param gbeanRegistry the GBeanRegistry implementation to use for this contianer
+     * Returns a Set of all GBeans matching the object name pattern
+     * @return a List of javax.management.ObjectName of matching GBeans registered with this kernel
      */
-    public Kernel(String kernelName, GBeanRegistry gbeanRegistry) {
-        if (kernelName.indexOf(':') >= 0 || kernelName.indexOf('*') >= 0 || kernelName.indexOf('?') >= 0) {
-            throw new IllegalArgumentException("Kernel name may not contain a ':', '*' or '?' character");
-        }
-        this.kernelName = kernelName;
-        this.gbeanRegistry = gbeanRegistry;
-    }
+    Set listGBeans(ObjectName pattern);
 
     /**
-     * Construct a Kernel with the specified name and an unspecified GBeanRegistry implementation.
-     *
-     * @param kernelName the name of the kernel
+     * Returns a Set of all GBeans matching the set of object name pattern
+     * @return a List of javax.management.ObjectName of matching GBeans registered with this kernel
      */
-    public Kernel(String kernelName) {
-        this(kernelName, new BasicGBeanRegistry());
-    }
-
-    public String getKernelName() {
-        return kernelName;
-    }
-
-    public static Set getKernelNames() {
-        synchronized(kernels) {
-            return Collections.unmodifiableSet(kernels.keySet());
-        }
-    }
-    
+    Set listGBeans(Set patterns);
+
     /**
-     * Get a particular kernel indexed by a name
-     *
-     * @param name the name of the kernel to be obtained
-     * @return the kernel that was registered with that name
+     * Gets the value of an attribute on the specified gbean
+     * @param objectName the name of the gbean from which the attribute will be retrieved
+     * @param attributeName the name of the attribute to fetch
+     * @return the value of the attribute
+     * @throws GBeanNotFoundException if there is not a gbean under the specified name
+     * @throws NoSuchAttributeException if the gbean does not contain the specified attribute
+     * @throws Exception if the gbean throws an exception from the getter
      */
-    public static Kernel getKernel(String name) {
-        if (name == null) {
-            return getSingleKernel();
-        }
-        synchronized (kernels) {
-            processQueue();
-            KernelReference ref = (KernelReference) kernels.get(name);
-            if (ref != null) {
-                return (Kernel) ref.get();
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Obtain the single kernel that's registered.
-     * <p/>
-     * <p>This method assumes that there is only one kernel registered and will throw an
-     * <code>IllegalStateException</code> if more than one has been registered.
-     *
-     * @return the single kernel that's registered
-     * @throws IllegalStateException if more than one
+    Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+
+    /**
+     * Sets the value of an attribute on the specified gbean
+     * @param objectName the name of the gbean from in which the new attribute value will be set
+     * @param attributeName the name of the attribute to set
+     * @param attributeValue the new value of the attribute
+     * @throws GBeanNotFoundException if there is not a gbean under the specified name
+     * @throws NoSuchAttributeException if the gbean does not contain the specified attribute
+     * @throws Exception if the gbean throws an exception from the setter
      */
-    public static Kernel getSingleKernel() {
-        synchronized (kernels) {
-            processQueue();
-
-            int size = kernels.size();
-            if (size > 1) throw new IllegalStateException("More than one kernel has been registered.");
-            if (size < 1) return null;
-
-            Kernel result = (Kernel) ((KernelReference) kernels.values().iterator().next()).get();
-            if (result == null) {
-                kernels.clear();
-            }
-            return result;
-        }
-    }
-
-    /**
-     * @deprecated this will be removed as when we add generalized dependencies to gbeans... the only current user is Configuration
-     */
-    public DependencyManager getDependencyManager() {
-        return dependencyManager;
-    }
-
-    public ConfigurationManager getConfigurationManager() {
-        return configurationManager;
-    }
-
-    /**
-     * Gets the lifecycle monitor.
-     * @deprecated don't use this yet... it may change or go away
-     */
-    public LifecycleMonitor getLifecycleMonitor() {
-        return publicLifecycleMonitor;
-    }
-
-    /**
-     * Gets the proxy manager.
-     * @deprecated don't use this yet... it may change or go away
-     */
-    public ProxyManager getProxyManager() {
-        return proxyManager;
-    }
-
-    public Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(objectName));
-        return gbeanInstance.getAttribute(attributeName);
-    }
-
-    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(objectName));
-        gbeanInstance.setAttribute(attributeName, attributeValue);
-    }
-
-    public Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
-        return invoke(objectName, methodName, NO_ARGS, NO_TYPES);
-    }
-
-    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(objectName));
-        return gbeanInstance.invoke(methodName, args, types);
-    }
-
-    public boolean isLoaded(ObjectName name) {
-        return gbeanRegistry.isRegistered(new GBeanName(name));
-    }
-
-    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(name));
-        return gbeanInstance.getGBeanInfo();
-    }
-
-    public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(name));
-        return gbeanInstance.getGBeanData();
-    }
-
-    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
-        ObjectName objectName = gbeanData.getName();
-        GBeanInstance gbeanInstance = new GBeanInstance(gbeanData, this, dependencyManager, lifecycleMonitor.createLifecycleBroadcaster(objectName), classLoader);
-        gbeanRegistry.register(gbeanInstance);
-    }
-
-    /**
-     * @deprecated use loadGBean(GBeanData gbeanData, ClassLoader classLoader)
-     */
-    public void loadGBean(ObjectName name, org.apache.geronimo.gbean.jmx.GBeanMBean gbean) throws GBeanAlreadyExistsException, InternalKernelException {
-        GBeanData gbeanData = gbean.getGBeanData();
-        gbeanData.setName(name);
-        ClassLoader classLoader = gbean.getClassLoader();
-        loadGBean(gbeanData, classLoader);
-    }
-
-    public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(name));
-        gbeanInstance.start();
-    }
-
-    public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(name));
-        gbeanInstance.startRecursive();
-    }
-
-    public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(name));
-        gbeanInstance.stop();
-    }
-
-    public void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
-        GBeanName gbeanName = new GBeanName(name);
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(gbeanName);
-        gbeanInstance.die();
-        gbeanRegistry.unregister(gbeanName);
-    }
-
-    public Set listGBeans(ObjectName pattern) {
-        String domain = (pattern == null || pattern.isDomainPattern()) ? null : pattern.getDomain();
-        Map props = pattern == null ? null : pattern.getKeyPropertyList();
-        Set gbeans = gbeanRegistry.listGBeans(domain, props);
-        Set result = new HashSet(gbeans.size());
-        for (Iterator i = gbeans.iterator(); i.hasNext();) {
-            GBeanInstance instance = (GBeanInstance) i.next();
-            result.add(instance.getObjectNameObject());
-        }
-        return result;
-    }
-
-    public Set listGBeans(Set patterns) {
-        Set gbeans = new HashSet();
-        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
-            ObjectName pattern = (ObjectName) iterator.next();
-            gbeans.addAll(listGBeans(pattern));
-        }
-        return gbeans;
-    }
-
-    public List listConfigurationStores() {
-        return getConfigurationManager().listStores();
-    }
-
-    public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
-        return getConfigurationManager().listConfigurations(storeName);
-    }
-
-    public ObjectName startConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException, InternalKernelException {
-        ObjectName configName = getConfigurationManager().load(configID);
-		try {
-		    startRecursiveGBean(configName);
-		} catch (GBeanNotFoundException e) {
-		    // should not happen as we just loaded it
-		    throw new InvalidConfigException(e);
-		}
-		return configName;
-    }
-
-    public void stopConfiguration(URI configID) throws NoSuchConfigException, InternalKernelException {
-        ConfigurationManager configurationManager = getConfigurationManager();
-        try {
-            ObjectName configName = Configuration.getConfigurationObjectName(configID);
-            stopGBean(configName);
-        } catch (MalformedObjectNameException e) {
-            throw new NoSuchConfigException(e);
-        } catch (GBeanNotFoundException e) {
-            throw new NoSuchConfigException(e);
-        }
-        configurationManager.unload(configID);
-    }
-
-    public int getConfigurationState(URI configID) throws NoSuchConfigException, InternalKernelException {
-        GBeanInstance gbeanInstance = null;
-        try {
-            ObjectName configName = Configuration.getConfigurationObjectName(configID);
-            gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(configName));
-        } catch (MalformedObjectNameException e) {
-            throw new NoSuchConfigException(e);
-        } catch (GBeanNotFoundException e) {
-            throw new NoSuchConfigException(e);
-        }
-        return gbeanInstance.getState();
-    }
+    void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
 
     /**
-     * Boot this Kernel, triggering the instantiation of the MBeanServer and DependencyManager,
-     * and the registration of ConfigurationStore
-     *
-     * @throws java.lang.Exception if the boot fails
+     * Invokes a no-argument method on the specified GBean
+     * @param objectName the name of the gbean from in which the new attribute value will be set
+     * @param methodName the name of the method to invoke
+     * @return the return value of the method or null if the specified method does not return a value
+     * @throws GBeanNotFoundException if there is not a gbean under the specified name
+     * @throws NoSuchOperationException if the gbean does not have the specified operation
+     * @throws InternalKernelException if an error occurs within the kernel itself
+     * @throws Exception if the method throws an exception
+     */
+    Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+
+    /**
+     * Invokes a method on the specified GBean with the specified arguments
+     * @param objectName the name of the gbean from in which the new attribute value will be set
+     * @param methodName the name of the method to invoke
+     * @param args the arguments to pass to the method
+     * @param types the types of the arguments; the types are used to determine the signature of the mehod that should be invoked
+     * @return the return value of the method or null if the specified method does not return a value
+     * @throws GBeanNotFoundException if there is not a gbean under the specified name
+     * @throws NoSuchOperationException if the gbean does not have the specified operation
+     * @throws InternalKernelException if an error occurs within the kernel itself
+     * @throws Exception if the method throws an exception
+     */
+    Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+
+    /**
+     * Brings the kernel online
+     * @throws Exception if the kernel can not boot
+     */
+    void boot() throws Exception;
+
+    /**
+     * Returns the time this kernel was last booted.
+     * @return the time this kernel was last booted; null if the kernel has not been
+     */
+    Date getBootTime();
+
+    /**
+     * Registers a runnable to execute when the kernel is shutdown
+     * @param hook a runnable to execute when the kernel is shutdown
      */
-    public void boot() throws Exception {
-        if (running) {
-            return;
-        }
-        bootTime = new Date();
-        log = LogFactory.getLog(Kernel.class.getName());
-        log.info("Starting boot");
-
-        // todo cleanup when boot fails
-        synchronized (kernels) {
-            if (kernels.containsKey(kernelName)) {
-                throw new IllegalStateException("A kernel is already running this kernel name: " + kernelName);
-            }
-            kernels.put(kernelName, new KernelReference(kernelName, this));
-        }
-
-        gbeanRegistry.start(this);
-
-        lifecycleMonitor = new BasicLifecycleMonitor(this);
-        publicLifecycleMonitor = new LifecycleMonitorFlyweight(lifecycleMonitor);
-        dependencyManager = new DependencyManager(publicLifecycleMonitor);
-        proxyManager = new ProxyManager(this);
-
-        // set up the data for the new configuration manager instance
-        GBeanData configurationData = new GBeanData(CONFIGURATION_MANAGER_NAME, ConfigurationManagerImpl.GBEAN_INFO);
-        configurationData.setReferencePatterns("Stores", Collections.singleton(CONFIGURATION_STORE_PATTERN));
-
-        // create the connfiguration manager instance
-        JMXLifecycleBroadcaster lifecycleBroadcaster = new JMXLifecycleBroadcaster(CONFIGURATION_MANAGER_NAME, lifecycleMonitor.createLifecycleBroadcaster(CONFIGURATION_MANAGER_NAME));
-        configurationManagerInstance = new GBeanInstance(configurationData, this, dependencyManager, lifecycleBroadcaster, getClass().getClassLoader());
-        configurationManagerInstance.start();
-        configurationManager = (ConfigurationManager) configurationManagerInstance.getTarget();
-        assert configurationManager != null: "ConfigurationManager failed to start";
-        gbeanRegistry.register(configurationManagerInstance);
-
-        // load and start the kernel gbean
-        GBeanData kernelGBeanData = new GBeanData(KERNEL, KernelGBean.GBEAN_INFO);
-        loadGBean(kernelGBeanData, getClass().getClassLoader());
-        startGBean(KERNEL);
-
-        running = true;
-        log.info("Booted");
-    }
-
-    public Date getBootTime() {
-        return bootTime;
-    }
-
-    public void registerShutdownHook(Runnable hook) {
-        assert hook != null : "Shutdown hook was null";
-        synchronized (shutdownHooks) {
-            shutdownHooks.add(hook);
-        }
-    }
-
-    public void unregisterShutdownHook(Runnable hook) {
-        synchronized (shutdownHooks) {
-            shutdownHooks.remove(hook);
-        }
-    }
-
-    /**
-     * Shut down this kernel instance, unregistering the MBeans and releasing
-     * the MBeanServer.
-     */
-    public void shutdown() {
-        if (!running) {
-            return;
-        }
-        running = false;
-        log.info("Starting kernel shutdown");
-
-        notifyShutdownHooks();
-        shutdownConfigManager();
-
-        gbeanRegistry.stop();
-
-        dependencyManager.close();
-        dependencyManager = null;
-
-        synchronized (this) {
-            notify();
-        }
-
-        synchronized (kernels) {
-            kernels.remove(kernelName);
-        }
-
-        log.info("Kernel shutdown complete");
-    }
-
-    private void notifyShutdownHooks() {
-        while (!shutdownHooks.isEmpty()) {
-            Runnable hook;
-            synchronized (shutdownHooks) {
-                hook = (Runnable) shutdownHooks.removeFirst();
-            }
-            try {
-                hook.run();
-            } catch (Throwable e) {
-                log.warn("Error from kernel shutdown hook", e);
-            }
-        }
-    }
-
-    private void shutdownConfigManager() {
-        configurationManager = null;
-        if (configurationManagerInstance != null) {
-            try {
-                configurationManagerInstance.stop();
-            } catch (Exception e) {
-                // ignore
-            }
-            try {
-                gbeanRegistry.unregister(new GBeanName(CONFIGURATION_MANAGER_NAME));
-            } catch (Exception e) {
-                // ignore
-            }
-            configurationManagerInstance = null;
-        }
-    }
-
-    public boolean isRunning() {
-        return running;
-    }
-
-    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException {
-        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(new GBeanName(name));
-        return gbeanInstance.getClassLoader();
-    }
-
-    private static void processQueue() {
-        KernelReference kernelRef;
-        while ((kernelRef = (KernelReference) queue.poll()) != null) {
-            synchronized (kernels) {
-                kernels.remove(kernelRef.key);
-            }
-        }
-    }
-
-    private static class KernelReference extends WeakReference {
-        private final Object key;
-
-        public KernelReference(Object key, Object kernel) {
-            super(kernel, queue);
-            this.key = key;
-        }
-    }
+    void registerShutdownHook(Runnable hook);
+
+    /**
+     * Unregisters a runnable from the list to execute when the kernel is shutdown
+     * @param hook the runnable that should be removed
+     */
+    void unregisterShutdownHook(Runnable hook);
+
+    /**
+     * Stops the kernel
+     */
+    void shutdown();
+
+    /**
+     * Has the kernel been booted
+     * @return true if the kernel has been booted; false otherwise
+     */
+    boolean isRunning();
+
 }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactory.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactory.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactory.java Sun May  8 12:35:23 2005
@@ -0,0 +1,89 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.geronimo.kernel.basic.BasicKernelFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class KernelFactory {
+    public static final String KERNEL_FACTORY_KEY = KernelFactory.class.getName();
+
+    public static KernelFactory newInstance() {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader == null) {
+            classLoader = KernelFactory.class.getClassLoader();
+        }
+
+        // System property
+        try {
+            String kernelFactoryName = System.getProperty(KERNEL_FACTORY_KEY);
+            if (kernelFactoryName != null) {
+                return createKernelFactory(kernelFactoryName, classLoader);
+            }
+        } catch (SecurityException se) {
+        }
+
+        // Jar Service Specification - http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html
+        String serviceId = "META-INF/services/" + KERNEL_FACTORY_KEY;
+        InputStream inputStream = null;
+        try {
+            inputStream = classLoader.getResourceAsStream(serviceId);
+            if (inputStream != null) {
+                BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+                String kernelFactoryName = reader.readLine();
+                reader.close();
+
+                if (kernelFactoryName != null && kernelFactoryName.length() > 0) {
+                    return createKernelFactory(kernelFactoryName, classLoader);
+                }
+            }
+        } catch (Exception ignored) {
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException ignored) {
+                }
+                inputStream = null;
+            }
+        }
+
+        // Default is the basic kernel
+        return new BasicKernelFactory();
+    }
+
+    private static KernelFactory createKernelFactory(String className, ClassLoader classLoader) {
+        try {
+            return (KernelFactory) classLoader.loadClass(className).newInstance();
+        } catch (ClassCastException e) {
+            throw new KernelFactoryError("Kernel factory class does not implement KernelFactory: " + className);
+        } catch (ClassNotFoundException e) {
+            throw new KernelFactoryError("Kernel factory class not found: " + className);
+        } catch (Exception e) {
+            throw new KernelFactoryError("Unable to instantiate kernel factory class: " + className, e);
+        }
+    }
+
+    public abstract Kernel createKernel(String kernelName);
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactoryError.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactoryError.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactoryError.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelFactoryError.java Sun May  8 12:35:23 2005
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class KernelFactoryError extends Error {
+    public KernelFactoryError() {
+        super();
+    }
+
+    public KernelFactoryError(String message) {
+        super(message);
+    }
+
+    public KernelFactoryError(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public KernelFactoryError(Throwable cause) {
+        super(cause);
+    }
+}

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java Sun May  8 12:35:23 2005
@@ -16,31 +16,42 @@
  */
 package org.apache.geronimo.kernel;
 
-import java.io.IOException;
-import java.net.URI;
 import java.util.Date;
-import java.util.List;
 import java.util.Set;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
 
 /**
  * @version $Rev$ $Date$
  */
-public class KernelGBean {
+public class KernelGBean implements Kernel{
     private final Kernel kernel;
 
     public KernelGBean(Kernel kernel) {
         this.kernel = kernel;
     }
 
+    public DependencyManager getDependencyManager() {
+        return kernel.getDependencyManager();
+    }
+
+    public LifecycleMonitor getLifecycleMonitor() {
+        return kernel.getLifecycleMonitor();
+    }
+
+    public ProxyManager getProxyManager() {
+        return kernel.getProxyManager();
+    }
+
+    public void boot() throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
     public Date getBootTime() {
         return kernel.getBootTime();
     }
@@ -69,32 +80,24 @@
         kernel.unloadGBean(name);
     }
 
-    public boolean isRunning() {
-        return kernel.isRunning();
-    }
-
-    public ConfigurationManager getConfigurationManager() {
-        return kernel.getConfigurationManager();
+    public int getGBeanState(ObjectName name) throws GBeanNotFoundException {
+        return kernel.getGBeanState(name);
     }
 
-    public List listConfigurationStores() {
-        return kernel.listConfigurationStores();
+    public long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException {
+        return kernel.getGBeanStartTime(name);
     }
 
-    public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
-        return kernel.listConfigurations(storeName);
+    public boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException {
+        return kernel.isGBeanEnabled(name);
     }
 
-    public ObjectName startConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
-        return kernel.startConfiguration(configID);
+    public void setGBeanEnabled(ObjectName name, boolean enabled) throws GBeanNotFoundException {
+        kernel.setGBeanEnabled(name, enabled);
     }
 
-    public void stopConfiguration(URI configID) throws NoSuchConfigException {
-        kernel.stopConfiguration(configID);
-    }
-
-    public int getConfigurationState(URI configId) throws NoSuchConfigException {
-        return kernel.getConfigurationState(configId);
+    public boolean isRunning() {
+        return kernel.isRunning();
     }
 
     public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException, InternalKernelException {

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelRegistry.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelRegistry.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelRegistry.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelRegistry.java Sun May  8 12:35:23 2005
@@ -0,0 +1,124 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel;
+
+import java.lang.ref.WeakReference;
+import java.lang.ref.ReferenceQueue;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Collections;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class KernelRegistry {
+    /**
+     * Index of kernel references by kernel name
+     */
+    private static final Map kernels = new HashMap();
+
+    /**
+     * ReferenceQueue that watches the weak references to our kernels
+     */
+    private static final ReferenceQueue queue = new ReferenceQueue();
+
+    public static Set getKernelNames() {
+        synchronized(kernels) {
+            return Collections.unmodifiableSet(kernels.keySet());
+        }
+    }
+
+    /**
+     * Get a particular kernel indexed by a name
+     *
+     * @param name the name of the kernel to be obtained
+     * @return the kernel that was registered with that name
+     */
+    public static Kernel getKernel(String name) {
+        if (name == null) {
+            return getSingleKernel();
+        }
+        synchronized (kernels) {
+            processQueue();
+            KernelReference ref = (KernelReference) kernels.get(name);
+            if (ref != null) {
+                return (Kernel) ref.get();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Obtain the single kernel that's registered.
+     * <p/>
+     * <p>This method assumes that there is only one kernel registered and will throw an
+     * <code>IllegalStateException</code> if more than one has been registered.
+     *
+     * @return the single kernel that's registered
+     * @throws IllegalStateException if more than one
+     */
+    public static Kernel getSingleKernel() {
+        synchronized (kernels) {
+            processQueue();
+
+            int size = kernels.size();
+            if (size > 1) throw new IllegalStateException("More than one kernel has been registered.");
+            if (size < 1) return null;
+
+            Kernel result = (Kernel) ((KernelReference) kernels.values().iterator().next()).get();
+            if (result == null) {
+                kernels.clear();
+            }
+            return result;
+        }
+    }
+
+    public static void registerKernel(Kernel kernel) {
+        synchronized (kernels) {
+            String kernelName = kernel.getKernelName();
+            if (kernels.containsKey(kernelName)) {
+                throw new IllegalStateException("A kernel is already running this kernel name: " + kernelName);
+            }
+            kernels.put(kernelName, new KernelReference(kernelName, kernel));
+        }
+    }
+
+    public static void unregisterKernel(Kernel kernel) {
+        synchronized (kernels) {
+            kernels.remove(kernel.getKernelName());
+        }
+    }
+
+    private static void processQueue() {
+        KernelReference kernelRef;
+        while ((kernelRef = (KernelReference) queue.poll()) != null) {
+            synchronized (kernels) {
+                kernels.remove(kernelRef.key);
+            }
+        }
+    }
+
+    private static class KernelReference extends WeakReference {
+        private final Object key;
+
+        public KernelReference(Object key, Object kernel) {
+            super(kernel, queue);
+            this.key = key;
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java Sun May  8 12:35:23 2005
@@ -0,0 +1,272 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.basic;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.DependencyManager;
+
+/**
+ * DependencyManager is the record keeper of the dependencies in Geronimo.  The DependencyManager
+ * does not enforce any dependencies, it is simply a place where components can register their intent
+ * to be dependent on another component.  Since a JMX Component can pretty much do whatever it wants
+ * a component must watch the components it depends on to assure that they are following the
+ * J2EE-Management state machine.
+ * <p/>
+ * The DependencyManager uses the nomenclature of parent-child where a child is dependent on a parent.
+ * The names parent and child have no other meaning are just a convience to make the code readable.
+ *
+ * @version $Rev: 124822 $ $Date: 2005-01-10 11:01:13 -0800 (Mon, 10 Jan 2005) $
+ */
+public class BasicDependencyManager implements DependencyManager {
+    /**
+     * The lifecycleMonitor informs us when gbeans go off line,
+     * so we can clean up the lingering dependencies.
+     */
+    private final LifecycleMonitor lifecycleMonitor;
+
+    /**
+     * Listenes for GBeans to unregister and removes all dependencies associated with the dependency
+     */
+    private final LifecycleListener lifecycleListener = new DependencyManagerLifecycleListener();
+
+    /**
+     * A map from child names to a list of parents.
+     */
+    private final Map childToParentMap = new HashMap();
+
+    /**
+     * A map from parent back to a list of its children.
+     */
+    private final Map parentToChildMap = new HashMap();
+
+    /**
+     * A map from a component's ObjectName to the list of ObjectPatterns that the component is blocking
+     * from starting.
+     */
+    private final Map startHoldsMap = new HashMap();
+
+    public BasicDependencyManager(LifecycleMonitor lifecycleMonitor) throws Exception {
+        assert lifecycleMonitor != null;
+        this.lifecycleMonitor = lifecycleMonitor;
+        lifecycleMonitor.addLifecycleListener(lifecycleListener, new ObjectName("*:*"));
+    }
+
+    public synchronized void close() {
+        lifecycleMonitor.removeLifecycleListener(lifecycleListener);
+        childToParentMap.clear();
+        parentToChildMap.clear();
+        startHoldsMap.clear();
+    }
+
+    /**
+     * Declares a dependency from a child to a parent.
+     *
+     * @param child the dependent component
+     * @param parent the component the child is depending on
+     */
+    public synchronized void addDependency(ObjectName child, ObjectName parent) {
+        Set parents = (Set) childToParentMap.get(child);
+        if (parents == null) {
+            parents = new HashSet();
+            childToParentMap.put(child, parents);
+        }
+        parents.add(parent);
+
+        Set children = (Set) parentToChildMap.get(parent);
+        if (children == null) {
+            children = new HashSet();
+            parentToChildMap.put(parent, children);
+        }
+        children.add(child);
+    }
+
+    /**
+     * Removes a dependency from a child to a parent
+     *
+     * @param child the dependnet component
+     * @param parent the component that the child wil no longer depend on
+     */
+    public synchronized void removeDependency(ObjectName child, ObjectName parent) {
+        Set parents = (Set) childToParentMap.get(child);
+        if (parents != null) {
+            parents.remove(parent);
+        }
+
+        Set children = (Set) parentToChildMap.get(parent);
+        if (children != null) {
+            children.remove(child);
+        }
+    }
+
+    /**
+     * Removes all dependencies for a child
+     *
+     * @param child the component that will no longer depend on anything
+     */
+    public synchronized void removeAllDependencies(ObjectName child) {
+        Set parents = (Set) childToParentMap.remove(child);
+        if (parents == null) {
+            return;
+        }
+        for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+            ObjectName parent = (ObjectName) iterator.next();
+            Set children = (Set) parentToChildMap.get(parent);
+            if (children != null) {
+                children.remove(child);
+            }
+
+        }
+    }
+
+    /**
+     * Adds dependencies from the child to every parent in the parents set
+     *
+     * @param child the dependent component
+     * @param parents the set of components the child is depending on
+     */
+    public synchronized void addDependencies(ObjectName child, Set parents) {
+        Set existingParents = (Set) childToParentMap.get(child);
+        if (existingParents == null) {
+            existingParents = new HashSet(parents);
+            childToParentMap.put(child, existingParents);
+        } else {
+            existingParents.addAll(parents);
+        }
+
+        for (Iterator i = parents.iterator(); i.hasNext();) {
+            Object startParent = i.next();
+            Set children = (Set) parentToChildMap.get(startParent);
+            if (children == null) {
+                children = new HashSet();
+                parentToChildMap.put(startParent, children);
+            }
+            children.add(child);
+        }
+    }
+
+    /**
+     * Gets the set of parents that the child is depending on
+     *
+     * @param child the dependent component
+     * @return a collection containing all of the components the child depends on; will never be null
+     */
+    public synchronized Set getParents(ObjectName child) {
+        Set parents = (Set) childToParentMap.get(child);
+        if (parents == null) {
+            return Collections.EMPTY_SET;
+        }
+        return new HashSet(parents);
+    }
+
+    /**
+     * Gets all of the MBeans that have a dependency on the specified startParent.
+     *
+     * @param parent the component the returned childen set depend on
+     * @return a collection containing all of the components that depend on the parent; will never be null
+     */
+    public synchronized Set getChildren(ObjectName parent) {
+        Set children = (Set) parentToChildMap.get(parent);
+        if (children == null) {
+            return Collections.EMPTY_SET;
+        }
+        return new HashSet(children);
+    }
+
+    /**
+     * Adds a hold on a collection of object name patterns.  If the name of a component matches an object name
+     * pattern in the collection, the component should not start.
+     *
+     * @param objectName the name of the component placing the holds
+     * @param holds a collection of object name patterns which should not start
+     */
+    public synchronized void addStartHolds(ObjectName objectName, Collection holds) {
+        Collection currentHolds = (Collection) startHoldsMap.get(objectName);
+        if (currentHolds == null) {
+            currentHolds = new LinkedList(holds);
+            startHoldsMap.put(objectName, currentHolds);
+        } else {
+            currentHolds.addAll(holds);
+        }
+    }
+
+    /**
+     * Removes a collection of holds.
+     *
+     * @param objectName the object name of the components owning the holds
+     * @param holds a collection of the holds to remove
+     */
+    public synchronized void removeStartHolds(ObjectName objectName, Collection holds) {
+        Collection currentHolds = (Collection) startHoldsMap.get(objectName);
+        if (currentHolds != null) {
+            currentHolds.removeAll(holds);
+        }
+    }
+
+    /**
+     * Removes all of the holds owned by a component.
+     *
+     * @param objectName the object name of the component that will no longer have any holds
+     */
+    public synchronized void removeAllStartHolds(ObjectName objectName) {
+        startHoldsMap.remove(objectName);
+    }
+
+    /**
+     * Gets the object name of the mbean blocking the start specified mbean.
+     *
+     * @param objectName the mbean to check for blockers
+     * @return the mbean blocking the specified mbean, or null if there are no blockers
+     */
+    public synchronized ObjectName checkBlocker(ObjectName objectName) {
+        // check if objectName name is on one of the hold lists
+        for (Iterator iterator = startHoldsMap.keySet().iterator(); iterator.hasNext();) {
+            ObjectName blocker = (ObjectName) iterator.next();
+            List holds = (List) startHoldsMap.get(blocker);
+            for (Iterator holdsIterator = holds.iterator(); holdsIterator.hasNext();) {
+                ObjectName pattern = (ObjectName) holdsIterator.next();
+                if (pattern.apply(objectName)) {
+                    return blocker;
+                }
+            }
+        }
+        return null;
+    }
+
+    private class DependencyManagerLifecycleListener extends LifecycleAdapter {
+        public void unloaded(ObjectName objectName) {
+            synchronized (BasicDependencyManager.this) {
+                removeAllDependencies(objectName);
+                removeAllStartHolds(objectName);
+            }
+
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java Sun May  8 12:35:23 2005
@@ -0,0 +1,369 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.basic;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanName;
+import org.apache.geronimo.gbean.runtime.GBeanInstance;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelGBean;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
+
+
+/**
+ * The core of a Geronimo instance.
+ * A Kernel is responsible for managing the Configurations that comprise a
+ * Geronimo system and exposing them using JMX. Each Kernel is associated
+ * with an MBeanServer that is used to register the Configurations themselves
+ * and the MBeans they define.
+ * <p/>
+ * Dependencies between MBeans are handled by a dedicated DependencyManager
+ * that is responsible for tracking those dependencies and ensuring that the
+ * dependent objects follow the appropriate lifecycle and receive appropriate
+ * notifications.
+ * <p/>
+ * The Kernel also provides a ConfigurationStore which is used to stage
+ * installed Configurations (providing a local filesystem based classpath) and
+ * used hold the persistent state of each Configuration. This allows
+ * Configurations to restart in the event of system failure.
+ * 
+ * TODO: Describe the order of method invocation (e.g. if loadGbean may be before boot)
+ *
+ * @version $Rev: 154947 $ $Date: 2005-02-22 20:10:45 -0800 (Tue, 22 Feb 2005) $
+ */
+public class BasicKernel implements Kernel {
+    /**
+     * Helper objects for invoke and getAttribute
+     */
+    private static final String[] NO_TYPES = new String[0];
+    private static final Object[] NO_ARGS = new Object[0];
+
+    /**
+     * Name of this kernel
+     */
+    private final String kernelName;
+
+    /**
+     * The log
+     */
+    private Log log;
+
+    /**
+     * Is this kernel running?
+     */
+    private boolean running;
+
+    /**
+     * The timestamp when the kernel was started
+     */
+    private Date bootTime;
+
+    /**
+     * The registry
+     */
+    private final BasicRegistry registry;
+
+    /**
+     * Listeners for when the kernel shutdown
+     */
+    private LinkedList shutdownHooks = new LinkedList();
+
+    /**
+     * This manager is used by the kernel to manage dependencies between gbeans
+     */
+    private DependencyManager dependencyManager;
+
+    /**
+     * Monitors the lifecycle of all gbeans.
+     */
+    private BasicLifecycleMonitor lifecycleMonitor;
+    private LifecycleMonitor publicLifecycleMonitor;
+
+    /**
+     * This factory gbean proxies, and tracks all proxies in the system
+     */
+    private ProxyManager proxyManager;
+
+    /**
+     * Construct a Kernel with the specified name.
+     *
+     * @param kernelName the name of the kernel
+     */
+    public BasicKernel(String kernelName) {
+        if (kernelName.indexOf(':') >= 0 || kernelName.indexOf('*') >= 0 || kernelName.indexOf('?') >= 0) {
+            throw new IllegalArgumentException("Kernel name may not contain a ':', '*' or '?' character");
+        }
+        this.kernelName = kernelName;
+        this.registry = new BasicRegistry();
+    }
+
+    public String getKernelName() {
+        return kernelName;
+    }
+
+    /**
+     * @deprecated this will be removed as when we add generalized dependencies to gbeans... the only current user is Configuration
+     */
+    public DependencyManager getDependencyManager() {
+        return dependencyManager;
+    }
+
+    /**
+     * Gets the lifecycle monitor.
+     * @deprecated don't use this yet... it may change or go away
+     */
+    public LifecycleMonitor getLifecycleMonitor() {
+        return publicLifecycleMonitor;
+    }
+
+    /**
+     * Gets the proxy manager.
+     * @deprecated don't use this yet... it may change or go away
+     */
+    public ProxyManager getProxyManager() {
+        return proxyManager;
+    }
+
+    public Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(objectName));
+        return gbeanInstance.getAttribute(attributeName);
+    }
+
+    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(objectName));
+        gbeanInstance.setAttribute(attributeName, attributeValue);
+    }
+
+    public Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invoke(objectName, methodName, NO_ARGS, NO_TYPES);
+    }
+
+    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(objectName));
+        return gbeanInstance.invoke(methodName, args, types);
+    }
+
+    public boolean isLoaded(ObjectName name) {
+        return registry.isRegistered(createGBeanName(name));
+    }
+
+    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.getGBeanInfo();
+    }
+
+    public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.getGBeanData();
+    }
+
+    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
+        ObjectName objectName = gbeanData.getName();
+        GBeanInstance gbeanInstance = new GBeanInstance(gbeanData, this, dependencyManager, lifecycleMonitor.createLifecycleBroadcaster(objectName), classLoader);
+        registry.register(gbeanInstance);
+    }
+
+    public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        gbeanInstance.start();
+    }
+
+    public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        gbeanInstance.startRecursive();
+    }
+
+    public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        gbeanInstance.stop();
+    }
+
+    public void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanName gbeanName = createGBeanName(name);
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(gbeanName);
+        gbeanInstance.die();
+        registry.unregister(gbeanName);
+    }
+
+    public int getGBeanState(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.getState();
+    }
+
+    public long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.getStartTime();
+    }
+
+    public boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.isEnabled();
+    }
+
+    public void setGBeanEnabled(ObjectName name, boolean enabled) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        gbeanInstance.setEnabled(enabled);
+    }
+
+    public Set listGBeans(ObjectName pattern) {
+        String domain = (pattern == null || pattern.isDomainPattern()) ? null : pattern.getDomain();
+        Map props = pattern == null ? null : pattern.getKeyPropertyList();
+        Set gbeans = registry.listGBeans(domain, props);
+        Set result = new HashSet(gbeans.size());
+        for (Iterator i = gbeans.iterator(); i.hasNext();) {
+            GBeanInstance instance = (GBeanInstance) i.next();
+            result.add(instance.getObjectNameObject());
+        }
+        return result;
+    }
+
+    public Set listGBeans(Set patterns) {
+        Set gbeans = new HashSet();
+        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
+            ObjectName pattern = (ObjectName) iterator.next();
+            gbeans.addAll(listGBeans(pattern));
+        }
+        return gbeans;
+    }
+
+    /**
+     * Boot this Kernel, triggering the instantiation of the MBeanServer and DependencyManager,
+     * and the registration of ConfigurationStore
+     *
+     * @throws java.lang.Exception if the boot fails
+     */
+    public void boot() throws Exception {
+        if (running) {
+            return;
+        }
+        bootTime = new Date();
+        log = LogFactory.getLog(BasicKernel.class.getName());
+        log.info("Starting boot");
+
+        // todo cleanup when boot fails
+        KernelRegistry.registerKernel(this);
+
+        registry.start(this);
+
+        lifecycleMonitor = new BasicLifecycleMonitor(this);
+        publicLifecycleMonitor = new LifecycleMonitorFlyweight(lifecycleMonitor);
+        dependencyManager = new BasicDependencyManager(publicLifecycleMonitor);
+        proxyManager = new BasicProxyManager(this);
+
+        // load and start the kernel gbean
+        GBeanData kernelGBeanData = new GBeanData(KERNEL, KernelGBean.GBEAN_INFO);
+        loadGBean(kernelGBeanData, getClass().getClassLoader());
+        startGBean(KERNEL);
+
+        running = true;
+        log.info("Booted");
+    }
+
+    public Date getBootTime() {
+        return bootTime;
+    }
+
+    public void registerShutdownHook(Runnable hook) {
+        assert hook != null : "Shutdown hook was null";
+        synchronized (shutdownHooks) {
+            shutdownHooks.add(hook);
+        }
+    }
+
+    public void unregisterShutdownHook(Runnable hook) {
+        synchronized (shutdownHooks) {
+            shutdownHooks.remove(hook);
+        }
+    }
+
+    /**
+     * Shut down this kernel instance, unregistering the MBeans and releasing
+     * the MBeanServer.
+     */
+    public void shutdown() {
+        if (!running) {
+            return;
+        }
+        running = false;
+        log.info("Starting kernel shutdown");
+
+        notifyShutdownHooks();
+
+        registry.stop();
+
+        dependencyManager.close();
+        dependencyManager = null;
+
+        synchronized (this) {
+            notify();
+        }
+
+        KernelRegistry.unregisterKernel(this);
+
+        log.info("Kernel shutdown complete");
+    }
+
+    private void notifyShutdownHooks() {
+        while (!shutdownHooks.isEmpty()) {
+            Runnable hook;
+            synchronized (shutdownHooks) {
+                hook = (Runnable) shutdownHooks.removeFirst();
+            }
+            try {
+                hook.run();
+            } catch (Throwable e) {
+                log.warn("Error from kernel shutdown hook", e);
+            }
+        }
+    }
+
+    public boolean isRunning() {
+        return running;
+    }
+
+    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.getClassLoader();
+    }
+
+    private GBeanName createGBeanName(ObjectName objectName) {
+        if (objectName.getDomain().length() == 0) {
+            return new GBeanName(kernelName, objectName.getKeyPropertyList());
+        }
+        return new GBeanName(objectName);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java Sun May  8 12:35:23 2005
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicKernelFactory extends KernelFactory {
+    public Kernel createKernel(String kernelName) {
+        return new BasicKernel(kernelName);
+    }
+}



Mime
View raw message