geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r109957 - in geronimo/trunk: modules/common/src/java/org/apache/geronimo/common/propertyeditor modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb modules/j2ee/src/test/org/apache/geronimo/j2ee/management modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting modules/kernel/src/java/org/apache/geronimo/gbean 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/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/kernel/src/test/org/apache/geronimo/kernel/config modules/remoting/src/java/org/apache/geronimo/remoting/jmx modules/remoting/src/test/org/apache/geronimo/remoting modules/security/src/test/org/apache/geronimo/security/jaas modules/system/src/java/org/apache/geronimo/system/main plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin
Date Mon, 06 Dec 2004 07:52:08 GMT
Author: dain
Date: Sun Dec  5 23:52:06 2004
New Revision: 109957

URL: http://svn.apache.org/viewcvs?view=rev&rev=109957
Log:
Kernel is not totally decoupled from JMX.  By default the kernel will no longer boot an MBeanServer.  The only place we boot the MBean server is when we are booting a full blown long running Geronimo server.

Introduced GBeanRegistry which manages the map ObjectName to GBeanInstance.

Added BasicGBeanRegistry which manages the map with no dependency on JMX.

Added JMXGBeanRegistry which creates an MBeanServer on startup.  It mounts a o.a.g.kernel.jmx.GBeanMBean into an MBeanServer for each GBeanInstance registered.  The a o.a.g.kernel.jmx.GBeanMBean does not interact directly with GBeanInstances, instead it simply redirects all calls to a GBean.  GBeanMBean in the o.a.g.gbean.jmx package is just a proxy for a GBeanData, and should be removed soon.

Added KernelDelegate which replaces the MBeanServerFactory use on the client side to create a proxy to the server side geronimo kernel.

Added MBeanServerDelegate which is used to provide apis such as the JSR 88 MEJB which needs a something that implements MBeanServer.  The MBeanServerDelegate only implements the operations of the MBeanServer that easily map to Kernel.  All unimplemented methods throw a SecurityException.

Moved Lifecycle* classes to o.a.g.kernel.lifecycle

Added:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/GBeanMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGBeanRegistry.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXLifecycleBroadcaster.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelMBean.java
      - copied, changed from r109772, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/BasicLifecycleMonitor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleAdapter.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleListener.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitorFlyweight.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/BasicGBeanRegistry.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/GBeanRegistry.java
Removed:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXLifecycleBroadcaster.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleAdapter.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleListener.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Run.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java
   geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/RunTest.java
Modified:
   geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java
   geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java
   geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
   geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
   geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
   geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
   geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
   geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java
   geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
   geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
   geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
   geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java
   geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java
   geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java
   geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
   geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
   geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java
   geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java

Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java?view=diff&rev=109957&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java&r1=109956&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java	(original)
+++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ClassEditor.java	Sun Dec  5 23:52:06 2004
@@ -24,23 +24,18 @@
  *
  * @version $Rev$ $Date$
  */
-public class ClassEditor
-    extends TextPropertyEditorSupport
-{
+public class ClassEditor extends TextPropertyEditorSupport {
     /**
      * Returns a Class for the input object converted to a string.
      *
      * @return a Class object
-     *
-     * @throws PropertyEditorException   Failed to create Class instance.
+     * @throws PropertyEditorException Failed to create Class instance.
      */
-    public Object getValue()
-    {
+    public Object getValue() {
         try {
             String classname = getAsText();
-            return ClassLoading.loadClass(classname);
-        }
-        catch (Exception e) {
+            return ClassLoading.loadClass(classname, Thread.currentThread().getContextClassLoader());
+        } catch (Exception e) {
             throw new PropertyEditorException(e);
         }
     }

Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java?view=diff&rev=109957&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java&r1=109956&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java	(original)
+++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java	Sun Dec  5 23:52:06 2004
@@ -158,8 +158,9 @@
             throw new NullArgumentException("editorTypeName");
         }
 
-        Class type = ClassLoading.loadClass(typeName);
-        Class editorType = ClassLoading.loadClass(editorTypeName);
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        Class type = ClassLoading.loadClass(typeName, classLoader);
+        Class editorType = ClassLoading.loadClass(editorTypeName, classLoader);
 
         registerEditor(type, editorType);
     }

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java?view=diff&rev=109957&p1=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java&r1=109956&p2=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java	(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java	Sun Dec  5 23:52:06 2004
@@ -44,12 +44,11 @@
 import org.apache.geronimo.deployment.plugin.local.StartCommand;
 import org.apache.geronimo.deployment.plugin.local.StopCommand;
 import org.apache.geronimo.deployment.plugin.local.UndeployCommand;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.KernelMBean;
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.NoSuchStoreException;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
+import org.apache.geronimo.kernel.jmx.KernelDelegate;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 import org.apache.geronimo.kernel.management.State;
 
 /**
@@ -66,7 +65,7 @@
     public JMXDeploymentManager(JMXConnector jmxConnector) throws IOException {
         this.jmxConnector = jmxConnector;
         mbServerConnection = jmxConnector.getMBeanServerConnection();
-        kernel = (KernelMBean) MBeanProxyFactory.getProxy(KernelMBean.class, mbServerConnection, Kernel.KERNEL);
+        kernel = new KernelDelegate(mbServerConnection);
     }
 
     public void release() {

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java?view=diff&rev=109957&p1=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java&r1=109956&p2=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java	(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java	Sun Dec  5 23:52:06 2004
@@ -33,7 +33,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
-import org.apache.geronimo.kernel.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 
 /**
  * @version $Rev$ $Date$

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java?view=diff&rev=109957&p1=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java&r1=109956&p2=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java	(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java	Sun Dec  5 23:52:06 2004
@@ -26,8 +26,9 @@
 
 import org.apache.geronimo.deployment.plugin.TargetImpl;
 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
-import org.apache.geronimo.kernel.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 
 /**
  * @version $Rev$ $Date$

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?view=diff&rev=109957&p1=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java&r1=109956&p2=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java	(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java	Sun Dec  5 23:52:06 2004
@@ -21,7 +21,8 @@
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
-import org.apache.geronimo.kernel.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 
 /**
  *

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java?view=diff&rev=109957&p1=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java&r1=109956&p2=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java	(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java	Sun Dec  5 23:52:06 2004
@@ -21,7 +21,7 @@
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
-import org.apache.geronimo.kernel.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 
 /**
  * @version $Rev$ $Date$

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java?view=diff&rev=109957&p1=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java&r1=109956&p2=geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java	(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java	Sun Dec  5 23:52:06 2004
@@ -23,7 +23,7 @@
 
 import org.apache.geronimo.deployment.plugin.TargetImpl;
 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
-import org.apache.geronimo.kernel.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 
 /**

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java?view=diff&rev=109957&p1=geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java&r1=109956&p2=geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java	Sun Dec  5 23:52:06 2004
@@ -16,8 +16,6 @@
  */
 package org.apache.geronimo.j2ee.mejb;
 
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 import javax.ejb.EJBHome;
 import javax.ejb.EJBObject;
@@ -27,8 +25,11 @@
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
 import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.InvalidAttributeValueException;
 import javax.management.MBeanException;
 import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.QueryExp;
 import javax.management.ReflectionException;
@@ -37,13 +38,8 @@
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.jmx.GBeanJMXUtil;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.InternalKernelException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.KernelMBean;
-import org.apache.geronimo.kernel.NoSuchAttributeException;
-import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.jmx.MBeanServerDelegate;
  
 /**
  * GBean implementing Management interface and supplying proxies to act as the MEJB container.
@@ -51,150 +47,50 @@
  * @version $Rev:  $ $Date:  $
  */
 public class MEJB implements Management {
-    private final Kernel kernel;
+    private final MBeanServer mbeanServer;
 
     public MEJB(Kernel kernel) {
-        this.kernel = kernel;
+        mbeanServer = new MBeanServerDelegate(kernel);
     }
 
-    public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
-        try {
-            return kernel.getAttribute(name, attribute);
-        } catch (NoSuchAttributeException e) {
-            throw new AttributeNotFoundException(attribute);
-        } catch (GBeanNotFoundException e) {
-            throw new InstanceNotFoundException(name.getCanonicalName());
-        } catch (InternalKernelException e) {
-            throw new MBeanException(unwrapInternalKernelException(e));
-        } catch (Exception e) {
-            throw new MBeanException(e);
-        }
-    }
-
-    public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
-        AttributeList attributeList = new AttributeList(attributes.length);
-        for (int i = 0; i < attributes.length; i++) {
-            String attribute = attributes[i];
-            try {
-                Object value = kernel.getAttribute(name, attribute);
-                attributeList.add(i, new Attribute(attribute, value));
-            } catch (NoSuchAttributeException e) {
-                // ignored - caller will simply find no value
-            } catch (GBeanNotFoundException e) {
-                throw new InstanceNotFoundException(name.getCanonicalName());
-            } catch (InternalKernelException e) {
-                throw new ReflectionException(unwrapInternalKernelException(e));
-            } catch (Exception e) {
-                // ignored - caller will simply find no value
-            }
-        }
-        return attributeList;
+    public MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException, IntrospectionException, ReflectionException {
+        return mbeanServer.getMBeanInfo(objectName);
     }
 
     public String getDefaultDomain() {
-        return kernel.getKernelName();
+        return mbeanServer.getDefaultDomain();
+    }
+
+    public Object getAttribute(ObjectName objectName, String s) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
+        return mbeanServer.getAttribute(objectName, s);
+    }
+
+    public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
+        mbeanServer.setAttribute(objectName, attribute);
+    }
+
+    public AttributeList getAttributes(ObjectName objectName, String[] strings) throws InstanceNotFoundException, ReflectionException {
+        return mbeanServer.getAttributes(objectName, strings);
+    }
+
+    public AttributeList setAttributes(ObjectName objectName, AttributeList attributeList) throws InstanceNotFoundException, ReflectionException {
+        return mbeanServer.setAttributes(objectName, attributeList);
+    }
+
+    public Object invoke(ObjectName objectName, String s, Object[] objects, String[] strings) throws InstanceNotFoundException, MBeanException, ReflectionException {
+        return mbeanServer.invoke(objectName, s, objects, strings);
     }
 
     public Integer getMBeanCount() {
-        return new Integer(kernel.listGBeans((ObjectName)null).size());
+        return mbeanServer.getMBeanCount();
+    }
+
+    public boolean isRegistered(ObjectName objectName) {
+        return mbeanServer.isRegistered(objectName);
     }
 
-    public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, ReflectionException {
-        GBeanInfo gbeanInfo;
-        try {
-            gbeanInfo = kernel.getGBeanInfo(name);
-        } catch (GBeanNotFoundException e) {
-            throw new InstanceNotFoundException(name.toString());
-        } catch (InternalKernelException e) {
-            throw new ReflectionException(unwrapInternalKernelException(e));
-        }
-        return GBeanJMXUtil.toMBeanInfo(gbeanInfo);
-    }
-
-    public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException {
-        try {
-            return kernel.invoke(name, operationName, params, signature);
-        } catch (NoSuchOperationException e) {
-            throw new ReflectionException(new NoSuchMethodException(e.getMessage()));
-        } catch (GBeanNotFoundException e) {
-            throw new InstanceNotFoundException(name.getCanonicalName());
-        } catch (InternalKernelException e) {
-            throw new MBeanException(unwrapInternalKernelException(e));
-        } catch (Exception e) {
-            throw new MBeanException(e);
-        }
-    }
-
-    public boolean isRegistered(ObjectName name) {
-        return kernel.isLoaded(name);
-    }
-
-    public Set queryNames(ObjectName pattern, QueryExp query) {
-        if (query != null) {
-            throw new IllegalArgumentException("NYI");
-        }
-        Set names = kernel.listGBeans(pattern);
-        if (query == null) {
-            return names;
-        }
-
-        // todo this will not work for non MBean server based queries
-        // dain: I think we could create an MBeanServer wraper around
-        // kernel that passed though most operations to kernel and
-        // threw an UnsupportedOperationException for the operations
-        // that have no equivilent Kernel method.
-        query.setMBeanServer(kernel.getMBeanServer());
-
-        Set filteredNames = new HashSet(names.size());
-        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
-            ObjectName name = (ObjectName) iterator.next();
-            try {
-                if (query.apply(name)) {
-                    filteredNames.add(name);
-                }
-            } catch (Exception e) {
-                // reject any name that threw an exception
-            }
-        }
-        return filteredNames;
-    }
-
-    public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, MBeanException {
-        String attributeName = attribute.getName();
-        Object attributeValue = attribute.getValue();
-        try {
-            kernel.setAttribute(name, attributeName, attributeValue);
-        } catch (NoSuchAttributeException e) {
-            throw new AttributeNotFoundException(attributeName);
-        } catch (GBeanNotFoundException e) {
-            throw new InstanceNotFoundException(name.getCanonicalName());
-        } catch (InternalKernelException e) {
-            throw new MBeanException(unwrapInternalKernelException(e));
-        } catch (Exception e) {
-            throw new MBeanException(e);
-        }
-    }
-
-    public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException {
-        AttributeList set = new AttributeList(attributes.size());
-        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
-            Attribute attribute = (Attribute) iterator.next();
-            String attributeName = attribute.getName();
-            Object attributeValue = attribute.getValue();
-            try {
-                kernel.setAttribute(name, attributeName, attributeValue);
-                set.add(attribute);
-            } catch (NoSuchAttributeException e) {
-                // ignored - caller will see value was not set because this attribute will not be in the attribute list
-            } catch (GBeanNotFoundException e) {
-                throw new InstanceNotFoundException(name.getCanonicalName());
-            } catch (InternalKernelException e) {
-                throw new ReflectionException(unwrapInternalKernelException(e));
-            } catch (Exception e) {
-                // ignored - caller will see value was not set because this attribute will not be in the attribute list
-            }
-        }
-        return set;
+    public Set queryNames(ObjectName objectName, QueryExp queryExp) {
+        return mbeanServer.queryNames(objectName, queryExp);
     }
 
     public ListenerRegistration getListenerRegistry() {
@@ -202,27 +98,6 @@
     }
 
 
-//    //ListenerRegistration implementation
-//    public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException {
-//        try {
-//            kernel.invoke(name, "addNotificationListener", new Object[]{listener, filter, handback}, new String[]{NotificationListener.class.getName(), NotificationFilter.class.getName(), Object.class.getName()});
-//        } catch (InstanceNotFoundException e) {
-//            throw e;
-//        } catch (Exception e) {
-//            throw new RuntimeException(e);
-//        }
-//    }
-//
-//    public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException {
-//        try {
-//            kernel.invoke(name, "removeNotificationListener", new Object[]{listener}, new String[]{NotificationListener.class.getName()});
-//        } catch (InstanceNotFoundException e) {
-//            throw e;
-//        } catch (Exception e) {
-//            throw new RuntimeException(e);
-//        }
-//    }
-
     // EJBObject implementation
     public EJBHome getEJBHome() {
         return null;
@@ -243,18 +118,11 @@
     public void remove() throws RemoveException {
     }
 
-    private static Exception unwrapInternalKernelException(InternalKernelException e) {
-        if (e.getCause() instanceof Exception) {
-            return (Exception) e.getCause();
-        }
-        return e;
-    }
-
     public static final GBeanInfo GBEAN_INFO;
 
     static {
         GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(MEJB.class);
-        infoBuilder.addAttribute("kernel", KernelMBean.class, false);
+        infoBuilder.addAttribute("kernel", Kernel.class, false);
         infoBuilder.addInterface(Management.class);
 
         infoBuilder.setConstructor(new String[]{"kernel"});

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java?view=diff&rev=109957&p1=geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java&r1=109956&p2=geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/management/Abstract77Test.java	Sun Dec  5 23:52:06 2004
@@ -23,7 +23,7 @@
 import javax.management.ObjectName;
 
 import junit.framework.TestCase;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl;
 import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
 import org.apache.geronimo.j2ee.management.impl.JVMImpl;
@@ -48,20 +48,22 @@
         super.setUp();
         kernel = new Kernel(DOMAIN);
         kernel.boot();
-        GBeanMBean gbean;
-        gbean = new GBeanMBean(ServerInfo.getGBeanInfo());
+
+        ClassLoader classLoader = getClass().getClassLoader();
+        GBeanData gbean;
+        gbean = new GBeanData(SERVER_INFO_NAME, ServerInfo.getGBeanInfo());
         gbean.setAttribute("baseDirectory", System.getProperty("java.io.tmpdir"));
-        kernel.loadGBean(SERVER_INFO_NAME, gbean);
+        kernel.loadGBean(gbean, classLoader);
 
-        gbean = new GBeanMBean(J2EEDomainImpl.GBEAN_INFO);
-        kernel.loadGBean(DOMAIN_NAME, gbean);
+        gbean = new GBeanData(DOMAIN_NAME, J2EEDomainImpl.GBEAN_INFO);
+        kernel.loadGBean(gbean, classLoader);
 
-        gbean = new GBeanMBean(J2EEServerImpl.GBEAN_INFO);
+        gbean = new GBeanData(SERVER_NAME, J2EEServerImpl.GBEAN_INFO);
         gbean.setReferencePatterns("ServerInfo", Collections.singleton(SERVER_INFO_NAME));
-        kernel.loadGBean(SERVER_NAME, gbean);
+        kernel.loadGBean(gbean, classLoader);
 
 
-        kernel.loadGBean(JVM_NAME, new GBeanMBean(JVMImpl.GBEAN_INFO));
+        kernel.loadGBean(new GBeanData(JVM_NAME, JVMImpl.GBEAN_INFO), classLoader);
         kernel.startGBean(SERVER_INFO_NAME);
         kernel.startGBean(DOMAIN_NAME);
         kernel.startGBean(SERVER_NAME);

Modified: geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java?view=diff&rev=109957&p1=geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java&r1=109956&p2=geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java	(original)
+++ geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java	Sun Dec  5 23:52:06 2004
@@ -21,6 +21,7 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
+import javax.management.MBeanServer;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -29,6 +30,7 @@
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.jmx.MBeanServerDelegate;
 
 /**
  * A Connector that supports the server sideof JSR 160 JMX Remoting.
@@ -106,7 +108,8 @@
         } else {
             log.warn("Starting unauthenticating JMXConnector for " + serviceURL);
         }
-        server = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, env, kernel.getMBeanServer());
+        MBeanServer mbeanServer = new MBeanServerDelegate(kernel);
+        server = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, env, mbeanServer);
         server.start();
         log.info("Started JMXConnector " + server.getAddress());
     }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GOperationSignature.java	Sun Dec  5 23:52:06 2004
@@ -19,8 +19,6 @@
 
 import java.lang.reflect.Method;
 import java.util.List;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
 
 /**
  * This is a key class based on a MBean operation name and parameters.
@@ -38,15 +36,6 @@
         argumentTypes = new String[parameters.length];
         for (int i = 0; i < parameters.length; i++) {
             argumentTypes[i] = parameters[i].getName();
-        }
-    }
-
-    public GOperationSignature(MBeanOperationInfo operationInfo) {
-        name = operationInfo.getName();
-        MBeanParameterInfo[] parameters = operationInfo.getSignature();
-        argumentTypes = new String[parameters.length];
-        for (int i = 0; i < parameters.length; i++) {
-            argumentTypes[i] = parameters[i].getType();
         }
     }
 

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java?view=auto&rev=109956
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java	Sun Dec  5 23:52:06 2004
@@ -17,38 +17,15 @@
 
 package org.apache.geronimo.gbean.jmx;
 
-import java.util.Iterator;
 import java.util.Set;
 import javax.management.Attribute;
-import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.JMException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanOperationInfo;
 
-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.GOperationSignature;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.gbean.runtime.GBeanInstance;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.NoSuchAttributeException;
-import org.apache.geronimo.kernel.NoSuchOperationException;
-import org.apache.geronimo.kernel.management.NotificationType;
 
 /**
  * A GBeanMBean is a J2EE Management Managed Object, and is standard base for Geronimo services.
@@ -58,15 +35,7 @@
  *
  * @version $Rev$ $Date$
  */
-public final class GBeanMBean implements DynamicMBean, MBeanRegistration, NotificationEmitter {
-    private static final Log log = LogFactory.getLog(GBeanMBean.class);
-    private static final MBeanInfo DEFAULT_MBEAN_INFO = new MBeanInfo("java.lang.Object", "", new MBeanAttributeInfo[0], new MBeanConstructorInfo[0], new MBeanOperationInfo[0], new MBeanNotificationInfo[0]);
-
-    /**
-     * Gets the context class loader from the thread or the system class loader if there is no context class loader.
-     *
-     * @return the context class loader or the system classloader
-     */
+public final class GBeanMBean {
     private static ClassLoader getContextClassLoader() {
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         if (classLoader == null) {
@@ -76,24 +45,9 @@
     }
 
     /**
-     * The kernel in which this server is registered.
-     */
-    private Kernel kernel;
-
-    /**
-     * The unique name of this service.
-     */
-    private ObjectName objectName;
-
-    /**
      * The data of the
      */
-    private GBeanData gbeanData;
-
-    /**
-     * The instance for this gbean mbean
-     */
-    private GBeanInstance gbeanInstance;
+    private final GBeanData gbeanData;
 
     /**
      * The classloader used for all invocations and creating targets.
@@ -101,322 +55,100 @@
     private final ClassLoader classLoader;
 
     /**
-     * JMX sped mbeanInfo for this gbean (translation of the above gbeanInfo
-     */
-    private MBeanInfo mbeanInfo = DEFAULT_MBEAN_INFO;
-
-    /**
-     * The broadcaster for notifications
-     */
-    private JMXLifecycleBroadcaster lifecycleBroadcaster;
-
-    /**
-     * This is the constructor used by the kernel.  This constructor should not be used dirctly.
-     * Instedad you should use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
-     * @deprecated use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
-     */
-    public GBeanMBean(Kernel kernel, GBeanData gbeanData, ClassLoader classLoader) throws InvalidConfigurationException {
-        this.kernel = kernel;
-        this.gbeanData = gbeanData;
-        this.classLoader = classLoader;
-
-        this.objectName = gbeanData.getName();
-    }
-
-    /**
-     * This constructor allows the kernel to bootstrap and existing GBeanInstance directly into the MBeanServer.
-     * @deprecated DO NOT USE
-     */
-    public GBeanMBean(Kernel kernel, GBeanInstance gbeanInstance, JMXLifecycleBroadcaster lifecycleBroadcaster) throws InvalidConfigurationException {
-        this.kernel = kernel;
-        this.gbeanInstance = gbeanInstance;
-        this.lifecycleBroadcaster = lifecycleBroadcaster;
-
-        this.objectName = gbeanInstance.getObjectNameObject();
-        this.gbeanData = gbeanInstance.getGBeanData();
-        this.classLoader = gbeanInstance.getClassLoader();
-    }
-
-    /**
-     * Constructa a GBeanMBean using the supplied GBeanData and class loader
-     *
-     * @param gbeanData the data for the new GBean including GBeanInfo, intial attribute values, and reference patterns
-     * @param classLoader the class loader used to load the gbean instance and attribute/reference types
-     * @throws InvalidConfigurationException if the gbeanInfo is inconsistent with the actual java classes, such as
-     * mismatched attribute types or the intial data can not be set
-     * @deprecated use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
+     * @deprecated use GBeanData instead
      */
     public GBeanMBean(GBeanData gbeanData, ClassLoader classLoader) throws InvalidConfigurationException {
-        this.classLoader = classLoader;
         this.gbeanData = gbeanData;
+        this.classLoader = classLoader;
     }
 
     /**
-     * Constructa a GBeanMBean using the supplied gbeanInfo and class loader
-     *
-     * @param gbeanInfo the metadata describing the attributes, operations, constructor and references of the gbean
-     * @param classLoader the class loader used to load the gbean instance and attribute/reference types
-     * @throws InvalidConfigurationException if the gbeanInfo is inconsistent with the actual java classes, such as
-     * mismatched attribute types
-     * @deprecated use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
+     * @deprecated use GBeanData instead
      */
     public GBeanMBean(GBeanInfo gbeanInfo, ClassLoader classLoader) throws InvalidConfigurationException {
-        this(new GBeanData(gbeanInfo), classLoader);
+        this.gbeanData = new GBeanData(gbeanInfo);
+        this.classLoader = classLoader;
     }
 
     /**
      * @deprecated use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
      */
     public GBeanMBean(GBeanInfo gbeanInfo) throws InvalidConfigurationException {
-        this(new GBeanData(gbeanInfo), getContextClassLoader());
+        this.gbeanData = new GBeanData(gbeanInfo);
+        this.classLoader = getContextClassLoader();
     }
 
     /**
      * @deprecated use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
      */
     public GBeanMBean(String className, ClassLoader classLoader) throws Exception {
-        this(new GBeanData(GBeanInfo.getGBeanInfo(className, classLoader)), classLoader);
+        this.gbeanData = new GBeanData(GBeanInfo.getGBeanInfo(className, classLoader));
+        this.classLoader = classLoader;
     }
 
     /**
-     * @deprecated use kernel.loadGBean(GBeanData gbeanData, ClassLoader classLoader)
+     * @deprecated use GBeanData instead
      */
     public GBeanMBean(String className) throws Exception {
-        this(className, ClassLoader.getSystemClassLoader());
+        this.classLoader = ClassLoader.getSystemClassLoader();
+        this.gbeanData = new GBeanData(GBeanInfo.getGBeanInfo(className, classLoader));
     }
 
     /**
-     * Gets the MBeanInfo equivilent of the GBeanInfo used to construct this gbean.
-     *
-     * @return the MBeanInfo for this gbean
+     * @deprecated use GBeanData instead
      */
-    public MBeanInfo getMBeanInfo() {
-        return mbeanInfo;
-    }
-
     public ClassLoader getClassLoader() {
         return classLoader;
     }
 
-    public synchronized ObjectName preRegister(MBeanServer server, ObjectName objectName) throws Exception {
-        if (gbeanInstance == null) {
-            this.objectName = objectName;
-            try {
-                String kernelName = (String) server.getAttribute(Kernel.KERNEL, "KernelName");
-                kernel = Kernel.getKernel(kernelName);
-            } catch (Exception e) {
-                throw new IllegalStateException("No kernel is registered in this MBeanServer");
-            }
-
-            gbeanData.setName(objectName);
-            lifecycleBroadcaster = new JMXLifecycleBroadcaster(objectName, kernel.getLifecycleMonitor().createLifecycleBroadcaster(objectName));
-            gbeanInstance = new GBeanInstance(kernel, gbeanData, lifecycleBroadcaster, classLoader);
-            mbeanInfo = GBeanJMXUtil.toMBeanInfo(gbeanInstance.getGBeanInfo());
-        }
-        return gbeanInstance.getObjectNameObject();
-    }
-
-    public synchronized void postRegister(Boolean registrationDone) {
-        if (!registrationDone.booleanValue()) {
-            if (gbeanInstance != null) {
-                gbeanInstance.destroy();
-                gbeanInstance = null;
-            }
-            mbeanInfo = DEFAULT_MBEAN_INFO;
-            lifecycleBroadcaster = null;
-            kernel = null;
-            objectName = null;
-        }
-    }
-
-    public void preDeregister() throws Exception {
-    }
-
-    public synchronized void postDeregister() {
-        if (gbeanInstance != null) {
-            gbeanData = gbeanInstance.getGBeanData();
-            gbeanInstance.destroy();
-            gbeanInstance = null;
-        }
-        mbeanInfo = DEFAULT_MBEAN_INFO;
-        kernel = null;
-        objectName = null;
-    }
-
     /**
-     * Gets the gbean data for the gbean held by this gbean mbean.
-     * @return the gbean data
+     * @deprecated use GBeanData instead
      */
     public GBeanData getGBeanData() {
-        if (gbeanInstance != null) {
-            return gbeanInstance.getGBeanData();
-        } else {
-            return gbeanData;
-        }
-    }
-
-    public void setGBeanData(GBeanData gbeanData) throws Exception {
-        if (gbeanInstance != null) {
-            gbeanInstance.setGBeanData(gbeanData);
-        } else {
-            this.gbeanData = gbeanData;
-        }
+        return gbeanData;
     }
 
+    /**
+     * @deprecated use GBeanData instead
+     */
     public Object getAttribute(String name) throws ReflectionException, AttributeNotFoundException {
-        if (gbeanInstance == null) {
-            return gbeanData.getAttribute(name);
-        } else {
-            try {
-                return gbeanInstance.getAttribute(name);
-            } catch (NoSuchAttributeException e) {
-                throw new AttributeNotFoundException(name);
-            } catch (Exception e) {
-                throw new ReflectionException(e);
-            }
-        }
+        return gbeanData.getAttribute(name);
     }
 
+    /**
+     * @deprecated use GBeanData instead
+     */
     public void setAttribute(String name, Object value) throws ReflectionException, AttributeNotFoundException {
-        if (gbeanInstance == null) {
-            gbeanData.setAttribute(name, value);
-        } else {
-            try {
-                gbeanInstance.setAttribute(name, value);
-            } catch (NoSuchAttributeException e) {
-                throw new AttributeNotFoundException(name);
-            } catch (Exception e) {
-                throw new ReflectionException(e);
-            }
-        }
+        gbeanData.setAttribute(name, value);
     }
 
+    /**
+     * @deprecated use GBeanData instead
+     */
     public void setAttribute(Attribute attribute) throws ReflectionException, AttributeNotFoundException {
         String name = attribute.getName();
         Object value = attribute.getValue();
-        if (gbeanInstance == null) {
-            gbeanData.setAttribute(name, value);
-        } else {
-            try {
-                gbeanInstance.setAttribute(name, value);
-            } catch (NoSuchAttributeException e) {
-                throw new AttributeNotFoundException(name);
-            } catch (Exception e) {
-                throw new ReflectionException(e);
-            }
-        }
-    }
-
-    public AttributeList getAttributes(String[] attributes) {
-        AttributeList results = new AttributeList(attributes.length);
-        for (int i = 0; i < attributes.length; i++) {
-            String name = attributes[i];
-            try {
-                Object value = getAttribute(name);
-                results.add(new Attribute(name, value));
-            } catch (JMException e) {
-                log.warn("Exception while getting attribute " + name, e);
-            }
-        }
-        return results;
-    }
-
-    public AttributeList setAttributes(AttributeList attributes) {
-        AttributeList results = new AttributeList(attributes.size());
-        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
-            Attribute attribute = (Attribute) iterator.next();
-            try {
-                setAttribute(attribute);
-                results.add(attribute);
-            } catch (JMException e) {
-                log.warn("Exception while setting attribute " + attribute.getName(), e);
-            }
-        }
-        return results;
-    }
-
-    public Object invoke(String operationName, Object[] arguments, String[] types) throws ReflectionException {
-        if (gbeanInstance == null) {
-            throw new IllegalStateException("An offline gbean can not be invoked: " + objectName);
-        } else {
-            try {
-                return gbeanInstance.invoke(operationName, arguments, types);
-            } catch (NoSuchOperationException e) {
-                throw new ReflectionException(new NoSuchMethodException(new GOperationSignature(operationName, types).toString()));
-            } catch (Exception e) {
-                throw new ReflectionException(e);
-            }
-        }
+        gbeanData.setAttribute(name, value);
     }
 
     /**
-     * Gets the object name patters for a reference.
-     *
-     * @param name the reference name
-     * @return the object name patterns for the reference
+     * @deprecated use GBeanData instead
      */
     public Set getReferencePatterns(String name) {
-        if (gbeanInstance != null) {
-            return gbeanInstance.getReferencePatterns(name);
-        } else {
-            return gbeanData.getReferencePatterns(name);
-        }
+        return gbeanData.getReferencePatterns(name);
     }
 
     /**
-     * Sets a single object name pattern for a reference.
-     *
-     * @param name the reference name
-     * @param pattern the new single object name pattern for the reference
+     * @deprecated use GBeanData instead
      */
     public void setReferencePattern(String name, ObjectName pattern) {
-        if (gbeanInstance != null) {
-            gbeanInstance.setReferencePattern(name, pattern);
-        } else {
-            gbeanData.setReferencePattern(name, pattern);
-        }
+        gbeanData.setReferencePattern(name, pattern);
     }
 
     /**
-     * Sets the object name patterns for a reference.
-     *
-     * @param name the reference name
-     * @param patterns the new object name patterns for the reference
+     * @deprecated use GBeanData instead
      */
     public void setReferencePatterns(String name, Set patterns) {
-        if (gbeanInstance != null) {
-            gbeanInstance.setReferencePatterns(name, patterns);
-        } else {
-            gbeanData.setReferencePatterns(name, patterns);
-        }
-    }
-
-    public final String getObjectName() {
-        return objectName.getCanonicalName();
-    }
-
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[]{
-            new MBeanNotificationInfo(NotificationType.TYPES, "javax.management.Notification", "J2EE Notifications")
-        };
-    }
-
-    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) {
-        lifecycleBroadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
-        lifecycleBroadcaster.removeNotificationListener(listener);
-    }
-
-    public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
-        lifecycleBroadcaster.removeNotificationListener(listener, filter, handback);
-    }
-
-    public String toString() {
-        if (objectName == null) {
-            return super.toString();
-        }
-        return objectName.toString();
+        gbeanData.setReferencePatterns(name, patterns);
     }
 }

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXLifecycleBroadcaster.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXLifecycleBroadcaster.java?view=auto&rev=109956
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java	Sun Dec  5 23:52:06 2004
@@ -27,11 +27,12 @@
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.kernel.ClassLoading;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.LifecycleAdapter;
-import org.apache.geronimo.kernel.LifecycleListener;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;
 
 /**
@@ -79,21 +80,37 @@
      */
     private final Set targets = new HashSet();
 
+    /**
+     * The metadata for this reference
+     */
     private final GReferenceInfo referenceInfo;
 
     /**
      * The kernel to which the reference is bound.
      */
-    private Kernel kernel;
+    private final Kernel kernel;
+
+    /**
+     * The dependency manager of the kernel.
+     */
+    private final DependencyManager dependencyManager;
 
     /**
      * Proxy for this reference
      */
     private Object proxy;
 
-    public AbstractGBeanReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException {
+    /**
+     * is this reference online
+     */
+    private boolean isOnline = false;
+
+    public AbstractGBeanReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
         this.gbeanInstance = gbeanInstance;
         this.referenceInfo = referenceInfo;
+        this.kernel = kernel;
+        this.dependencyManager = dependencyManager;
+
         this.name = referenceInfo.getName();
         try {
             this.referenceType = ClassLoading.loadClass(referenceInfo.getReferenceType(), gbeanInstance.getClassLoader());
@@ -158,6 +175,10 @@
         return kernel;
     }
 
+    protected DependencyManager getDependencyManager() {
+        return dependencyManager;
+    }
+
     public final GBeanInstance getGBeanInstance() {
         return gbeanInstance;
     }
@@ -191,7 +212,7 @@
     }
 
     public final void setPatterns(Set patterns) {
-        if (kernel != null) {
+        if (isOnline) {
             throw new IllegalStateException("Pattern set can not be modified while online");
         }
 
@@ -210,9 +231,7 @@
         }
     }
 
-    public final synchronized void online(Kernel kernel) {
-        this.kernel = kernel;
-
+    public final synchronized void online() {
         Set gbeans = kernel.listGBeans(patterns);
         for (Iterator objectNameIterator = gbeans.iterator(); objectNameIterator.hasNext();) {
             ObjectName target = (ObjectName) objectNameIterator.next();
@@ -226,6 +245,7 @@
         }
 
         kernel.getLifecycleMonitor().addLifecycleListener(listener, patterns);
+        isOnline = true;
     }
 
     public final synchronized void offline() {
@@ -235,7 +255,7 @@
         kernel.getLifecycleMonitor().removeLifecycleListener(listener);
 
         targets.clear();
-        kernel = null;
+        isOnline = false;
     }
 
     protected abstract void targetAdded(ObjectName target);

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java	Sun Dec  5 23:52:06 2004
@@ -21,13 +21,15 @@
 
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.DependencyManager;
 
 /**
  * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
  */
 public class GBeanCollectionReference extends AbstractGBeanReference {
-    public GBeanCollectionReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException {
-        super(gbeanInstance, referenceInfo);
+    public GBeanCollectionReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
+        super(gbeanInstance, referenceInfo, kernel, dependencyManager);
     }
 
     public synchronized void start() throws Exception {

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java	Sun Dec  5 23:52:06 2004
@@ -45,6 +45,7 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.management.EventProvider;
 import org.apache.geronimo.kernel.management.ManagedObject;
 import org.apache.geronimo.kernel.management.NotificationType;
@@ -66,11 +67,6 @@
     public static final String RAW_INVOKER = "$$RAW_INVOKER$$";
 
     /**
-     * Attribute name used to retrieve the GBeanData for the GBean
-     */
-    public static final String GBEAN_DATA = "$$GBEAN_DATA$$";
-
-    /**
      * The kernel in which this server is registered.
      */
     private final Kernel kernel;
@@ -189,11 +185,11 @@
      * @throws org.apache.geronimo.gbean.InvalidConfigurationException if the gbeanInfo is inconsistent with the actual java classes, such as
      * mismatched attribute types or the intial data can not be set
      */
-    public GBeanInstance(Kernel kernel, GBeanData gbeanData, LifecycleBroadcaster lifecycleBroadcaster, ClassLoader classLoader) throws InvalidConfigurationException {
-        this.kernel = kernel;
+    public GBeanInstance(GBeanData gbeanData, Kernel kernel, DependencyManager dependencyManager, LifecycleBroadcaster lifecycleBroadcaster, ClassLoader classLoader) throws InvalidConfigurationException {
         this.objectName = gbeanData.getName();
+        this.kernel = kernel;
         this.lifecycleBroadcaster = lifecycleBroadcaster;
-        this.gbeanInstanceState = new GBeanInstanceState(kernel, objectName, new GBeanLifecycleCallback(), lifecycleBroadcaster);
+        this.gbeanInstanceState = new GBeanInstanceState(objectName, kernel, dependencyManager, new GBeanLifecycleCallback(), lifecycleBroadcaster);
         this.classLoader = classLoader;
         gbeanLifecycleController = new GBeanInstanceLifecycleController(this);
 
@@ -227,9 +223,9 @@
         for (Iterator iterator = gbeanInfo.getReferences().iterator(); iterator.hasNext();) {
             GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next();
             if (referenceInfo.getProxyType().equals(Collection.class.getName())) {
-                referencesSet.add(new GBeanCollectionReference(this, referenceInfo));
+                referencesSet.add(new GBeanCollectionReference(this, referenceInfo, kernel, dependencyManager));
             } else {
-                referencesSet.add(new GBeanSingleReference(this, referenceInfo));
+                referencesSet.add(new GBeanSingleReference(this, referenceInfo, kernel, dependencyManager));
             }
         }
         references = (GBeanReference[]) referencesSet.toArray(new GBeanReference[gbeanInfo.getReferences().size()]);
@@ -294,7 +290,7 @@
         }
 
         for (int i = 0; i < references.length; i++) {
-            references[i].online(this.kernel);
+            references[i].online();
         }
         lifecycleBroadcaster.fireLoadedEvent();
     }
@@ -454,10 +450,9 @@
      * Moves this GBeanInstance to the starting state and then attempts to move this MBean immediately
      * to the running state.
      *
-     * @throws Exception If an exception occurs while starting this MBean
      * @throws IllegalStateException If the gbean is disabled
      */
-    public final void start() throws Exception {
+    public final void start() {
         synchronized (this) {
             if (!enabled) {
                 throw new IllegalStateException("A disabled GBean can not be started: objectName=" + objectName);
@@ -469,10 +464,9 @@
     /**
      * Starts this GBeanInstance and then attempts to start all of its start dependent children.
      *
-     * @throws Exception if a problem occurs will starting this MBean or any child MBean
      * @throws IllegalStateException If the gbean is disabled
      */
-    public final void startRecursive() throws Exception {
+    public final void startRecursive() {
         synchronized (this) {
             if (!enabled) {
                 throw new IllegalStateException("A disabled GBean can not be started: objectName=" + objectName);
@@ -484,10 +478,8 @@
     /**
      * Moves this GBeanInstance to the STOPPING state, calls stop on all start dependent children, and then attempt
      * to move this MBean to the STOPPED state.
-     *
-     * @throws Exception If an exception occurs while stoping this MBean or any of the childern
      */
-    public final void stop() throws Exception {
+    public final void stop() {
         gbeanInstanceState.stop();
     }
 
@@ -592,12 +584,6 @@
             if (attributeName.equals(RAW_INVOKER)) {
                 return rawInvoker;
             }
-
-            if (attributeName.equals(GBEAN_DATA)) {
-                return getGBeanData();
-
-            }
-
             throw e;
         }
 
@@ -941,6 +927,16 @@
                         new MethodInvoker() {
                             public Object invoke(Object target, Object[] arguments) throws Exception {
                                 return new Boolean(isEventProvider());
+                            }
+                        }));
+
+        attributesMap.put("eventTypes",
+                GBeanAttribute.createFrameworkAttribute(this,
+                        "eventTypes",
+                        Boolean.TYPE,
+                        new MethodInvoker() {
+                            public Object invoke(Object target, Object[] arguments) throws Exception {
+                                return getEventTypes();
                             }
                         }));
 

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?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java&r2=109957
==============================================================================
--- 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 Dec  5 23:52:06 2004
@@ -16,22 +16,21 @@
  */
 package org.apache.geronimo.gbean.runtime;
 
-import java.util.Set;
 import java.util.Iterator;
-
+import java.util.Set;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.kernel.LifecycleAdapter;
-import org.apache.geronimo.kernel.LifecycleListener;
-import org.apache.geronimo.kernel.Kernel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.WaitingException;
 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.gbean.WaitingException;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+import org.apache.geronimo.kernel.management.State;
 
 /**
  * @version $Rev$ $Date$
@@ -74,10 +73,10 @@
     // objects check if each other are in one state or another (i.e., classic A calls B while B calls A)
     private volatile State state = State.STOPPED;
 
-    GBeanInstanceState(Kernel kernel, ObjectName objectName, GBeanLifecycle gbeanLifecycle, LifecycleBroadcaster lifecycleBroadcaster) {
-        this.kernel = kernel;
-        this.dependencyManager = kernel.getDependencyManager();
+    GBeanInstanceState(ObjectName objectName, Kernel kernel, DependencyManager dependencyManager, GBeanLifecycle gbeanLifecycle, LifecycleBroadcaster lifecycleBroadcaster) {
         this.objectName = objectName;
+        this.kernel = kernel;
+        this.dependencyManager = dependencyManager;
         this.gbeanLifecycle = gbeanLifecycle;
         this.lifecycleBroadcaster = lifecycleBroadcaster;
     }
@@ -89,10 +88,8 @@
      * Note:  This method cannot be called while the current thread holds a synchronized lock on this MBean,
      * because this method sends JMX notifications. Sending a general notification from a synchronized block
      * is a bad idea and therefore not allowed.
-     *
-     * @throws Exception If an exception occurs while starting this MBean
      */
-    public final void start() throws Exception {
+    public final void start() {
         assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";
 
         // Move to the starting state
@@ -122,10 +119,8 @@
      * Note:  This method cannot be call while the current thread holds a synchronized lock on this MBean,
      * because this method sends JMX notifications.  Sending a general notification from a synchronized block
      * is a bad idea and therefore not allowed.
-     *
-     * @throws Exception if a problem occurs will starting this MBean or any child MBean
      */
-    public final void startRecursive() throws Exception {
+    public final void startRecursive() {
         assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";
 
         State state = getStateInstance();
@@ -143,18 +138,18 @@
         Set dependents = dependencyManager.getChildren(objectName);
         for (Iterator iterator = dependents.iterator(); iterator.hasNext();) {
             ObjectName dependent = (ObjectName) iterator.next();
-            boolean enabled = true;
             try {
-                enabled = ((Boolean) kernel.getAttribute(dependent, "gbeanEnabled")).booleanValue();
+                if (((Boolean) kernel.getAttribute(dependent, "gbeanEnabled")).booleanValue()) {
+                    kernel.startRecursiveGBean(dependent);
+                }
             } catch (NoSuchAttributeException e) {
                 // this is ok didn't have the attribute....
-            }
-            if (enabled) {
-                try {
-                    kernel.invoke(dependent, "startRecursive", null, null);
-                } catch (NoSuchMethodException e) {
-                    // did not have a startRecursive method - ok
-                }
+            } catch (GBeanNotFoundException e) {
+                // this is ok the gbean died before we could start it
+                continue;
+            } catch (Exception e) {
+                // the is something wrong with this gbean... skip it
+                continue;
             }
         }
     }
@@ -166,10 +161,8 @@
      * Note:  This method can not be call while the current thread holds a syncronized lock on this MBean,
      * because this method sends JMX notifications.  Sending a general notification from a synchronized block
      * is a bad idea and therefore not allowed.
-     *
-     * @throws Exception If an exception occurs while stopping this MBean or any of the children
      */
-    public final void stop() throws Exception {
+    public final void stop() {
         assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";
 
         // move to the stopping state
@@ -238,11 +231,10 @@
      * Attempts to bring the component into {@link org.apache.geronimo.kernel.management.State#RUNNING} state. If an Exception occurs while
      * starting the component, the component will be failed.
      *
-     * @throws Exception if a problem occurs while starting the component
      * <p/>
      * Note: Do not call this from within a synchronized block as it makes may send a JMX notification
      */
-    void attemptFullStart() throws Exception {
+    void attemptFullStart() {
         assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";
 
         State newState = null;
@@ -327,14 +319,12 @@
                     } catch (WaitingException e) {
                         log.debug("Waiting to start: objectName=\"" + objectName + "\" reason=\"" + e.getMessage() + "\"");
                         return;
+                    } catch (Exception e) {
+                        log.error("Error while starting: objectName=\"" + objectName+ "\"", e);
+                        return;
                     }
                     setStateInstance(State.RUNNING);
                     newState = State.RUNNING;
-                } catch (Exception e) {
-                    doSafeFail();
-                    setStateInstance(State.FAILED);
-                    newState = State.FAILED;
-                    throw e;
                 } catch (Error e) {
                     doSafeFail();
                     setStateInstance(State.FAILED);
@@ -353,11 +343,10 @@
      * Attempt to bring the component into the fully stopped state.
      * If an exception occurs while stopping the component, the component will be failed.
      *
-     * @throws Exception if a problem occurs while stopping the component
      * <p/>
      * Note: Do not call this from within a synchronized block as it may send a JMX notification
      */
-    void attemptFullStop() throws Exception {
+    void attemptFullStop() {
         assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";
 
         State newState = null;
@@ -399,14 +388,12 @@
                     } catch (WaitingException e) {
                         log.debug("Waiting to stop: objectName=\"" + objectName + "\" reason=\"" + e.getMessage() + "\"");
                         return;
+                    } catch (Exception e) {
+                        log.error("Error while stopping: objectName=\"" + objectName+ "\"", e);
+                        return;
                     }
                     setStateInstance(State.STOPPED);
                     newState = State.STOPPED;
-                } catch (Exception e) {
-                    doSafeFail();
-                    setStateInstance(State.FAILED);
-                    newState = State.FAILED;
-                    throw e;
                 } catch (Error e) {
                     doSafeFail();
                     setStateInstance(State.FAILED);

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java	Sun Dec  5 23:52:06 2004
@@ -18,7 +18,6 @@
 
 import java.util.Set;
 
-import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.gbean.GReferenceInfo;
 
 /**
@@ -37,7 +36,7 @@
 
     void setPatterns(Set patterns);
 
-    void online(Kernel kernel);
+    void online();
 
     void offline();
 

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?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java&r2=109957
==============================================================================
--- 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 Dec  5 23:52:06 2004
@@ -26,6 +26,7 @@
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.management.State;
 
 /**
@@ -44,8 +45,8 @@
      */
     private ObjectName proxyTarget;
 
-    public GBeanSingleReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException {
-        super(gbeanInstance, referenceInfo);
+    public GBeanSingleReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
+        super(gbeanInstance, referenceInfo, kernel, dependencyManager);
     }
 
     public synchronized void start() throws Exception {
@@ -73,30 +74,30 @@
         waitingForMe = false;
 
         // stop all gbeans that would match our patterns from starting
-        Kernel kernel = getKernel();
         ObjectName objectName = getGBeanInstance().getObjectNameObject();
-        kernel.getDependencyManager().addStartHolds(objectName, getPatterns());
+        DependencyManager dependencyManager = getDependencyManager();
+        dependencyManager.addStartHolds(objectName, getPatterns());
 
         // add a dependency on our target and create the proxy
         ObjectName target = (ObjectName) targets.iterator().next();
-        setProxy(kernel.getProxyManager().createProxy(target, getReferenceType()));
+        setProxy(getKernel().getProxyManager().createProxy(target, getReferenceType()));
         proxyTarget = target;
-        kernel.getDependencyManager().addDependency(objectName, target);
+        dependencyManager.addDependency(objectName, target);
     }
 
     public synchronized void stop() {
         waitingForMe = false;
-        Kernel kernel = getKernel();
         ObjectName objectName = getGBeanInstance().getObjectNameObject();
         Set patterns = getPatterns();
+        DependencyManager dependencyManager = getDependencyManager();
         if (!patterns.isEmpty()) {
-            kernel.getDependencyManager().removeStartHolds(objectName, patterns);
+            dependencyManager.removeStartHolds(objectName, patterns);
         }
 
         Object proxy = getProxy();
         if (proxy != null) {
-            kernel.getDependencyManager().removeDependency(objectName, proxyTarget);
-            kernel.getProxyManager().destroyProxy(proxy);
+            dependencyManager.removeDependency(objectName, proxyTarget);
+            getKernel().getProxyManager().destroyProxy(proxy);
             setProxy(null);
             proxyTarget = null;
         }

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?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java&r2=109957
==============================================================================
--- 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 Dec  5 23:52:06 2004
@@ -27,17 +27,6 @@
  * @version $Rev$ $Date$
  */
 public class ClassLoading {
-    /**
-     * Load a class for the given name using the context class loader.
-     *
-     * @param className The name of the Class to be loaded.
-     * @return The Class object for the given name.
-     * @throws ClassNotFoundException Failed to load Class object.
-     * @see #loadClass(String,ClassLoader)
-     */
-    public static Class loadClass(final String className) throws ClassNotFoundException {
-        return loadClass(className, getContextClassLoader());
-    }
 
     /**
      * Load a class for the given name.
@@ -127,16 +116,6 @@
             rc.append(VM_PRIMITIVES_REVERSE.get(clazz));
         }
         return rc.toString();
-    }
-
-    /**
-     * This method acts equivalently to invoking
-     * <code>Thread.currentThread().getContextClassLoader()</code>.
-     *
-     * @return The thread context class Loader.
-     */
-    private static ClassLoader getContextClassLoader() {
-        return Thread.currentThread().getContextClassLoader();
     }
 
     /**

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?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java&r2=109957
==============================================================================
--- 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 Dec  5 23:52:06 2004
@@ -28,6 +28,10 @@
 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

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?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r2=109957
==============================================================================
--- 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 Dec  5 23:52:06 2004
@@ -30,14 +30,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.JMRuntimeException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
@@ -45,8 +37,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
-import org.apache.geronimo.gbean.jmx.JMXLifecycleBroadcaster;
 import org.apache.geronimo.gbean.runtime.GBeanInstance;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
@@ -54,8 +44,14 @@
 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;
 
 
 /**
@@ -77,7 +73,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class Kernel implements KernelMBean {
+public class Kernel {
 
     /**
      * The JMX name used by a Kernel to register itself when it boots.
@@ -118,11 +114,6 @@
     private final String kernelName;
 
     /**
-     * JMX domain name of this kernel
-     */
-    private final String domainName;
-
-    /**
      * The log
      */
     private Log log;
@@ -138,9 +129,9 @@
     private Date bootTime;
 
     /**
-     * The MBean server used by this kernel
+     * The gbean registry
      */
-    private MBeanServer mbServer;
+    private final GBeanRegistry gbeanRegistry;
 
     /**
      * Listeners for when the kernel shutdown
@@ -164,49 +155,54 @@
 
     /**
      * Monitors the lifecycle of all gbeans.
-     * @deprecated don't use this yet... it may go away
      */
-    private LifecycleMonitor lifecycleMonitor;
+    private BasicLifecycleMonitor lifecycleMonitor;
+    private LifecycleMonitor publicLifecycleMonitor;
 
     /**
      * This factory gbean proxies, and tracks all proxies in the system
-     * @deprecated don't use this yet... it may go away
      */
     private ProxyManager proxyManager;
 
     /**
      * No-arg constructor allowing this class to be used as a GBean reference.
      */
-    public Kernel() {
+    protected Kernel() {
         kernelName = null;
-        domainName = null;
+        gbeanRegistry = null;
     }
 
     /**
-     * Construct a Kernel which does not have a config store.
+     * Construct a Kernel with the specified name and GBeanRegistry implementation.
      *
-     * @param kernelName the domain name to be used for the JMX MBeanServer
+     * @param kernelName the name of the kernel
+     * @param gbeanRegistry the GBeanRegistry implementation to use for this contianer
      */
-    public Kernel(String kernelName) {
+    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.domainName = kernelName;
+        this.gbeanRegistry = gbeanRegistry;
     }
 
     /**
-     * Construct a Kernel which does not have a config store.
+     * Construct a Kernel with the specified name and an unspecified GBeanRegistry implementation.
      *
-     * @param kernelName the name of the kernel that uniquely indentifies the kernel in a VM
-     * @param domainName the domain name to be used for the JMX MBeanServer
-     * @deprecated we are dropping the ability to have multiple kernels in a single mbean server, as the kernels will
-     * stomp on each others namespace
+     * @param kernelName the name of the kernel
      */
-    public Kernel(String kernelName, String domainName) {
-        this.kernelName = kernelName;
-        this.domainName = domainName;
+    public Kernel(String kernelName) {
+        this(kernelName, new BasicGBeanRegistry());
     }
 
-    public MBeanServer getMBeanServer() {
-        return mbServer;
+    /**
+     * Construct a Kernel with the specified name and an unspecified GBeanRegistry implementation.
+     *
+     * @param kernelName the name of the kernel
+     * @deprecated use new Kernel(kernelName)
+     */
+    public Kernel(String kernelName, String ignored) {
+        this(kernelName);
     }
 
     public String getKernelName() {
@@ -258,6 +254,9 @@
         }
     }
 
+    /**
+     * @deprecated this will be removed as when we add generalized dependencies to gbeans... the only current user is Configuration
+     */
     public DependencyManager getDependencyManager() {
         return dependencyManager;
     }
@@ -271,7 +270,7 @@
      * @deprecated don't use this yet... it may change or go away
      */
     public LifecycleMonitor getLifecycleMonitor() {
-        return lifecycleMonitor;
+        return publicLifecycleMonitor;
     }
 
     /**
@@ -282,50 +281,14 @@
         return proxyManager;
     }
 
-    public Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, InternalKernelException, Exception {
-        try {
-            return mbServer.getAttribute(objectName, attributeName);
-        } catch (Exception e) {
-            Throwable cause = unwrapJMException(e);
-            if (cause instanceof InstanceNotFoundException) {
-                throw new GBeanNotFoundException(objectName.getCanonicalName());
-            } else if (cause instanceof AttributeNotFoundException) {
-                throw new NoSuchAttributeException(cause.getMessage());
-            } else if (cause instanceof JMException) {
-                throw new InternalKernelException(cause);
-            } else if (cause instanceof JMRuntimeException) {
-                throw new InternalKernelException(cause);
-            } else if (cause instanceof Error) {
-                throw (Error) cause;
-            } else if (cause instanceof Exception) {
-                throw (Exception) cause;
-            } else {
-                throw new InternalKernelException("Unknown throwable", cause);
-            }
-        }
+    public Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(objectName);
+        return gbeanInstance.getAttribute(attributeName);
     }
 
-    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, InternalKernelException, Exception {
-        try {
-            mbServer.setAttribute(objectName, new Attribute(attributeName, attributeValue));
-        } catch (Exception e) {
-            Throwable cause = unwrapJMException(e);
-            if (cause instanceof InstanceNotFoundException) {
-                throw new GBeanNotFoundException(objectName.getCanonicalName());
-            } else if (cause instanceof AttributeNotFoundException) {
-                throw new NoSuchAttributeException(cause.getMessage());
-            } else if (cause instanceof JMException) {
-                throw new InternalKernelException(cause);
-            } else if (cause instanceof JMRuntimeException) {
-                throw new InternalKernelException(cause);
-            } else if (cause instanceof Error) {
-                throw (Error) cause;
-            } else if (cause instanceof Exception) {
-                throw (Exception) cause;
-            } else {
-                throw new InternalKernelException("Unknown throwable", cause);
-            }
-        }
+    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(objectName);
+        gbeanInstance.setAttribute(attributeName, attributeValue);
     }
 
     public Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
@@ -333,147 +296,61 @@
     }
 
     public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
-        try {
-            return mbServer.invoke(objectName, methodName, args, types);
-        } catch (Exception e) {
-            Throwable cause = unwrapJMException(e);
-            if (cause instanceof InstanceNotFoundException) {
-                throw new GBeanNotFoundException(objectName.getCanonicalName());
-            } else if (cause instanceof NoSuchMethodException) {
-                throw new NoSuchOperationException(cause.getMessage());
-            } else if (cause instanceof JMException) {
-                throw new InternalKernelException(cause);
-            } else if (cause instanceof JMRuntimeException) {
-                throw new InternalKernelException(cause);
-            } else if (cause instanceof Error) {
-                throw (Error) cause;
-            } else if (cause instanceof Exception) {
-                throw (Exception) cause;
-            } else {
-                throw new InternalKernelException("Unknown throwable", cause);
-            }
-        }
-    }
-
-    private Throwable unwrapJMException(Throwable cause) {
-        while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
-            cause = cause.getCause();
-        }
-        return cause;
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(objectName);
+        return gbeanInstance.invoke(methodName, args, types);
     }
 
-
     public boolean isLoaded(ObjectName name) {
-        try {
-            return mbServer != null && mbServer.isRegistered(name);
-        } catch (RuntimeException e) {
-            throw new InternalKernelException(e);
-        }
+        return gbeanRegistry.isRegistered(name);
     }
 
-    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-        try {
-            return (GBeanInfo) getAttribute(name, "gbeanInfo");
-        } catch (GBeanNotFoundException e) {
-            throw e;
-        } catch (InternalKernelException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new InternalKernelException(e);
-        }
+    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(name);
+        return gbeanInstance.getGBeanInfo();
     }
 
     public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-        try {
-            return (GBeanData) getAttribute(name, GBeanInstance.GBEAN_DATA);
-        } catch (GBeanNotFoundException e) {
-            throw e;
-        } catch (InternalKernelException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new InternalKernelException(e);
-        }
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(name);
+        return gbeanInstance.getGBeanData();
     }
 
     public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
-        try {
-            GBeanMBean gbean = new GBeanMBean(this, gbeanData, classLoader);
-            mbServer.registerMBean(gbean, gbeanData.getName());
-        } catch (InstanceAlreadyExistsException e) {
-            throw new GBeanAlreadyExistsException("A GBean is alreayd registered witht then name " + gbeanData.getName());
-        } catch (Exception e) {
-            throw new InternalKernelException("Error loading GBean " + gbeanData.getName().getCanonicalName(), unwrapJMException(e));
-        }
+        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, GBeanMBean gbean) throws GBeanAlreadyExistsException, InternalKernelException {
+    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 {
-        try {
-            invoke(name, "start");
-        } catch (GBeanNotFoundException e) {
-            throw e;
-        } catch (InternalKernelException e) {
-            throw e;
-        } catch (NoSuchOperationException e) {
-            throw new InternalKernelException("GBean is not state manageable: " + name.getCanonicalName(), e);
-        } catch (Exception e) {
-            throw new InternalKernelException("Invalid GBean configuration for " + name, unwrapJMException(e));
-        }
+    public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(name);
+        gbeanInstance.start();
     }
 
-    public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-        try {
-            invoke(name, "startRecursive");
-        } catch (GBeanNotFoundException e) {
-            throw e;
-        } catch (InternalKernelException e) {
-            throw e;
-        } catch (NoSuchOperationException e) {
-            throw new InternalKernelException("GBean is not state manageable: " + name.getCanonicalName(), e);
-        } catch (Exception e) {
-            throw new InternalKernelException("Invalid GBean configuration for " + name, e);
-        }
+    public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(name);
+        gbeanInstance.startRecursive();
     }
 
-    public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-        try {
-            invoke(name, "stop");
-        } catch (GBeanNotFoundException e) {
-            throw e;
-        } catch (InternalKernelException e) {
-            throw e;
-        } catch (NoSuchOperationException e) {
-            throw new InternalKernelException("GBean is not state manageable: " + name.getCanonicalName(), e);
-        } catch (Exception e) {
-            throw new InternalKernelException("Invalid GBean configuration for " + name, e);
-        }
+    public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(name);
+        gbeanInstance.stop();
     }
 
-    public void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-       try {
-            mbServer.unregisterMBean(name);
-       } catch (InstanceNotFoundException e) {
-           throw new GBeanNotFoundException(name.getCanonicalName());
-       } catch (Exception e) {
-           throw new InternalKernelException("Error unloading GBean " + name, unwrapJMException(e));
-       }
+    public void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+       gbeanRegistry.unregister(name);
     }
 
     public Set listGBeans(ObjectName pattern) {
-        try {
-            return mbServer.queryNames(pattern, null);
-        } catch (RuntimeException e) {
-            throw new InternalKernelException("Error while applying pattern " + pattern, e);
-        }
+        return gbeanRegistry.listGBeans(pattern);
     }
 
     public Set listGBeans(Set patterns) {
@@ -518,18 +395,16 @@
     }
 
     public int getConfigurationState(URI configID) throws NoSuchConfigException, InternalKernelException {
-         try {
-             ObjectName configName = Configuration.getConfigurationObjectName(configID);
-             return ((Integer)getAttribute(configName, "state")).intValue();
-         } catch (MalformedObjectNameException e) {
-             throw new NoSuchConfigException(e);
-         } catch (GBeanNotFoundException e) {
-             throw new NoSuchConfigException(e);
-         } catch (InternalKernelException e) {
-             throw e;
-         } catch (Exception e) {
-             throw new InternalKernelException(e);
-         }
+        GBeanInstance gbeanInstance = null;
+        try {
+            ObjectName configName = Configuration.getConfigurationObjectName(configID);
+            gbeanInstance = gbeanRegistry.getGBeanInstance(configName);
+        } catch (MalformedObjectNameException e) {
+            throw new NoSuchConfigException(e);
+        } catch (GBeanNotFoundException e) {
+            throw new NoSuchConfigException(e);
+        }
+        return gbeanInstance.getState();
     }
 
     /**
@@ -546,6 +421,7 @@
         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);
@@ -553,10 +429,11 @@
             kernels.put(kernelName, new KernelReference(kernelName, this));
         }
 
-        mbServer = MBeanServerFactory.createMBeanServer(domainName);
-        mbServer.registerMBean(this, KERNEL);
-        lifecycleMonitor = new LifecycleMonitor(this);
-        dependencyManager = new DependencyManager(lifecycleMonitor);
+        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
@@ -565,14 +442,16 @@
 
         // create the connfiguration manager instance
         JMXLifecycleBroadcaster lifecycleBroadcaster = new JMXLifecycleBroadcaster(CONFIGURATION_MANAGER_NAME, lifecycleMonitor.createLifecycleBroadcaster(CONFIGURATION_MANAGER_NAME));
-        configurationManagerInstance = new GBeanInstance(this, configurationData, lifecycleBroadcaster, getClass().getClassLoader());
+        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);
 
-        // wrap it in an mbean and register it
-        GBeanMBean configurationManagerGBean = new GBeanMBean(this, configurationManagerInstance, lifecycleBroadcaster);
-        mbServer.registerMBean(configurationManagerGBean, CONFIGURATION_MANAGER_NAME);
+        // 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");
@@ -609,17 +488,11 @@
         notifyShutdownHooks();
         shutdownConfigManager();
 
-        try {
-            mbServer.unregisterMBean(KERNEL);
-        } catch (Exception e) {
-            // ignore
-        }
+        gbeanRegistry.stop();
 
         dependencyManager.close();
         dependencyManager = null;
 
-        MBeanServerFactory.releaseMBeanServer(mbServer);
-        mbServer = null;
         synchronized (this) {
             notify();
         }
@@ -654,7 +527,7 @@
                 // ignore
             }
             try {
-                mbServer.unregisterMBean(CONFIGURATION_MANAGER_NAME);
+                gbeanRegistry.unregister(CONFIGURATION_MANAGER_NAME);
             } catch (Exception e) {
                 // ignore
             }
@@ -667,13 +540,8 @@
     }
 
     public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException {
-        try {
-            return mbServer.getClassLoaderFor(name);
-        } catch (InstanceNotFoundException e) {
-            throw new GBeanNotFoundException(name.getCanonicalName());
-        } catch (RuntimeException e) {
-            throw new InternalKernelException("Error while attemping to get class loader for " + name.getCanonicalName(), e);
-        }
+        GBeanInstance gbeanInstance = gbeanRegistry.getGBeanInstance(name);
+        return gbeanInstance.getClassLoader();
     }
 
     private static void processQueue() {

Added: 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?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,165 @@
+/**
+ *
+ * Copyright 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;
+
+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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class KernelGBean {
+    private final Kernel kernel;
+
+    public KernelGBean(Kernel kernel) {
+        this.kernel = kernel;
+    }
+
+    public Date getBootTime() {
+        return kernel.getBootTime();
+    }
+
+    public String getKernelName() {
+        return kernel.getKernelName();
+    }
+
+    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
+        kernel.loadGBean(gbeanData, classLoader);
+    }
+
+    public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startGBean(name);
+    }
+
+    public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startRecursiveGBean(name);
+    }
+
+    public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.stopGBean(name);
+    }
+
+    public void unloadGBean(ObjectName name) throws GBeanNotFoundException {
+        kernel.unloadGBean(name);
+    }
+
+    public boolean isRunning() {
+        return kernel.isRunning();
+    }
+
+    public ConfigurationManager getConfigurationManager() {
+        return kernel.getConfigurationManager();
+    }
+
+    public List listConfigurationStores() {
+        return kernel.listConfigurationStores();
+    }
+
+    public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
+        return kernel.listConfigurations(storeName);
+    }
+
+    public ObjectName startConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
+        return kernel.startConfiguration(configID);
+    }
+
+    public void stopConfiguration(URI configID) throws NoSuchConfigException {
+        kernel.stopConfiguration(configID);
+    }
+
+    public int getConfigurationState(URI configId) throws NoSuchConfigException {
+        return kernel.getConfigurationState(configId);
+    }
+
+    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        return kernel.getClassLoaderFor(name);
+    }
+
+    public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        return kernel.getGBeanData(name);
+    }
+
+    public Object getAttribute(ObjectName objectName, String attributeName) throws Exception {
+        return kernel.getAttribute(objectName, attributeName);
+    }
+
+    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws Exception {
+        kernel.setAttribute(objectName, attributeName, attributeValue);
+    }
+
+    public Object invoke(ObjectName objectName, String methodName) throws Exception {
+        return kernel.invoke(objectName, methodName);
+    }
+
+    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws Exception {
+        return kernel.invoke(objectName, methodName, args, types);
+    }
+
+    public boolean isLoaded(ObjectName name) {
+        return kernel.isLoaded(name);
+    }
+
+    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
+        return kernel.getGBeanInfo(name);
+    }
+
+    public Set listGBeans(ObjectName pattern) throws InternalKernelException {
+        return kernel.listGBeans(pattern);
+    }
+
+    public Set listGBeans(Set patterns) throws InternalKernelException {
+        return kernel.listGBeans(patterns);
+    }
+
+    public void registerShutdownHook(Runnable hook) {
+        kernel.registerShutdownHook(hook);
+    }
+
+    public void unregisterShutdownHook(Runnable hook) {
+        kernel.unregisterShutdownHook(hook);
+    }
+
+    public void shutdown() {
+        kernel.shutdown();
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(KernelGBean.class);
+        infoFactory.addInterface(KernelGBean.class);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.setConstructor(new String[]{"kernel"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java?view=auto&rev=109956
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleAdapter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleAdapter.java?view=auto&rev=109956
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleListener.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleListener.java?view=auto&rev=109956
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java?view=auto&rev=109956
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java	Sun Dec  5 23:52:06 2004
@@ -211,6 +211,7 @@
                 log.trace("Registering GBean " + name);
                 kernel.loadGBean(gbeanData, configurationClassLoader);
                 objectNames.add(name);
+                // todo change this to a dependency on the gbeanData itself as soon as we add that feature 
                 kernel.getDependencyManager().addDependency(name, this.objectName);
             }
             this.objectNames = objectNames;

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Run.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Run.java?view=auto&rev=109956
==============================================================================

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/GBeanMBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/GBeanMBean.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/GBeanMBean.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,200 @@
+/**
+ *
+ * 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.jmx;
+
+import java.util.Iterator;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.JMException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GOperationSignature;
+import org.apache.geronimo.gbean.runtime.LifecycleBroadcaster;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.management.NotificationType;
+
+/**
+ * @version $Rev: 109772 $ $Date: 2004-12-03 21:06:02 -0800 (Fri, 03 Dec 2004) $
+ */
+public final class GBeanMBean implements DynamicMBean, NotificationEmitter, LifecycleBroadcaster {
+    private static final Log log = LogFactory.getLog(GBeanMBean.class);
+
+    /**
+     * The kernel
+     */
+    private final Kernel kernel;
+
+    /**
+     * The unique name of this service.
+     */
+    private final ObjectName objectName;
+
+    /**
+     * The mbean info
+     */
+    private final MBeanInfo mbeanInfo;
+
+    /**
+     * The broadcaster for notifications
+     */
+    private final NotificationBroadcasterSupport notificationBroadcaster = new NotificationBroadcasterSupport();
+
+    /**
+     * Sequence number used for notifications
+     */
+    private long sequence;
+
+    public GBeanMBean(Kernel kernel, ObjectName objectName, MBeanInfo mbeanInfo) {
+        this.kernel = kernel;
+        this.objectName = objectName;
+        this.mbeanInfo = mbeanInfo;
+    }
+
+    public MBeanInfo getMBeanInfo() {
+        return mbeanInfo;
+    }
+
+    public Object getAttribute(String attributeName) throws ReflectionException, AttributeNotFoundException {
+        try {
+            return kernel.getAttribute(objectName, attributeName);
+        } catch (NoSuchAttributeException e) {
+            throw new AttributeNotFoundException(attributeName);
+        } catch (Exception e) {
+            throw new ReflectionException(e);
+        }
+    }
+
+    public void setAttribute(Attribute attribute) throws ReflectionException, AttributeNotFoundException {
+        String attributeName = attribute.getName();
+        Object attributeValue = attribute.getValue();
+        try {
+            kernel.setAttribute(objectName, attributeName, attributeValue);
+        } catch (NoSuchAttributeException e) {
+            throw new AttributeNotFoundException(attributeName);
+        } catch (Exception e) {
+            throw new ReflectionException(e);
+        }
+    }
+
+    public AttributeList getAttributes(String[] attributes) {
+        AttributeList results = new AttributeList(attributes.length);
+        for (int i = 0; i < attributes.length; i++) {
+            String name = attributes[i];
+            try {
+                Object value = getAttribute(name);
+                results.add(new Attribute(name, value));
+            } catch (JMException e) {
+                log.warn("Exception while getting attribute " + name, e);
+            }
+        }
+        return results;
+    }
+
+    public AttributeList setAttributes(AttributeList attributes) {
+        AttributeList results = new AttributeList(attributes.size());
+        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+            Attribute attribute = (Attribute) iterator.next();
+            try {
+                setAttribute(attribute);
+                results.add(attribute);
+            } catch (JMException e) {
+                log.warn("Exception while setting attribute " + attribute.getName(), e);
+            }
+        }
+        return results;
+    }
+
+    public Object invoke(String operationName, Object[] arguments, String[] types) throws ReflectionException {
+        try {
+            return kernel.invoke(objectName, operationName, arguments, types);
+        } catch (NoSuchOperationException e) {
+            throw new ReflectionException(new NoSuchMethodException(new GOperationSignature(operationName, types).toString()));
+        } catch (Exception e) {
+            throw new ReflectionException(e);
+        }
+    }
+
+    public MBeanNotificationInfo[] getNotificationInfo() {
+        return new MBeanNotificationInfo[]{
+            new MBeanNotificationInfo(NotificationType.TYPES, "javax.management.Notification", "J2EE Notifications")
+        };
+    }
+
+    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) {
+        notificationBroadcaster.addNotificationListener(listener, filter, handback);
+    }
+
+    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
+        notificationBroadcaster.removeNotificationListener(listener);
+    }
+
+    public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
+        notificationBroadcaster.removeNotificationListener(listener, filter, handback);
+    }
+
+    public void fireLoadedEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.OBJECT_CREATED, objectName, nextSequence()));
+    }
+
+    public void fireStartingEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_STARTING, objectName, nextSequence()));
+    }
+
+    public void fireRunningEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_RUNNING, objectName, nextSequence()));
+    }
+
+    public void fireStoppingEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_STOPPING, objectName, nextSequence()));
+    }
+
+    public void fireStoppedEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_STOPPED, objectName, nextSequence()));
+    }
+
+    public void fireFailedEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_FAILED, objectName, nextSequence()));
+    }
+
+    public void fireUnloadedEvent() {
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.OBJECT_DELETED, objectName, nextSequence()));
+    }
+
+    private synchronized long nextSequence() {
+        return sequence++;
+    }
+
+    public String toString() {
+        return objectName.toString();
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGBeanRegistry.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGBeanRegistry.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGBeanRegistry.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,176 @@
+/**
+ *
+ * Copyright 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.jmx;
+
+import java.util.HashMap;
+import java.util.Set;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMException;
+import javax.management.JMRuntimeException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.GBeanInstance;
+import org.apache.geronimo.gbean.runtime.LifecycleBroadcaster;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.registry.GBeanRegistry;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMXGBeanRegistry implements GBeanRegistry {
+    private final HashMap registry = new HashMap();
+    private Kernel kernel;
+    private MBeanServer mbServer;
+
+    public void start(Kernel kernel) {
+        this.kernel = kernel;
+        mbServer = MBeanServerFactory.createMBeanServer(kernel.getKernelName());
+//        try {
+//            mbServer.registerMBean(kernel, Kernel.KERNEL);
+//        } catch (Exception e) {
+//            throw new InternalKernelException("Error registering kernel with MBeanServer", unwrapJMException(e));
+//        }
+    }
+
+    public void stop() {
+//        try {
+//            mbServer.unregisterMBean(Kernel.KERNEL);
+//        } catch (Exception e) {
+//            // ignore
+//        }
+//
+        MBeanServerFactory.releaseMBeanServer(mbServer);
+
+        // todo destroy instances
+        synchronized(this) {
+            registry.clear();
+        }
+    }
+
+    public MBeanServer getMBeanServer() {
+        return mbServer;
+    }
+
+    public synchronized boolean isRegistered(ObjectName name) {
+        return registry.containsKey(name);
+    }
+
+    public void register(GBeanInstance gbeanInstance) throws GBeanAlreadyExistsException, InternalKernelException {
+        ObjectName name = gbeanInstance.getObjectNameObject();
+        MBeanInfo mbeanInfo = JMXUtil.toMBeanInfo(gbeanInstance.getGBeanInfo());
+        GBeanMBean gbeanMBean = new GBeanMBean(kernel, name, mbeanInfo);
+        try {
+            mbServer.registerMBean(gbeanMBean, name);
+        } catch (InstanceAlreadyExistsException e) {
+            throw new GBeanAlreadyExistsException("A GBean is alreayd registered witht then name " + name);
+        } catch (Exception e) {
+            throw new InternalKernelException("Error loading GBean " + name.getCanonicalName(), unwrapJMException(e));
+        }
+
+        synchronized (this) {
+            registry.put(name, gbeanInstance);
+        }
+
+        kernel.getLifecycleMonitor().addLifecycleListener(new LifecycleBridge(gbeanMBean), name);
+
+        // fire the loaded event from the gbeanMBean.. it was already fired from
+        // the GBeanInstance when it was created
+        gbeanMBean.fireLoadedEvent();        
+    }
+
+    public void unregister(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        try {
+             mbServer.unregisterMBean(name);
+        } catch (InstanceNotFoundException e) {
+            throw new GBeanNotFoundException(name.getCanonicalName());
+        } catch (Exception e) {
+            throw new InternalKernelException("Error unloading GBean " + name, unwrapJMException(e));
+        }
+
+        synchronized (this) {
+            registry.remove(name);
+        }
+    }
+
+    public synchronized GBeanInstance getGBeanInstance(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = (GBeanInstance) registry.get(name);
+        if (gbeanInstance == null) {
+            throw new GBeanNotFoundException(name.getCanonicalName());
+        }
+        return gbeanInstance;
+    }
+
+    public Set listGBeans(ObjectName pattern) throws InternalKernelException {
+        try {
+            return mbServer.queryNames(pattern, null);
+        } catch (RuntimeException e) {
+            throw new InternalKernelException("Error while applying pattern " + pattern, e);
+        }
+    }
+
+    private Throwable unwrapJMException(Throwable cause) {
+        while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
+            cause = cause.getCause();
+        }
+        return cause;
+    }
+
+    private static class LifecycleBridge implements LifecycleListener {
+        private final LifecycleBroadcaster broadcaster;
+
+        public LifecycleBridge(LifecycleBroadcaster broadcaster) {
+            this.broadcaster = broadcaster;
+        }
+
+        public void loaded(ObjectName objectName) {
+            broadcaster.fireLoadedEvent();
+        }
+
+        public void starting(ObjectName objectName) {
+            broadcaster.fireStartingEvent();
+        }
+
+        public void running(ObjectName objectName) {
+            broadcaster.fireRunningEvent();
+        }
+
+        public void stopping(ObjectName objectName) {
+            broadcaster.fireStoppingEvent();
+        }
+
+        public void stopped(ObjectName objectName) {
+            broadcaster.fireStoppedEvent();
+        }
+
+        public void failed(ObjectName objectName) {
+            broadcaster.fireFailedEvent();
+        }
+
+        public void unloaded(ObjectName objectName) {
+            broadcaster.fireUnloadedEvent();
+        }
+    }
+}

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java?view=auto&rev=109956
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java?view=auto&rev=109956
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java?view=auto&rev=109956
==============================================================================

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXLifecycleBroadcaster.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXLifecycleBroadcaster.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXLifecycleBroadcaster.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,93 @@
+/**
+ *
+ * Copyright 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.jmx;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.LifecycleBroadcaster;
+import org.apache.geronimo.kernel.management.NotificationType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMXLifecycleBroadcaster implements LifecycleBroadcaster {
+    private final NotificationBroadcasterSupport notificationBroadcaster = new NotificationBroadcasterSupport();
+    private final ObjectName objectName;
+    private final LifecycleBroadcaster lifecycleBroadcaster;
+    private long sequence;
+
+    public JMXLifecycleBroadcaster(ObjectName objectName, LifecycleBroadcaster lifecycleBroadcaster) {
+        this.objectName = objectName;
+        this.lifecycleBroadcaster = lifecycleBroadcaster;
+    }
+
+    public void fireLoadedEvent() {
+        lifecycleBroadcaster.fireLoadedEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.OBJECT_CREATED, objectName, nextSequence()));
+    }
+
+    public void fireStartingEvent() {
+        lifecycleBroadcaster.fireStartingEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_STARTING, objectName, nextSequence()));
+    }
+
+    public void fireRunningEvent() {
+        lifecycleBroadcaster.fireRunningEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_RUNNING, objectName, nextSequence()));
+    }
+
+    public void fireStoppingEvent() {
+        lifecycleBroadcaster.fireStoppingEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_STOPPING, objectName, nextSequence()));
+    }
+
+    public void fireStoppedEvent() {
+        lifecycleBroadcaster.fireStoppedEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_STOPPED, objectName, nextSequence()));
+    }
+
+    public void fireFailedEvent() {
+        lifecycleBroadcaster.fireFailedEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.STATE_FAILED, objectName, nextSequence()));
+    }
+
+    public void fireUnloadedEvent() {
+        lifecycleBroadcaster.fireUnloadedEvent();
+        notificationBroadcaster.sendNotification(new Notification(NotificationType.OBJECT_DELETED, objectName, nextSequence()));
+    }
+
+    void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) {
+        notificationBroadcaster.addNotificationListener(listener, filter, handback);
+    }
+
+    void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
+        notificationBroadcaster.removeNotificationListener(listener);
+    }
+
+    void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
+        notificationBroadcaster.removeNotificationListener(listener, filter, handback);
+    }
+
+    private synchronized long nextSequence() {
+        return sequence++;
+    }
+}

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java?view=auto&rev=109956
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java?view=auto&rev=109956
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXUtil.java	Sun Dec  5 23:52:06 2004
@@ -17,8 +17,22 @@
 
 package org.apache.geronimo.kernel.jmx;
 
+import java.util.Set;
+import java.util.Iterator;
+import java.util.List;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
+import javax.management.MBeanInfo;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.MBeanNotificationInfo;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GOperationInfo;
+import org.apache.geronimo.kernel.management.NotificationType;
 
 
 /**
@@ -31,11 +45,6 @@
     }
 
     /**
-     * the ObjectName of the MBeanServerDelegate
-     */
-    public static final ObjectName DELEGATE_NAME = getObjectName("JMImplementation:type=MBeanServerDelegate");
-
-    /**
      * Convert a String to an ObjectName
      *
      * @param name the name
@@ -48,5 +57,56 @@
         } catch (MalformedObjectNameException e) {
             throw new IllegalArgumentException("Malformed ObjectName: " + name);
         }
+    }
+
+    public static MBeanInfo toMBeanInfo(GBeanInfo gBeanInfo) {
+        String className = gBeanInfo.getClassName();
+        String description = "No description available";
+
+        // attributes
+        Set gbeanAttributes = gBeanInfo.getAttributes();
+        MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[gbeanAttributes.size()];
+        int a = 0;
+        for (Iterator iterator = gbeanAttributes.iterator(); iterator.hasNext();) {
+            GAttributeInfo gAttributeInfo = (GAttributeInfo) iterator.next();
+            attributes[a] = new MBeanAttributeInfo(gAttributeInfo.getName(), gAttributeInfo.getType(), "no description available", gAttributeInfo.isReadable(), gAttributeInfo.isWritable(), isIs(gAttributeInfo));
+            a++;
+        }
+
+        //we don't expose managed constructors
+        MBeanConstructorInfo[] constructors = new MBeanConstructorInfo[0];
+
+        // operations
+        Set gbeanOperations = gBeanInfo.getOperations();
+        MBeanOperationInfo[] operations = new MBeanOperationInfo[gbeanOperations.size()];
+        int o = 0;
+        for (Iterator iterator = gbeanOperations.iterator(); iterator.hasNext();) {
+            GOperationInfo gOperationInfo = (GOperationInfo) iterator.next();
+            //list of class names
+            List gparameters = gOperationInfo.getParameterList();
+            MBeanParameterInfo[] parameters = new MBeanParameterInfo[gparameters.size()];
+            int p = 0;
+            for (Iterator piterator = gparameters.iterator(); piterator.hasNext();) {
+                String type = (String) piterator.next();
+                parameters[p] = new MBeanParameterInfo("parameter" + p, type, "no description available");
+                p++;
+            }
+            operations[o] = new MBeanOperationInfo(gOperationInfo.getName(), "no description available", parameters, "java.lang.Object", MBeanOperationInfo.UNKNOWN);
+            o++;
+        }
+
+        MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[1];
+        notifications[0] = new MBeanNotificationInfo(NotificationType.TYPES, "javax.management.Notification", "J2EE Notifications");
+
+        MBeanInfo mbeanInfo = new MBeanInfo(className, description, attributes, constructors, operations, notifications);
+        return mbeanInfo;
+    }
+
+    private static boolean isIs(GAttributeInfo gAttributeInfo) {
+        String getterName = gAttributeInfo.getGetterName();
+        if (getterName == null) {
+            return false;
+        }
+        return getterName.startsWith("is");
     }
 }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,368 @@
+/**
+ *
+ * Copyright 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.jmx;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMException;
+import javax.management.JMRuntimeException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.jmx.*;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+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.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.NoSuchStoreException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class KernelDelegate implements KernelMBean {
+    private final MBeanServerConnection mbeanServer;
+
+    public KernelDelegate(MBeanServerConnection mbeanServer) {
+        this.mbeanServer = mbeanServer;
+    }
+
+    public Date getBootTime() {
+        return (Date) getKernelAttribute("bootTime");
+    }
+
+    public String getKernelName() {
+        return (String) getKernelAttribute("kernelName");
+    }
+
+    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
+        try {
+            invokeKernel("loadGBean", new Object[] {gbeanData, classLoader}, new String[] {GBeanData.class.getName(), ClassLoader.class.getName()});
+        } catch (GBeanAlreadyExistsException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void loadGBean(ObjectName name, GBeanMBean gbean) throws GBeanAlreadyExistsException, InternalKernelException {
+        throw new UnsupportedOperationException("Use loadGBean(GBeanData, ClassLoader)");
+    }
+
+    public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startGBean", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startRecursiveGBean", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("stopGBean", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unloadGBean(ObjectName name) throws GBeanNotFoundException {
+        try {
+            invokeKernel("unloadGBean", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isRunning() {
+        return ((Boolean) getKernelAttribute("running")).booleanValue();
+    }
+
+    public ConfigurationManager getConfigurationManager() {
+        return (ConfigurationManager) getKernelAttribute("configurationManager");
+    }
+
+    public List listConfigurationStores() {
+        try {
+            return (List) invokeKernel("listConfigurationStores", new Object[] {}, new String[] {});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
+        try {
+            return (List) invokeKernel("listConfigurations", new Object[] {storeName}, new String[] {ObjectName.class.getName()});
+        } catch (NoSuchStoreException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ObjectName startConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
+        try {
+            return (ObjectName) invokeKernel("startConfiguration", new Object[]{configID}, new String[]{URI.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void stopConfiguration(URI configID) throws NoSuchConfigException {
+        try {
+            invokeKernel("stopConfiguration", new Object[]{configID}, new String[]{URI.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public int getConfigurationState(URI configID) throws NoSuchConfigException {
+        try {
+            return ((Integer) invokeKernel("getConfigurationState", new Object[]{configID}, new String[]{URI.class.getName()})).intValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object getAttribute(ObjectName objectName, String attributeName) throws Exception {
+        try {
+            return invokeKernel("getAttribute", new Object[]{objectName, attributeName}, new String[]{ObjectName.class.getName(), String.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws Exception {
+        try {
+            invokeKernel("setAttribute", new Object[]{objectName, attributeName, attributeValue}, new String[]{ObjectName.class.getName(), String.class.getName(), Object.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object invoke(ObjectName objectName, String methodName) throws Exception {
+        try {
+            return invokeKernel("invoke", new Object[]{objectName, methodName}, new String[]{ObjectName.class.getName(), String.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws Exception {
+        try {
+            return invokeKernel("invoke", new Object[]{objectName, methodName, args, types}, new String[]{ObjectName.class.getName(), String.class.getName(), Object[].class.getName(), String[].class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isLoaded(ObjectName name) {
+        try {
+            return ((Boolean) invokeKernel("isLoaded", new Object[]{name}, new String[]{ObjectName.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
+        try {
+            return (GBeanInfo) invokeKernel("getGBeanInfo", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Set listGBeans(ObjectName pattern) throws InternalKernelException {
+        try {
+            return (Set) invokeKernel("listGBeans", new Object[] {pattern}, new String[] {ObjectName.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Set listGBeans(Set patterns) throws InternalKernelException {
+        try {
+            return (Set) invokeKernel("listGBeans", new Object[] {patterns}, new String[] {Set.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void registerShutdownHook(Runnable hook) {
+        try {
+            invokeKernel("registerShutdownHook", new Object[] {hook}, new String[] {Runnable.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unregisterShutdownHook(Runnable hook) {
+        try {
+            invokeKernel("unregisterShutdownHook", new Object[] {hook}, new String[] {Runnable.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void shutdown() {
+        try {
+            invokeKernel("shutdown", new Object[] {}, new String[] {});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        try {
+            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        try {
+            return (GBeanData) invokeKernel("getGBeanData", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    private Object getKernelAttribute(String attributeName) throws InternalKernelException {
+        try {
+            return mbeanServer.getAttribute(Kernel.KERNEL, attributeName);
+        } catch (Exception e) {
+            Throwable cause = unwrapJMException(e);
+            if (cause instanceof InstanceNotFoundException) {
+                throw new InternalKernelException("Kernel is not loaded");
+            } else if (cause instanceof AttributeNotFoundException) {
+                throw new InternalKernelException("KernelDelegate is out of synch with Kernel");
+            } else {
+                throw new InternalKernelException(cause);
+            }
+        }
+    }
+
+    private Object invokeKernel(String methodName, Object[] args, String[] types) throws InternalKernelException, Exception {
+        try {
+            return mbeanServer.invoke(Kernel.KERNEL, methodName, args, types);
+        } catch (Exception e) {
+            Throwable cause = unwrapJMException(e);
+            if (cause instanceof InstanceNotFoundException) {
+                throw new InternalKernelException("Kernel is not loaded");
+            } else if (cause instanceof NoSuchMethodException) {
+                throw new InternalKernelException("KernelDelegate is out of synch with Kernel");
+            } else if (cause instanceof JMException) {
+                throw new InternalKernelException(cause);
+            } else if (cause instanceof JMRuntimeException) {
+                throw new InternalKernelException(cause);
+            } else if (cause instanceof Error) {
+                throw (Error) cause;
+            } else if (cause instanceof Exception) {
+                throw (Exception) cause;
+            } else {
+                throw new InternalKernelException("Unknown throwable", cause);
+            }
+        }
+    }
+
+    private Throwable unwrapJMException(Throwable cause) {
+        while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
+            cause = cause.getCause();
+        }
+        return cause;
+    }
+
+
+}

Copied: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelMBean.java (from r109772, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelMBean.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java&r1=109772&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelMBean.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelMBean.java	Sun Dec  5 23:52:06 2004
@@ -15,25 +15,28 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.kernel;
+package org.apache.geronimo.kernel.jmx;
 
 import java.io.IOException;
 import java.net.URI;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
-import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 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.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 
 /**
+ * @deprecated nothing implements this interface.... we should introduce a Kernel interface
  * @version $Rev$ $Date$
  */
 public interface KernelMBean {
@@ -44,13 +47,6 @@
     Date getBootTime();
 
     /**
-     * Get the MBeanServer used by this kernel
-     *
-     * @return the MBeanServer used by this kernel
-     */
-    MBeanServer getMBeanServer();
-
-    /**
      * Get the name of this kernel
      *
      * @return the name of this kernel
@@ -63,8 +59,8 @@
      *
      * @param gbeanData the GBean to load
      * @param classLoader the class loader to use to load the gbean
-     * @throws GBeanAlreadyExistsException if the name is already used
-     * @throws InternalKernelException if there is a problem during registration
+     * @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
      */
     public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException;
 
@@ -84,10 +80,11 @@
      * Start a specific GBean.
      *
      * @param name the GBean to start
-     * @throws GBeanNotFoundException if the GBean could not be found
+     * @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
      */
-    void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException;
+    void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Start a specific GBean and its children.
@@ -95,8 +92,9 @@
      * @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
      */
-    void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException;
+    void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Stop a specific GBean.
@@ -104,8 +102,9 @@
      * @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
      */
-    void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException;
+    void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Unload a specific GBean.

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java?view=auto&rev=109956
==============================================================================

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,335 @@
+/**
+ *
+ * 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.jmx;
+
+import java.io.ObjectInputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.OperationsException;
+import javax.management.QueryExp;
+import javax.management.ReflectionException;
+import javax.management.loading.ClassLoaderRepository;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+ 
+/**
+ * A MBeanServerImplementation that delegates to a Kernel.
+ * @version $Rev:  $ $Date:  $
+ */
+public class MBeanServerDelegate implements MBeanServer {
+    private final Kernel kernel;
+
+    public MBeanServerDelegate(Kernel kernel) {
+        this.kernel = kernel;
+    }
+
+    public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
+        try {
+            return kernel.getAttribute(name, attribute);
+        } catch (NoSuchAttributeException e) {
+            throw new AttributeNotFoundException(attribute);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.getCanonicalName());
+        } catch (InternalKernelException e) {
+            throw new MBeanException(unwrapInternalKernelException(e));
+        } catch (Exception e) {
+            throw new MBeanException(e);
+        }
+    }
+
+    public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
+        AttributeList attributeList = new AttributeList(attributes.length);
+        for (int i = 0; i < attributes.length; i++) {
+            String attribute = attributes[i];
+            try {
+                Object value = kernel.getAttribute(name, attribute);
+                attributeList.add(i, new Attribute(attribute, value));
+            } catch (NoSuchAttributeException e) {
+                // ignored - caller will simply find no value
+            } catch (GBeanNotFoundException e) {
+                throw new InstanceNotFoundException(name.getCanonicalName());
+            } catch (InternalKernelException e) {
+                throw new ReflectionException(unwrapInternalKernelException(e));
+            } catch (Exception e) {
+                // ignored - caller will simply find no value
+            }
+        }
+        return attributeList;
+    }
+
+    public String getDefaultDomain() {
+        return kernel.getKernelName();
+    }
+
+    public Integer getMBeanCount() {
+        return new Integer(kernel.listGBeans((ObjectName)null).size());
+    }
+
+    public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, ReflectionException {
+        GBeanInfo gbeanInfo;
+        try {
+            gbeanInfo = kernel.getGBeanInfo(name);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.toString());
+        } catch (InternalKernelException e) {
+            throw new ReflectionException(unwrapInternalKernelException(e));
+        }
+        return JMXUtil.toMBeanInfo(gbeanInfo);
+    }
+
+    public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException {
+        try {
+            return kernel.invoke(name, operationName, params, signature);
+        } catch (NoSuchOperationException e) {
+            throw new ReflectionException(new NoSuchMethodException(e.getMessage()));
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.getCanonicalName());
+        } catch (InternalKernelException e) {
+            throw new MBeanException(unwrapInternalKernelException(e));
+        } catch (Exception e) {
+            throw new MBeanException(e);
+        }
+    }
+
+    public boolean isRegistered(ObjectName name) {
+        return kernel.isLoaded(name);
+    }
+
+    public Set queryNames(ObjectName pattern, QueryExp query) {
+        Set names = kernel.listGBeans(pattern);
+        if (query == null) {
+            return names;
+        }
+
+        Set filteredNames = new HashSet(names.size());
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            // this must be done for each objectName applied
+            query.setMBeanServer(this);
+
+            ObjectName name = (ObjectName) iterator.next();
+            try {
+                if (query.apply(name)) {
+                    filteredNames.add(name);
+                }
+            } catch (Exception e) {
+                // reject any name that threw an exception
+            }
+        }
+        return filteredNames;
+    }
+
+    public Set queryMBeans(ObjectName pattern, QueryExp query) {
+        Set names = queryNames(pattern, query);
+        Set objectInstances = new HashSet(names.size());
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            ObjectName name = (ObjectName) iterator.next();
+            try {
+                objectInstances.add(getObjectInstance(name));
+            } catch (InstanceNotFoundException e) {
+                // ignore
+            }
+        }
+        return objectInstances;
+    }
+
+    public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, MBeanException {
+        String attributeName = attribute.getName();
+        Object attributeValue = attribute.getValue();
+        try {
+            kernel.setAttribute(name, attributeName, attributeValue);
+        } catch (NoSuchAttributeException e) {
+            throw new AttributeNotFoundException(attributeName);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.getCanonicalName());
+        } catch (InternalKernelException e) {
+            throw new MBeanException(unwrapInternalKernelException(e));
+        } catch (Exception e) {
+            throw new MBeanException(e);
+        }
+    }
+
+    public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException {
+        AttributeList set = new AttributeList(attributes.size());
+        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+            Attribute attribute = (Attribute) iterator.next();
+            String attributeName = attribute.getName();
+            Object attributeValue = attribute.getValue();
+            try {
+                kernel.setAttribute(name, attributeName, attributeValue);
+                set.add(attribute);
+            } catch (NoSuchAttributeException e) {
+                // ignored - caller will see value was not set because this attribute will not be in the attribute list
+            } catch (GBeanNotFoundException e) {
+                throw new InstanceNotFoundException(name.getCanonicalName());
+            } catch (InternalKernelException e) {
+                throw new ReflectionException(unwrapInternalKernelException(e));
+            } catch (Exception e) {
+                // ignored - caller will see value was not set because this attribute will not be in the attribute list
+            }
+        }
+        return set;
+    }
+
+    public String[] getDomains() {
+        Set domains = new HashSet();
+        Set names = kernel.listGBeans((ObjectName)null);
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            ObjectName objectName = (ObjectName) iterator.next();
+            domains.add(objectName.getDomain());
+        }
+        return (String[]) domains.toArray(new String[domains.size()]);
+    }
+
+    public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException {
+        try {
+            GBeanInfo gbeanInfo = kernel.getGBeanInfo(objectName);
+            return new ObjectInstance(objectName, gbeanInfo.getClassName());
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(objectName.getCanonicalName());
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(ObjectName objectName) throws InstanceNotFoundException {
+        try {
+            return kernel.getClassLoaderFor(objectName);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(objectName.getCanonicalName());
+        }
+    }
+
+    private static Exception unwrapInternalKernelException(InternalKernelException e) {
+        if (e.getCause() instanceof Exception) {
+            return (Exception) e.getCause();
+        }
+        return e;
+    }
+
+    //////////////////////////////////////////////
+    //
+    // NOT ALLOWED
+    //
+    //////////////////////////////////////////////
+
+    public void addNotificationListener(ObjectName objectName, NotificationListener notificationListener, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void addNotificationListener(ObjectName objectName, ObjectName objectName1, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, ObjectName objectName1) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, NotificationListener notificationListener) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, ObjectName objectName1, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, NotificationListener notificationListener, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public boolean isInstanceOf(ObjectName objectName, String s) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName, ObjectName objectName1) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName, Object[] objects, String[] strings) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName, ObjectName objectName1, Object[] objects, String[] strings) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s) throws ReflectionException, MBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s, ObjectName objectName) throws ReflectionException, MBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s, Object[] objects, String[] strings) throws ReflectionException, MBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s, ObjectName objectName, Object[] objects, String[] strings) throws ReflectionException, MBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance registerMBean(Object o, ObjectName objectName) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInputStream deserialize(String s, ObjectName objectName, byte[] bytes) throws InstanceNotFoundException, OperationsException, ReflectionException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInputStream deserialize(String s, byte[] bytes) throws OperationsException, ReflectionException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInputStream deserialize(ObjectName objectName, byte[] bytes) throws InstanceNotFoundException, OperationsException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ClassLoader getClassLoader(ObjectName objectName) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ClassLoaderRepository getClassLoaderRepository() {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void unregisterMBean(ObjectName objectName) throws InstanceNotFoundException, MBeanRegistrationException {
+        throw new SecurityException("Operation not allowed");
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/BasicLifecycleMonitor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/BasicLifecycleMonitor.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/BasicLifecycleMonitor.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,249 @@
+/**
+ *
+ * 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.lifecycle;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+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.runtime.LifecycleBroadcaster;
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
+ */
+public class BasicLifecycleMonitor implements LifecycleMonitor {
+    private static final Log log = LogFactory.getLog(BasicLifecycleMonitor.class);
+
+    private final Kernel kernel;
+
+    // todo we should only hold weak references to the listeners
+    private final Map boundListeners = new HashMap();
+    private final Map listenerPatterns = new HashMap();
+
+    public BasicLifecycleMonitor(Kernel kernel) {
+        this.kernel = kernel;
+
+        // register for state change notifications with all mbeans that match the target patterns
+        Set names = this.kernel.listGBeans((ObjectName)null);
+        for (Iterator objectNameIterator = names.iterator(); objectNameIterator.hasNext();) {
+            addSource((ObjectName) objectNameIterator.next());
+        }
+    }
+
+    public synchronized void destroy() {
+        boundListeners.clear();
+        listenerPatterns.clear();
+    }
+
+    private synchronized void addSource(ObjectName source) {
+        if (boundListeners.containsKey(source)) {
+            // alreayd registered
+            return;
+        }
+
+        // find all listeners interested in events from this source
+        HashSet listeners = new HashSet();
+        for (Iterator listenerIterator = listenerPatterns.entrySet().iterator(); listenerIterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) listenerIterator.next();
+            Set patterns = (Set) entry.getValue();
+            for (Iterator patternIterator = patterns.iterator(); patternIterator.hasNext();) {
+                ObjectName pattern = (ObjectName) patternIterator.next();
+                if (pattern.apply(source)) {
+                    LifecycleListener listener = (LifecycleListener) entry.getKey();
+                    listeners.add(listener);
+                }
+            }
+        }
+
+        boundListeners.put(source, listeners);
+    }
+
+    private synchronized void removeSource(ObjectName source) {
+        boundListeners.remove(source);
+    }
+
+    public synchronized void addLifecycleListener(LifecycleListener listener, ObjectName pattern) {
+        addLifecycleListener(listener, Collections.singleton(pattern));
+    }
+
+    public synchronized void addLifecycleListener(LifecycleListener listener, Set patterns) {
+        for (Iterator patternIterator = patterns.iterator(); patternIterator.hasNext();) {
+            ObjectName pattern = (ObjectName) patternIterator.next();
+            for (Iterator iterator = boundListeners.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                ObjectName source = (ObjectName) entry.getKey();
+                if (pattern.apply(source)) {
+                    Set listeners = (Set) entry.getValue();
+                    listeners.add(listener);
+                }
+            }
+        }
+        listenerPatterns.put(listener, patterns);
+    }
+
+    public synchronized void removeLifecycleListener(LifecycleListener listener) {
+        for (Iterator iterator = boundListeners.values().iterator(); iterator.hasNext();) {
+            Set set = (Set) iterator.next();
+            set.remove(listener);
+        }
+        listenerPatterns.remove(listener);
+    }
+
+    private synchronized Set getTargets(ObjectName source) {
+        Set targets = (Set) boundListeners.get(source);
+        if (targets == null) {
+            // no one is interested in this event
+            return Collections.EMPTY_SET;
+        } else {
+            return new HashSet(targets);
+        }
+    }
+
+    private void fireLoadedEvent(ObjectName objectName) {
+        Set targets = getTargets(objectName);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.loaded(objectName);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireStartingEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.starting(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireRunningEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.running(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireStoppingEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.stopping(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireStoppedEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.stopped(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireFailedEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.failed(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireUnloadedEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.unloaded(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    public LifecycleBroadcaster createLifecycleBroadcaster(ObjectName objectName) {
+        return new RawLifecycleBroadcaster(objectName);
+    }
+
+    private class RawLifecycleBroadcaster implements LifecycleBroadcaster {
+        private final ObjectName objectName;
+
+        public RawLifecycleBroadcaster(ObjectName objectName) {
+            this.objectName = objectName;
+        }
+
+        public void fireLoadedEvent() {
+            addSource(objectName);
+            BasicLifecycleMonitor.this.fireLoadedEvent(objectName);
+        }
+
+        public void fireStartingEvent() {
+            BasicLifecycleMonitor.this.fireStartingEvent(objectName);
+        }
+
+        public void fireRunningEvent() {
+            BasicLifecycleMonitor.this.fireRunningEvent(objectName);
+        }
+
+        public void fireStoppingEvent() {
+            BasicLifecycleMonitor.this.fireStoppingEvent(objectName);
+        }
+
+        public void fireStoppedEvent() {
+            BasicLifecycleMonitor.this.fireStoppedEvent(objectName);
+        }
+
+        public void fireFailedEvent() {
+            BasicLifecycleMonitor.this.fireFailedEvent(objectName);
+        }
+
+        public void fireUnloadedEvent() {
+            BasicLifecycleMonitor.this.fireUnloadedEvent(objectName);
+            removeSource(objectName);
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleAdapter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleAdapter.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleAdapter.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 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.lifecycle;
+
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LifecycleAdapter implements LifecycleListener {
+    public void loaded(ObjectName objectName) {
+    }
+
+    public void starting(ObjectName objectName) {
+    }
+
+    public void running(ObjectName objectName) {
+    }
+
+    public void stopping(ObjectName objectName) {
+    }
+
+    public void stopped(ObjectName objectName) {
+    }
+
+    public void failed(ObjectName objectName) {
+    }
+
+    public void unloaded(ObjectName objectName) {
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleListener.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleListener.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleListener.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 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.lifecycle;
+
+import java.util.EventListener;
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface LifecycleListener extends EventListener {
+    public void loaded(ObjectName objectName);
+    public void starting(ObjectName objectName);
+    public void running(ObjectName objectName);
+    public void stopping(ObjectName objectName);
+    public void stopped(ObjectName objectName);
+    public void failed(ObjectName objectName);
+    public void unloaded(ObjectName objectName);
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitor.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitor.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 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.lifecycle;
+
+import java.util.Set;
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface LifecycleMonitor {
+    void addLifecycleListener(LifecycleListener listener, ObjectName pattern);
+
+    void addLifecycleListener(LifecycleListener listener, Set patterns);
+
+    void removeLifecycleListener(LifecycleListener listener);
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitorFlyweight.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitorFlyweight.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/LifecycleMonitorFlyweight.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 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.lifecycle;
+
+import java.util.Set;
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LifecycleMonitorFlyweight implements LifecycleMonitor {
+    private final LifecycleMonitor lifecycleMonitor;
+
+    public LifecycleMonitorFlyweight(LifecycleMonitor lifecycleMonitor) {
+        this.lifecycleMonitor = lifecycleMonitor;
+    }
+
+    public void addLifecycleListener(LifecycleListener listener, ObjectName pattern) {
+        lifecycleMonitor.addLifecycleListener(listener, pattern);
+    }
+
+    public void addLifecycleListener(LifecycleListener listener, Set patterns) {
+        lifecycleMonitor.addLifecycleListener(listener, patterns);
+    }
+
+    public void removeLifecycleListener(LifecycleListener listener) {
+        lifecycleMonitor.removeLifecycleListener(listener);
+    }
+}

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java	Sun Dec  5 23:52:06 2004
@@ -33,9 +33,6 @@
     // todo use weak keys for this
     private final IdentityHashMap interceptors = new IdentityHashMap();
 
-    /**
-     * @deprecated don't use this yet... it may change or go away
-     */
     public ProxyManager(Kernel kernel) {
         this.kernel = kernel;
     }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/BasicGBeanRegistry.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/BasicGBeanRegistry.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/BasicGBeanRegistry.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,229 @@
+/**
+ *
+ * Copyright 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.registry;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.GBeanInstance;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicGBeanRegistry implements GBeanRegistry {
+    private final Map registry = new HashMap();
+    private final Map domainIndex = new HashMap();
+    private String defaultDomainName;
+
+    public void start(Kernel kernel) {
+        this.defaultDomainName = kernel.getKernelName();
+    }
+
+    public void stop() {
+        // todo destroy instances
+        synchronized (this) {
+            registry.clear();
+            domainIndex.clear();
+        }
+    }
+
+    public boolean isRegistered(ObjectName name) {
+        synchronized (this) {
+            return registry.containsKey(name);
+        }
+    }
+
+    public void register(GBeanInstance gbeanInstance) throws GBeanAlreadyExistsException, InternalKernelException {
+        // do as much work as possible outside of the synchronized block
+        ObjectName name = gbeanInstance.getObjectNameObject();
+        String domainName = name.getDomain();
+        // convert properties list to a HashMap as it is more efficient then the synchronized Hashtable
+        Map properties = new HashMap(name.getKeyPropertyList());
+
+        synchronized (this) {
+            registry.put(name, gbeanInstance);
+
+            Map nameToProperties = (Map) domainIndex.get(domainName);
+            if (nameToProperties == null) {
+                nameToProperties = new HashMap();
+                domainIndex.put(domainName, nameToProperties);
+            }
+            nameToProperties.put(name, properties);
+        }
+    }
+
+    public void unregister(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
+        String domainName = name.getDomain();
+        synchronized (this) {
+            registry.remove(name);
+
+            // just leave the an empty nameToProperty map
+            Map nameToProperties = (Map) domainIndex.get(domainName);
+            if (nameToProperties != null) {
+                nameToProperties.remove(name);
+            }
+        }
+    }
+
+    public GBeanInstance getGBeanInstance(ObjectName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance;
+        synchronized (this) {
+            gbeanInstance = (GBeanInstance) registry.get(name);
+        }
+        if (gbeanInstance == null) {
+            throw new GBeanNotFoundException(name.getCanonicalName());
+        }
+        return gbeanInstance;
+    }
+
+    public Set listGBeans(ObjectName pattern) throws InternalKernelException {
+        if (pattern == null) {
+            synchronized (this) {
+                return new HashSet(registry.keySet());
+            }
+        }
+
+        String patternDomain = pattern.getDomain();
+        if (patternDomain.length() == 0) {
+            patternDomain = defaultDomainName;
+        }
+
+        // work with a copy of the registry key set
+        List nameToProperties;
+        if (!pattern.isDomainPattern()) {
+            synchronized (this) {
+                // create an array list big enough to match all names... extra space is better than resizing
+                nameToProperties = new ArrayList(registry.size());
+
+                // find we are only matching one specific domain, so
+                // just grab it directly from the index
+                Map map = (Map) domainIndex.get(patternDomain);
+                if (map != null) {
+                    nameToProperties.addAll(map.entrySet());
+                }
+            }
+        } else if (patternDomain.equals("*")) {
+            // this is very commmon, so support it directly
+            synchronized (this) {
+                // create an array list big enough to match all names... extra space is better than resizing
+                nameToProperties = new ArrayList(registry.size());
+
+                // find we are matching all domain, so just grab all of them directly
+                for (Iterator iterator = domainIndex.values().iterator(); iterator.hasNext();) {
+                    Map map = (Map) iterator.next();
+
+                    // we can just copy the entry set directly into the list we don't
+                    // have to worry about duplicates as the maps are mutually exclusive
+                    nameToProperties.addAll(map.entrySet());
+                }
+            }
+        } else {
+            String perl5Pattern = domainPatternToPerl5(patternDomain);
+            Pattern domainPattern = Pattern.compile(perl5Pattern);
+
+            synchronized (this) {
+                // create an array list big enough to match all names... extra space is better than resizing
+                nameToProperties = new ArrayList(registry.size());
+
+                // find all of the matching domains
+                for (Iterator iterator = domainIndex.entrySet().iterator(); iterator.hasNext();) {
+                    Map.Entry entry = (Map.Entry) iterator.next();
+                    String domain = (String) entry.getKey();
+                    if (domainPattern.matcher(domain).matches()) {
+                        // we can just copy the entry set directly into the list we don't
+                        // have to worry about duplicates as the maps are mutually exclusive
+                        Map map = (Map) entry.getValue();
+                        nameToProperties.addAll(map.entrySet());
+                    }
+                }
+            }
+        }
+
+        if (nameToProperties.isEmpty()) {
+            return Collections.EMPTY_SET;
+        }
+
+        // convert the pattern property list to a HashMap as it is not synchronized
+        Map patternProperties = new HashMap(pattern.getKeyPropertyList());
+        patternProperties.remove("*");
+        boolean isMatchAll = patternProperties.isEmpty();
+        boolean isPropertyPattern = pattern.isPropertyPattern();
+
+        Set matchingNames = new HashSet();
+        for (Iterator iterator = nameToProperties.iterator(); iterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            Map properties = (Map) entry.getValue();
+
+            if (isMatchAll) {
+                matchingNames.add(entry.getKey());
+            } else if (isPropertyPattern) {
+                if (properties.entrySet().containsAll(patternProperties.entrySet())) {
+                    matchingNames.add(entry.getKey());
+                }
+
+            } else {
+                if (properties.entrySet().equals(patternProperties.entrySet())) {
+                    matchingNames.add(entry.getKey());
+                }
+            }
+        }
+        return matchingNames;
+    }
+
+    private static String domainPatternToPerl5(String pattern) {
+        char[] patternCharacters = pattern.toCharArray();
+        StringBuffer buffer = new StringBuffer(2 * patternCharacters.length);
+        for (int position = 0; position < patternCharacters.length; position++) {
+            char character = patternCharacters[position];
+            switch (character) {
+                case '*':
+                    // replace '*' with '.*'
+                    buffer.append(".*");
+                    break;
+                case '?':
+                    // replace '?' with '.'
+                    buffer.append('.');
+                    break;
+                default:
+                    // escape any perl5 characters with '\'
+                    if (isPerl5MetaCharacter(character)) {
+                        buffer.append('\\');
+                    }
+                    buffer.append(character);
+                    break;
+            }
+        }
+
+        return buffer.toString();
+    }
+
+    private static boolean isPerl5MetaCharacter(char character) {
+        return ("'*?+[]()|^$.{}\\".indexOf(character) >= 0);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/GBeanRegistry.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/GBeanRegistry.java?view=auto&rev=109957
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/GBeanRegistry.java	Sun Dec  5 23:52:06 2004
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 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.registry;
+
+import java.util.Set;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.GBeanInstance;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface GBeanRegistry {
+    void start(Kernel kernel);
+
+    void stop();
+
+    boolean isRegistered(ObjectName name);
+
+    void register(GBeanInstance gbeanInstance) throws GBeanAlreadyExistsException, InternalKernelException;
+
+    void unregister(ObjectName name) throws GBeanNotFoundException, InternalKernelException;
+
+    GBeanInstance getGBeanInstance(ObjectName name) throws GBeanNotFoundException;
+
+    Set listGBeans(ObjectName pattern) throws InternalKernelException;
+}

Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java	(original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java	Sun Dec  5 23:52:06 2004
@@ -95,7 +95,7 @@
         printResults("FastClass", end, start, iterations);
 
         // start a kernel
-        Kernel kernel = new Kernel();
+        Kernel kernel = new Kernel("speed");
         kernel.boot();
         GBeanMBean mockGBean = new GBeanMBean(MockGBean.getGBeanInfo(), Speed.class.getClassLoader());
         mockGBean.setAttribute("Name", "bar");
@@ -225,7 +225,7 @@
         printResults("FastClass", end, start, iterations);
 
         // start a kernel
-        Kernel kernel = new Kernel();
+        Kernel kernel = new Kernel("speed");
         kernel.boot();
         GBeanMBean mockGBean = new GBeanMBean(MockGBean.getGBeanInfo(), Speed.class.getClassLoader());
         mockGBean.setAttribute("Name", "bar");

Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java	(original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java	Sun Dec  5 23:52:06 2004
@@ -348,12 +348,14 @@
         kernel = new Kernel("test");
         kernel.boot();
 
-        gbeanInstance = new GBeanInstance(kernel,
-                new GBeanData(new ObjectName("test:MockGBean=normal"), MockGBean.getGBeanInfo()),
+        gbeanInstance = new GBeanInstance(new GBeanData(new ObjectName("test:MockGBean=normal"), MockGBean.getGBeanInfo()),
+                kernel,
+                kernel.getDependencyManager(),
                 new MyLifecycleBroadcaster(),
                 MockGBean.class.getClassLoader());
-        dynamicGBeanInstance = new GBeanInstance(kernel,
-                new GBeanData(new ObjectName("test:MockGBean=dynamic"), MockDynamicGBean.getGBeanInfo()),
+        dynamicGBeanInstance = new GBeanInstance(new GBeanData(new ObjectName("test:MockGBean=dynamic"), MockDynamicGBean.getGBeanInfo()),
+                kernel,
+                kernel.getDependencyManager(),
                 new MyLifecycleBroadcaster(),
                 MockGBean.class.getClassLoader());
         getInvoker = new MethodInvoker() {

Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java?view=diff&rev=109957&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java&r1=109956&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java	(original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java	Sun Dec  5 23:52:06 2004
@@ -24,32 +24,9 @@
  *
  * @version $Rev$ $Date$
  */
-public class ClassloadingTest
-        extends TestCase {
-    protected Class loadClass(final String name) {
-        Class type = null;
-
-        try {
-            type = ClassLoading.loadClass(name);
-        } catch (ClassNotFoundException e) {
-            fail("Class should have been found: " + e);
-        }
-
-        assertNotNull(type);
-
-        return type;
-    }
-
+public class ClassloadingTest extends TestCase {
     public void testLoadClass_Null() {
         try {
-            ClassLoading.loadClass(null);
-            fail("Expected NullArgumentException");
-        } catch (IllegalArgumentException ignore) {
-        } catch (ClassNotFoundException e) {
-            fail("Class should have been found: " + e);
-        }
-
-        try {
             ClassLoading.loadClass("org.apache.geronimo.kernel.ClassLoading", null);
             fail("Expected NullArgumentException");
         } catch (IllegalArgumentException ignore) {
@@ -64,15 +41,6 @@
         assertEquals(className, type.getName());
     }
 
-    public void testLoadClass_Missing() {
-        String className = "some.class.that.does.not.Exist";
-        try {
-            ClassLoading.loadClass(className);
-            fail("Expected ClassNotFoundException: " + className);
-        } catch (ClassNotFoundException ignore) {
-        }
-    }
-
     public void testLoadClass_Primitives() {
         String className = "boolean";
         Class type = loadClass(className);
@@ -146,5 +114,19 @@
         y = loadClass(x);
         assertEquals(t, y);
 
+    }
+
+    private Class loadClass(String name) {
+        Class type = null;
+
+        try {
+            type = ClassLoading.loadClass(name, getClass().getClassLoader());
+        } catch (ClassNotFoundException e) {
+            fail("Class should have been found: " + e);
+        }
+
+        assertNotNull(type);
+
+        return type;
     }
 }

Deleted: /geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/RunTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/RunTest.java?view=auto&rev=109956
==============================================================================

Modified: geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java?view=diff&rev=109957&p1=geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java&r1=109956&p2=geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java	(original)
+++ geronimo/trunk/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java	Sun Dec  5 23:52:06 2004
@@ -18,6 +18,7 @@
 package org.apache.geronimo.remoting.jmx;
 
 import javax.management.ObjectName;
+import javax.management.MBeanServer;
 
 import org.apache.geronimo.core.service.Interceptor;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -25,6 +26,7 @@
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.jmx.MBeanServerDelegate;
 import org.apache.geronimo.proxy.ProxyContainer;
 import org.apache.geronimo.proxy.ReflexiveInterceptor;
 import org.apache.geronimo.remoting.DeMarshalingInterceptor;
@@ -63,7 +65,8 @@
         router.register(objectName, this);
 
         // Setup the server side contianer..
-        Interceptor firstInterceptor = new ReflexiveInterceptor(kernel.getMBeanServer());
+        MBeanServer mbeanServer = new MBeanServerDelegate(kernel);
+        Interceptor firstInterceptor = new ReflexiveInterceptor(mbeanServer);
         demarshaller = new DeMarshalingInterceptor(firstInterceptor, getClass().getClassLoader());
         serverContainer = new ProxyContainer(firstInterceptor);
     }

Modified: geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java?view=diff&rev=109957&p1=geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java&r1=109956&p2=geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java	(original)
+++ geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java	Sun Dec  5 23:52:06 2004
@@ -23,10 +23,14 @@
 import javax.management.ObjectName;
 
 import junit.framework.TestCase;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.remoting.jmx.MBeanServerStub;
 import org.apache.geronimo.remoting.jmx.RemoteMBeanServerFactory;
+import org.apache.geronimo.remoting.router.JMXRouter;
+import org.apache.geronimo.remoting.router.SubsystemRouter;
 import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
+import org.apache.geronimo.remoting.transport.TransportLoader;
 
 
 /**
@@ -43,32 +47,32 @@
     MBeanServer remoteProxy;
 
     public void setUp() throws Exception {
-        kernel = new Kernel("test.kernel", "simple.geronimo.test");
+        kernel = new Kernel("simple.geronimo.test");
         kernel.boot();
 
-        GBeanMBean gbean;
+        GBeanData gbean;
 
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         // Create all the parts
-        gbean = new GBeanMBean("org.apache.geronimo.remoting.router.SubsystemRouter", cl);
         subsystemRouter = new ObjectName("geronimo.remoting:router=SubsystemRouter");
-        kernel.loadGBean(subsystemRouter, gbean);
+        gbean = new GBeanData(subsystemRouter, SubsystemRouter.GBEAN_INFO);
+        kernel.loadGBean(gbean, cl);
 
-        gbean = new GBeanMBean("org.apache.geronimo.remoting.transport.TransportLoader", cl);
+        asyncTransport = new ObjectName("geronimo.remoting:transport=async");
+        gbean = new GBeanData(asyncTransport, TransportLoader.GBEAN_INFO);
         gbean.setAttribute("bindURI", new URI("async://0.0.0.0:0"));
         gbean.setReferencePatterns("Router", Collections.singleton(subsystemRouter));
-        asyncTransport = new ObjectName("geronimo.remoting:transport=async");
-        kernel.loadGBean(asyncTransport, gbean);
+        kernel.loadGBean(gbean, cl);
 
-        gbean = new GBeanMBean("org.apache.geronimo.remoting.router.JMXRouter", cl);
-        gbean.setReferencePatterns("SubsystemRouter", Collections.singleton(subsystemRouter));
         jmxRouter = new ObjectName("geronimo.remoting:router=JMXRouter");
-        kernel.loadGBean(jmxRouter, gbean);
+        gbean = new GBeanData(jmxRouter, JMXRouter.GBEAN_INFO);
+        gbean.setReferencePatterns("SubsystemRouter", Collections.singleton(subsystemRouter));
+        kernel.loadGBean(gbean, cl);
 
-        gbean = new GBeanMBean("org.apache.geronimo.remoting.jmx.MBeanServerStub", cl);
-        gbean.setReferencePatterns("Router", Collections.singleton(jmxRouter));
         serverStub = new ObjectName("geronimo.remoting:target=MBeanServerStub");
-        kernel.loadGBean(serverStub, gbean);
+        gbean = new GBeanData(serverStub, MBeanServerStub.GBEAN_INFO);
+        gbean.setReferencePatterns("Router", Collections.singleton(jmxRouter));
+        kernel.loadGBean(gbean, cl);
 
         kernel.startGBean(subsystemRouter);
         kernel.startGBean(asyncTransport);

Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java?view=diff&rev=109957&p1=geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java&r1=109956&p2=geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java	(original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java	Sun Dec  5 23:52:06 2004
@@ -36,7 +36,6 @@
 import org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal;
 import org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
 import org.apache.geronimo.kernel.Kernel;
 
 

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java?view=diff&rev=109957&p1=geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java&r1=109956&p2=geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java	(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ClientCommandLine.java	Sun Dec  5 23:52:06 2004
@@ -20,9 +20,6 @@
 import java.util.Collections;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.system.main.CommandLine;
-import org.apache.geronimo.system.main.ExceptionUtil;
-
 /**
  * @version $Revision$ $Date$
  */

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java?view=diff&rev=109957&p1=geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java&r1=109956&p2=geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java&r2=109957
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java	(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java	Sun Dec  5 23:52:06 2004
@@ -32,6 +32,7 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.jmx.JMXGBeanRegistry;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.log.GeronimoLogging;
 import org.apache.geronimo.system.url.GeronimoURLFactory;
@@ -97,8 +98,8 @@
                 ois.close();
             }
 
-            // build a basic kernel without a configuration-store, our configuration store is
-            final Kernel kernel = new Kernel("geronimo.kernel", "geronimo");
+            // build a jms kernel
+            final Kernel kernel = new Kernel("geronimo", new JMXGBeanRegistry());
 
             // boot the kernel
             try {

Modified: geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java?view=diff&rev=109957&p1=geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java&r1=109956&p2=geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java&r2=109957
==============================================================================
--- geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java	(original)
+++ geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java	Sun Dec  5 23:52:06 2004
@@ -29,6 +29,7 @@
 
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.jmx.JMXGBeanRegistry;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.log.GeronimoLogging;
 import org.apache.geronimo.system.url.GeronimoURLFactory;
@@ -105,7 +106,7 @@
         }
 
         // build a basic kernel without a configuration-store, our configuration store is
-        Kernel kernel = new Kernel(getKernelName(), getDomainName());
+        Kernel kernel = new Kernel(getKernelName(), new JMXGBeanRegistry());
         kernel.boot();
 
         ConfigurationManager configurationManager = kernel.getConfigurationManager();

Modified: geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java?view=diff&rev=109957&p1=geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java&r1=109956&p2=geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java&r2=109957
==============================================================================
--- geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java	(original)
+++ geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java	Sun Dec  5 23:52:06 2004
@@ -1,17 +1,16 @@
 package org.apache.geronimo.deployment.mavenplugin;
 
-import org.apache.geronimo.kernel.KernelMBean;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
-
+import java.util.HashMap;
+import java.util.Map;
 import javax.management.MBeanServerConnection;
 import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXServiceURL;
 import javax.management.remote.JMXConnectorFactory;
-import java.util.Map;
-import java.util.HashMap;
-import java.io.IOException;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
+import org.apache.geronimo.kernel.jmx.KernelDelegate;
 
 /**
  */
@@ -36,7 +35,7 @@
             Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
             JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
             mbServerConnection = jmxConnector.getMBeanServerConnection();
-            kernel = (KernelMBean) MBeanProxyFactory.getProxy(KernelMBean.class, mbServerConnection, Kernel.KERNEL);
+            kernel = new KernelDelegate(mbServerConnection);
             kernel.shutdown();
 
         } finally {

Modified: geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java?view=diff&rev=109957&p1=geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java&r1=109956&p2=geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java&r2=109957
==============================================================================
--- geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java	(original)
+++ geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java	Sun Dec  5 23:52:06 2004
@@ -16,20 +16,18 @@
  */
 package org.apache.geronimo.deployment.mavenplugin;
 
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.KernelMBean;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
-import org.apache.geronimo.kernel.management.State;
-
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
 import javax.management.MBeanServerConnection;
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
+
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.kernel.jmx.KernelDelegate;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
+import org.apache.geronimo.kernel.management.State;
 
 public class WaitForStarted extends AbstractModuleCommand {
 
@@ -65,9 +63,9 @@
                 try {
                     JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
                     mbServerConnection = jmxConnector.getMBeanServerConnection();
-                    kernel = (KernelMBean) MBeanProxyFactory.getProxy(KernelMBean.class, mbServerConnection, Kernel.KERNEL);
+                    kernel = new KernelDelegate(mbServerConnection);
                     break;
-                } catch (IOException e) {
+                } catch (Exception e) {
                     if (tries == 0) {
                         throw new Exception("Could not connect");
                     }

Mime
View raw message