You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2005/02/03 03:50:06 UTC

svn commit: r151106 [1/2] - in geronimo/trunk/modules: axis/src/java/org/apache/geronimo/axis/ axis/src/test/org/apache/geronimo/axis/ axis/src/test/org/apache/geronimo/axis/preconditions/ connector/src/java/org/apache/geronimo/connector/ connector/src/java/org/apache/geronimo/connector/outbound/ connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/ connector/src/java/org/apache/geronimo/connector/work/ core/src/java/org/apache/geronimo/pool/ derby/src/java/org/apache/geronimo/derby/ interop/src/java/org/apache/geronimo/interop/ jetty/src/java/org/apache/geronimo/jetty/ jetty/src/java/org/apache/geronimo/jetty/connector/ jetty/src/java/org/apache/geronimo/jetty/requestlog/ jmx-remoting/src/java/org/apache/geronimo/jmxremoting/ kernel/src/java/org/apache/geronimo/gbean/ kernel/src/java/org/apache/geronimo/gbean/runtime/ kernel/src/java/org/apache/geronimo/kernel/ kernel/src/java/org/apache/geronimo/kernel/config/ kernel/src/java/org/apache/geronimo/kernel/jmx/ kernel/src/java/org/apache/geronimo/kernel/registry/ kernel/src/test/org/apache/geronimo/gbean/runtime/ mail/src/java/org/apache/geronimo/mail/ security/src/java/org/apache/geronimo/security/jaas/ spring/src/java/org/apache/geronimo/spring/ system/src/java/org/apache/geronimo/system/configuration/ system/src/java/org/apache/geronimo/system/repository/ system/src/java/org/apache/geronimo/system/rmi/ system/src/java/org/apache/geronimo/system/url/ timer/src/java/org/apache/geronimo/timer/ tomcat/src/java/org/apache/geronimo/tomcat/ transaction/src/java/org/apache/geronimo/transaction/log/

Author: dain
Date: Wed Feb  2 18:49:54 2005
New Revision: 151106

URL: http://svn.apache.org/viewcvs?view=rev&rev=151106
Log:
Fixed lifecycle bug in GeronimoInstance and GeronimoInstanceState where lifecycle callback methods were being called from whithin synchronized blocks.  This could create deadlocks in the server when the lifecycle callbacks would call the lifecycle methods of other servers.
Removed use of WaitingException.  No code used this and the concept never really worked.  This also created a huge amount of complexity in the statemachine.

Removed:
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceLifecycleController.java
Modified:
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/EJBWSGBean.java
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/POJOWSGBean.java
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AbstractWebServiceTest.java
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
    geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ClockPool.java
    geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java
    geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java
    geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java
    geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/HTTPSConnector.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java
    geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycle.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycleController.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/GBeanAttribute.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/GBeanOperation.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/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/JMXGBeanRegistry.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/AbstractGBeanRegistry.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/registry/BasicGBeanRegistry.java
    geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
    geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/IMAPStoreGBean.java
    geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java
    geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/POP3StoreGBean.java
    geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/ProtocolGBean.java
    geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginService.java
    geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/POJOGBean.java
    geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/SpringGBean.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/ReadOnlyRepository.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/rmi/RMIRegistryService.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/url/GeronimoURLFactory.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/ThreadPooledTimer.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java

Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java Wed Feb  2 18:49:54 2005
@@ -23,7 +23,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
 
 /**
@@ -53,8 +52,7 @@
     /**
      * Constructor AxisGbean
      *
-     * @param name
-     @param objectName
+     * @param objectName
      */
     public AxisGbean(String objectName) {
         this.objectName = JMXUtil.getObjectName(objectName);
@@ -70,10 +68,9 @@
     /**
      * Method doStart
      *
-     * @throws WaitingException
      * @throws Exception
      */
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         log.info("Axis GBean has started");
         log.info(objectName);
     }
@@ -81,10 +78,9 @@
     /**
      * Method doStop
      *
-     * @throws WaitingException
      * @throws Exception
      */
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         log.info("Axis GBean has stoped");
     }
 

Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/EJBWSGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/EJBWSGBean.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/EJBWSGBean.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/EJBWSGBean.java Wed Feb  2 18:49:54 2005
@@ -25,7 +25,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 
 
 /**
@@ -57,9 +56,6 @@
 
     /**
      * Constructor AxisGbean
-     *
-     * @param name
-     * @param objectName
      */
     public EJBWSGBean(String objectName,Configuration ejbConfig,Collection classList) {
         this.objectName = objectName;
@@ -77,10 +73,9 @@
     /**
      * Method doStart
      *
-     * @throws WaitingException
      * @throws Exception
      */
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         log.info(objectName + "has started");
         ClassLoader cl = ejbConfig.getConfigurationClassLoader();
         for (Iterator it = classList.iterator(); it.hasNext();) {
@@ -94,10 +89,9 @@
     /**
      * Method doStop
      *
-     * @throws WaitingException
      * @throws Exception
      */
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         log.info("WebServiceGBean has stoped");
     }
 

Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/POJOWSGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/POJOWSGBean.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/POJOWSGBean.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/POJOWSGBean.java Wed Feb  2 18:49:54 2005
@@ -27,7 +27,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 
 /**
  * @version $Rev: $ $Date: $
@@ -65,7 +64,7 @@
     public void doFail() {
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         log.info("POJO WS starting");
         ClassLoader cl = new URLClassLoader(new URL[]{moduleURL});
         for (Iterator it = classList.iterator(); it.hasNext();) {
@@ -78,10 +77,9 @@
     /**
      * Method doStop
      *
-     * @throws WaitingException
      * @throws Exception
      */
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         log.info("WebServiceGBean has stoped");
     }
 

Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java Wed Feb  2 18:49:54 2005
@@ -31,7 +31,6 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
 
@@ -73,7 +72,7 @@
 
     }
     
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
     }
 
     public Object getDeploymentPlan(File planFile, JarFile jarFile) throws DeploymentException {
@@ -127,7 +126,7 @@
     
     public void doFail() {
     }
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
     }
 
     

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AbstractWebServiceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AbstractWebServiceTest.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AbstractWebServiceTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AbstractWebServiceTest.java Wed Feb  2 18:49:54 2005
@@ -18,8 +18,6 @@
 
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.net.URI;
 
 import javax.management.ObjectName;
@@ -27,7 +25,6 @@
 import org.apache.geronimo.axis.testUtils.AxisGeronimoConstants;
 import org.apache.geronimo.axis.testUtils.TestingUtils;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
@@ -54,7 +51,7 @@
     /**
      * @param testName
      */
-    public AbstractWebServiceTest(String testName) throws FileNotFoundException, WaitingException, IOException {
+    public AbstractWebServiceTest(String testName) {
         super(testName);
 
         store = AxisGeronimoConstants.STORE;

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java Wed Feb  2 18:49:54 2005
@@ -16,8 +16,6 @@
 package org.apache.geronimo.axis;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -27,7 +25,6 @@
 import org.apache.axis.utils.ClassUtils;
 import org.apache.geronimo.axis.testUtils.AxisGeronimoConstants;
 import org.apache.geronimo.axis.testUtils.TestingUtils;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
 import org.apache.geronimo.kernel.Kernel;
 
@@ -39,13 +36,7 @@
     private ObjectName axisname;
     private Kernel kernel;
 
-    /**
-     * @param testName
-     * @throws IOException
-     * @throws WaitingException
-     * @throws FileNotFoundException
-     */
-    public ComplexTypeWebServiceTest(String testName) throws FileNotFoundException, WaitingException, IOException {
+    public ComplexTypeWebServiceTest(String testName) {
         super(testName);
     }
 

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java Wed Feb  2 18:49:54 2005
@@ -17,8 +17,6 @@
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStreamReader;
 import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
@@ -26,7 +24,6 @@
 import java.net.URLClassLoader;
 
 import org.apache.geronimo.axis.testUtils.TestingUtils;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
 
 /**
@@ -35,7 +32,7 @@
  */
 public class SimpleEJBWebServiceTest extends AbstractWebServiceTest {
 
-    public SimpleEJBWebServiceTest(String testName) throws FileNotFoundException, WaitingException, IOException {
+    public SimpleEJBWebServiceTest(String testName) {
         super(testName);
     }
 

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java Wed Feb  2 18:49:54 2005
@@ -17,8 +17,6 @@
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStreamReader;
 import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
@@ -27,7 +25,6 @@
 
 import org.apache.axis.utils.ClassUtils;
 import org.apache.geronimo.axis.testUtils.TestingUtils;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
 /**
  * 
@@ -36,7 +33,7 @@
 public class SimplePOJOWebServiceTest extends AbstractWebServiceTest {
     
 
-    public SimplePOJOWebServiceTest(String testName) throws FileNotFoundException, WaitingException, IOException {
+    public SimplePOJOWebServiceTest(String testName) {
         super(testName);
     }
 

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java Wed Feb  2 18:49:54 2005
@@ -20,12 +20,9 @@
 import org.apache.axis.utils.ClassUtils;
 import org.apache.geronimo.axis.AbstractWebServiceTest;
 import org.apache.geronimo.axis.AxisGeronimoUtils;
-import org.apache.geronimo.gbean.WaitingException;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
@@ -40,7 +37,7 @@
  */
 
 public class AdminClientDeploymentTest extends AbstractWebServiceTest {
-    public AdminClientDeploymentTest(String testName) throws FileNotFoundException, WaitingException, IOException {
+    public AdminClientDeploymentTest(String testName) {
         super(testName);
     }
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java Wed Feb  2 18:49:54 2005
@@ -17,8 +17,6 @@
 
 package org.apache.geronimo.connector;
 
-import java.util.Map;
-
 import javax.resource.ResourceException;
 import javax.resource.spi.ActivationSpec;
 import javax.resource.spi.BootstrapContext;
@@ -34,7 +32,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 
 /**
@@ -105,11 +102,11 @@
         return resourceAdapter.getXAResources(specs);
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         resourceAdapter.start(bootstrapContext);
     }
 
-    public void doStop() throws WaitingException {
+    public void doStop() {
         resourceAdapter.stop();
     }
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java Wed Feb  2 18:49:54 2005
@@ -36,7 +36,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.naming.geronimo.GeronimoContextManager;
 import org.apache.geronimo.transaction.manager.NamedXAResource;
@@ -188,7 +187,7 @@
         this.connectionManagerFactory = connectionManagerFactory;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         //register with resource adapter if not yet done
         if (!registered && (managedConnectionFactory instanceof ResourceAdapterAssociation)) {
             if (resourceAdapterWrapper == null) {

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java Wed Feb  2 18:49:54 2005
@@ -33,7 +33,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.transaction.manager.LogException;
 import org.apache.geronimo.transaction.manager.Recovery;
 import org.apache.geronimo.transaction.manager.TransactionBranchInfo;
@@ -68,11 +67,11 @@
         this.dataSource = dataSource;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         dataSource = (DataSource) managedConnectionFactoryWrapper.$getResource();
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         dataSource = null;
     }
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java Wed Feb  2 18:49:54 2005
@@ -35,7 +35,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 
@@ -95,13 +94,13 @@
         this.transactionContextManager = transactionContextManager;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         syncWorkExecutorPool = syncWorkExecutorPool.start();
         startWorkExecutorPool = startWorkExecutorPool.start();
         scheduledWorkExecutorPool = scheduledWorkExecutorPool.start();
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         syncWorkExecutorPool = syncWorkExecutorPool.stop();
         startWorkExecutorPool = startWorkExecutorPool.stop();
         scheduledWorkExecutorPool = scheduledWorkExecutorPool.stop();

Modified: geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ClockPool.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ClockPool.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ClockPool.java (original)
+++ geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ClockPool.java Wed Feb  2 18:49:54 2005
@@ -24,8 +24,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
-
 
 /**
  * @version $Rev$ $Date$
@@ -50,14 +48,11 @@
         this.poolName = poolName;
     }
 
-    /**
-     * @return
-     */
     public ClockDaemon getClockDaemon() {
         return clockDaemon;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         clockDaemon = new ClockDaemon();
         clockDaemon.setThreadFactory(new ThreadFactory() {
             public Thread newThread(Runnable r) {
@@ -69,7 +64,7 @@
         log.info("Clock pool " + poolName + " started");
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         clockDaemon.shutDown();
         log.info("Clock pool " + poolName + " stopped");
     }

Modified: geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java (original)
+++ geronimo/trunk/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java Wed Feb  2 18:49:54 2005
@@ -24,8 +24,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
-
 
 /**
  * @version $Rev$ $Date$
@@ -60,10 +58,10 @@
         return nextWorkerID++;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         executor.shutdownNow();
     }
 

Modified: geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java (original)
+++ geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java Wed Feb  2 18:49:54 2005
@@ -24,7 +24,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 
 /**
  * A GBean that manages remote network access to the embedded Derby server.
@@ -58,14 +57,14 @@
         this.port = port;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         InetAddress address = InetAddress.getByName(host);
         network = new NetworkServerControl(address, port);
         network.start(null); // todo work out how to add this to our log stream
         log.info("Started on host " + host + ':' + port);
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         if (network != null) {
             try {
                 network.shutdown();

Modified: geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java (original)
+++ geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java Wed Feb  2 18:49:54 2005
@@ -25,7 +25,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 
 /**
@@ -47,7 +46,7 @@
         this.systemHome = derbySystemHome;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         // set up the system property for the database home
         String actualHome = System.getProperty(SYSTEM_HOME);
         if (actualHome == null) {
@@ -64,7 +63,7 @@
         log.info("Started in " + actualHome);
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         try {
             DriverManager.getConnection(SHUTDOWN_ALL, null, null);
         } catch (SQLException e) {

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java Wed Feb  2 18:49:54 2005
@@ -25,7 +25,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.interop.IOP.IOR;
 
 
@@ -105,11 +104,11 @@
      * Interface :: GBeanLifecycle
      */
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         log.info("Started " + getObjectName());
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         log.info("Stopped " + getObjectName());
     }
 

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java Wed Feb  2 18:49:54 2005
@@ -26,7 +26,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 
 /**
  * @version $Rev$ $Date$
@@ -139,11 +138,11 @@
         return server.getRequestLog();
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         server.start();
     }
 
-    public void doStop() throws WaitingException {
+    public void doStop() {
         try {
             server.stop(true);
         } catch (InterruptedException e) {

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java Wed Feb  2 18:49:54 2005
@@ -45,7 +45,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.jetty.interceptor.BeforeAfter;
 import org.apache.geronimo.jetty.interceptor.ComponentContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.InstanceContextBeforeAfter;
@@ -232,7 +231,7 @@
         chain.after(context, httpRequest, httpResponse);
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         // reset the classsloader... jetty likes to set it to null when stopping
         setClassLoader(webClassLoader);
 

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/HTTPSConnector.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/HTTPSConnector.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/HTTPSConnector.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/HTTPSConnector.java Wed Feb  2 18:49:54 2005
@@ -19,7 +19,6 @@
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.jetty.JettyContainer;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.mortbay.http.SunJsseListener;
@@ -94,7 +93,7 @@
         return https.getNeedClientAuth();
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         https.setKeystore(serverInfo.resolvePath(keystore));
         super.doStart();
     }

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java Wed Feb  2 18:49:54 2005
@@ -20,7 +20,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.jetty.JettyContainer;
 import org.mortbay.http.HttpListener;
 import org.mortbay.util.ThreadedServer;
@@ -50,13 +49,13 @@
         listener.setPort(port);
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         container.addListener(listener);
         ((ThreadedServer) listener).open();
         listener.start();
     }
 
-    public void doStop() throws WaitingException {
+    public void doStop() {
         while (true) {
             try {
                 listener.stop();

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java Wed Feb  2 18:49:54 2005
@@ -19,7 +19,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
 import org.apache.geronimo.jetty.JettyContainer;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 
@@ -112,13 +111,13 @@
         return preferProxiedForAddress;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         requestLog.setFilename(serverInfo.resolvePath(filename));
         container.setRequestLog(requestLog);
         requestLog.start();
     }
 
-    public void doStop() throws WaitingException, Exception {
+    public void doStop() throws Exception {
         requestLog.stop();
         container.setRequestLog(null);
     }

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&r1=151105&r2=151106
==============================================================================
--- 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 Wed Feb  2 18:49:54 2005
@@ -28,7 +28,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 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;
 
@@ -100,7 +99,7 @@
         this.url = url;
     }
 
-    public void doStart() throws WaitingException, Exception {
+    public void doStart() throws Exception {
         JMXServiceURL serviceURL = new JMXServiceURL(url);
         Map env = new HashMap();
         if (applicationConfigName != null) {

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycle.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycle.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycle.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycle.java Wed Feb  2 18:49:54 2005
@@ -28,17 +28,16 @@
     /**
      * Starts the GBean.  This informs the GBean that it is about to transition to the running state.
      *
-     * @throws WaitingException if the target is waiting for an external condition before it can fully start
      * @throws Exception if the target failed to start; this will cause a transition to the failed state
      */
-    void doStart() throws WaitingException, Exception;
+    void doStart() throws Exception;
 
     /**
      * Stops the target.  This informs the GBean that it is about to transition to the stopped state.
      *
-     * @throws WaitingException if the target is waiting for an external condition before it can fully stop
+     * @throws Exception if the target failed to stop; this will cause a transition to the failed state
      */
-    void doStop() throws WaitingException, Exception;
+    void doStop() throws Exception;
 
     /**
      * Fails the GBean.  This informs the GBean that it is about to transition to the failed state.

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycleController.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycleController.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycleController.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycleController.java Wed Feb  2 18:49:54 2005
@@ -33,16 +33,6 @@
     int getState();
 
     /**
-     * Attempts to bring the component into the fully running state. If an Exception occurs while
-     * starting the component, the component is automaticaly failed.
-     * <p/>
-     * There is no guarantee that the Geronimo MBean will be running when the method returns.
-     *
-     * @throws Exception if a problem occurs while starting the component
-     */
-    void start() throws Exception;
-
-    /**
      * Attempt to bring the component into the fully stopped state. If an exception occurs while
      * stopping the component, tthe component is automaticaly failed.
      * <p/>
@@ -51,11 +41,4 @@
      * @throws Exception if a problem occurs while stopping the component
      */
     void stop() throws Exception;
-
-    /**
-     * Moves this component to the FAILED state.
-     * <p/>
-     * The component is guaranteed to be in the failed state when the method returns.
-     */
-    void fail();
 }

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&r1=151105&r2=151106
==============================================================================
--- 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 Wed Feb  2 18:49:54 2005
@@ -138,44 +138,20 @@
             setInvoker = null;
         }
 
-        listener = new LifecycleAdapter() {
-            public void running(ObjectName objectName) {
-                if (!targets.contains(objectName)) {
-                    targets.add(objectName);
-                    targetAdded(objectName);
-                }
-            }
-
-            public void stopping(ObjectName objectName) {
-                removeTarget(objectName);
-            }
-
-            public void stopped(ObjectName objectName) {
-                removeTarget(objectName);
-            }
+        listener = createLifecycleListener();
+    }
 
-            public void failed(ObjectName objectName) {
-                removeTarget(objectName);
-            }
+    protected abstract LifecycleListener createLifecycleListener();
 
-            public void unloaded(ObjectName objectName) {
-                removeTarget(objectName);
-            }
+    protected abstract void targetAdded(ObjectName target);
 
-            private void removeTarget(ObjectName objectName) {
-                boolean wasTarget = targets.remove(objectName);
-                if (wasTarget) {
-                    targetRemoved(objectName);
-                }
-            }
-        };
-    }
+    protected abstract void targetRemoved(ObjectName target);
 
     protected final Kernel getKernel() {
         return kernel;
     }
 
-    protected DependencyManager getDependencyManager() {
+    protected final DependencyManager getDependencyManager() {
         return dependencyManager;
     }
 
@@ -199,11 +175,11 @@
         return proxyType;
     }
 
-    public Object getProxy() {
+    public final Object getProxy() {
         return proxy;
     }
 
-    protected void setProxy(Object proxy) {
+    protected final void setProxy(Object proxy) {
         this.proxy = proxy;
     }
 
@@ -258,18 +234,28 @@
         isOnline = false;
     }
 
-    protected abstract void targetAdded(ObjectName target);
-
-    protected abstract void targetRemoved(ObjectName target);
-
     protected final Set getTargets() {
         return targets;
     }
 
-    public final synchronized void inject() throws Exception {
+    protected final void addTarget(ObjectName objectName) {
+        if (!targets.contains(objectName)) {
+            targets.add(objectName);
+            targetAdded(objectName);
+        }
+    }
+
+    protected final void removeTarget(ObjectName objectName) {
+        boolean wasTarget = targets.remove(objectName);
+        if (wasTarget) {
+            targetRemoved(objectName);
+        }
+    }
+
+    public final synchronized void inject(Object target) throws Exception {
         // set the proxy into the instance
         if (setInvoker != null && patterns.size() > 0) {
-            setInvoker.invoke(gbeanInstance.getTarget(), new Object[]{getProxy()});
+            setInvoker.invoke(target, new Object[]{getProxy()});
         }
     }
 

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java?view=diff&r1=151105&r2=151106
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java Wed Feb  2 18:49:54 2005
@@ -313,9 +313,9 @@
         return special;
     }
 
-    public void inject() throws Exception {
+    public void inject(Object target) throws Exception {
         if ((persistent || special) && !isConstructorArg && writable) {
-            setValue(persistentValue);
+            setValue(target, persistentValue);
         }
     }
 
@@ -339,7 +339,7 @@
         this.persistentValue = persistentValue;
     }
 
-    public Object getValue() throws Exception {
+    public Object getValue(Object target) throws Exception {
         if (!readable) {
             if (persistent) {
                 throw new IllegalStateException("This persistent attribute is not accessible while started. " + getDescription());
@@ -353,9 +353,8 @@
         }
 
         // get the target to invoke
-        Object target = gbeanInstance.getTarget();
         if (target == null && !framework) {
-            throw new IllegalStateException("GBeanMBean does not have a target instance to invoke. " + getDescription());
+            throw new IllegalStateException("GBean does not have a target instance to invoke. " + getDescription());
         }
 
         // call the getter
@@ -363,7 +362,7 @@
         return value;
     }
 
-    public void setValue(Object value) throws Exception {
+    public void setValue(Object target, Object value) throws Exception {
         if (!writable) {
             if (persistent) {
                 throw new IllegalStateException("This persistent attribute is not modifable while running. " + getDescription());
@@ -380,9 +379,8 @@
         // @todo actually check type
 
         // get the target to invoke
-        Object target = gbeanInstance.getTarget();
         if (target == null && !framework) {
-            throw new IllegalStateException("GBeanMBean does not have a target instance to invoke. " + getDescription());
+            throw new IllegalStateException("GBean does not have a target instance to invoke. " + getDescription());
         }
 
         // call the setter

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&r1=151105&r2=151106
==============================================================================
--- 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 Wed Feb  2 18:49:54 2005
@@ -23,6 +23,8 @@
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 
 /**
  * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
@@ -32,19 +34,13 @@
         super(gbeanInstance, referenceInfo, kernel, dependencyManager);
     }
 
-    public synchronized void start() throws Exception {
-        // if there are no patterns then there is nothing to start
-        if (getPatterns().isEmpty()) {
-            return;
+    public synchronized boolean start() {
+        // We only need to start if there are patterns and we don't already have a proxy
+        if (!getPatterns().isEmpty() && getProxy() == null) {
+            // add a dependency on our target and create the proxy
+            setProxy(new ProxyCollection(getName(), getReferenceType(), getKernel().getProxyManager(), getTargets()));
         }
-
-        // if we already have a proxy then we have already been started
-        if (getProxy() != null) {
-            return;
-        }
-
-        // add a dependency on our target and create the proxy
-        setProxy(new ProxyCollection(getName(), getReferenceType(), getKernel().getProxyManager(), getTargets()));
+        return true;
     }
 
     public synchronized void stop() {
@@ -55,17 +51,41 @@
         }
     }
 
-    public synchronized void targetAdded(ObjectName target) {
+    protected synchronized void targetAdded(ObjectName target) {
         ProxyCollection proxy = (ProxyCollection) getProxy();
         if (proxy != null) {
             proxy.addTarget(target);
         }
     }
 
-    public synchronized void targetRemoved(ObjectName target) {
+    protected synchronized void targetRemoved(ObjectName target) {
         ProxyCollection proxy = (ProxyCollection) getProxy();
         if (proxy != null) {
             proxy.removeTarget(target);
         }
+    }
+
+    protected LifecycleListener createLifecycleListener() {
+        return new LifecycleAdapter() {
+                    public void running(ObjectName objectName) {
+                        addTarget(objectName);
+                    }
+
+                    public void stopping(ObjectName objectName) {
+                        removeTarget(objectName);
+                    }
+
+                    public void stopped(ObjectName objectName) {
+                        removeTarget(objectName);
+                    }
+
+                    public void failed(ObjectName objectName) {
+                        removeTarget(objectName);
+                    }
+
+                    public void unloaded(ObjectName objectName) {
+                        removeTarget(objectName);
+                    }
+                };
     }
 }

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&r1=151105&r2=151106
==============================================================================
--- 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 Wed Feb  2 18:49:54 2005
@@ -41,11 +41,11 @@
 import org.apache.geronimo.gbean.GOperationSignature;
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.kernel.DependencyManager;
 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.GBeanNotFoundException;
 import org.apache.geronimo.kernel.management.EventProvider;
 import org.apache.geronimo.kernel.management.ManagedObject;
 import org.apache.geronimo.kernel.management.NotificationType;
@@ -60,10 +60,12 @@
 public final class GBeanInstance implements ManagedObject, StateManageable, EventProvider {
     private static final Log log = LogFactory.getLog(GBeanInstance.class);
 
-    /**
-     * Attribute name used to retrieve the RawInvoker for the GBean
-     * @deprecated DO NOT USE THIS... THIS WILL BE REMOVED!!!!!!
-     */
+    private static final int DESTROYED = 0;
+    private static final int CREATING = 1;
+    private static final int RUNNING = 2;
+    private static final int DESTROYING = 3;
+
+    /** Attribute name used to retrieve the RawInvoker for the GBean */
     public static final String RAW_INVOKER = "$$RAW_INVOKER$$";
 
     /**
@@ -154,12 +156,12 @@
     /**
      * Has this instance been destroyed?
      */
-    private boolean destroyed = true;
+    private boolean dead = false;
 
     /**
-     * Is this gbean running?
+     * The state of the internal gbean instance that we are wrapping.
      */
-    private boolean running = false;
+    private int instanceState = DESTROYED;
 
     /**
      * Target instance of this GBean wrapper
@@ -176,6 +178,12 @@
      */
     private boolean enabled = true;
 
+    /**
+     * This is used to signal the creating thread that it should
+     * fail when it returns from usercode.  This is set when a
+     * reference has gone offline during construction.
+     */
+    private boolean shouldFail = false; 
 
     /**
      * Construct a GBeanMBean using the supplied GBeanData and class loader
@@ -189,7 +197,7 @@
         this.objectName = gbeanData.getName();
         this.kernel = kernel;
         this.lifecycleBroadcaster = lifecycleBroadcaster;
-        this.gbeanInstanceState = new GBeanInstanceState(objectName, kernel, dependencyManager, new GBeanLifecycleCallback(), lifecycleBroadcaster);
+        this.gbeanInstanceState = new GBeanInstanceState(objectName, kernel, dependencyManager, this, lifecycleBroadcaster);
         this.classLoader = classLoader;
         gbeanLifecycleController = new GBeanInstanceLifecycleController(this);
 
@@ -248,7 +256,7 @@
         operations = new GBeanOperation[operationsMap.size()];
         int opCounter = 0;
         for (Iterator iterator = operationsMap.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry)iterator.next();
+            Map.Entry entry = (Map.Entry) iterator.next();
             operations[opCounter] = (GBeanOperation) entry.getValue();
             operationIndex.put(entry.getKey(), new Integer(opCounter));
             opCounter++;
@@ -284,7 +292,23 @@
 
         // set the initial attribute values
         try {
-            setGBeanData(gbeanData);
+            // set the attributes
+            Map dataAttributes = gbeanData.getAttributes();
+            for (Iterator iterator = dataAttributes.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                String attributeName = (String) entry.getKey();
+                Object attributeValue = entry.getValue();
+                setAttribute(attributeName, attributeValue);
+            }
+
+            // add the references
+            Map dataReferences = gbeanData.getReferences();
+            for (Iterator iterator = dataReferences.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                String referenceName = (String) entry.getKey();
+                Set referencePattern = (Set) entry.getValue();
+                getReferenceByName(referenceName).setPatterns(referencePattern);
+            }
         } catch (Exception e) {
             throw new InvalidConfigurationException("GBeanData could not be loaded into the GBeanMBean", e);
         }
@@ -295,22 +319,20 @@
         lifecycleBroadcaster.fireLoadedEvent();
     }
 
-    public void destroy() {
+    public void die() throws GBeanNotFoundException {
         synchronized (this) {
-            if (destroyed) {
-                return;
+            if (dead) {
+                // someone beat us to the punch... this instance should have never been found in the first place
+                throw new GBeanNotFoundException(name);
             }
-            destroyed = true;
+            dead = true;
         }
 
-        lifecycleBroadcaster.fireUnloadedEvent();
-
-        // just to be sure, stop all the references again
-        for (int i = 0; i < references.length; i++) {
-            references[i].offline();
-        }
+        // if the bean is already stopped or failed, this will do nothing; otherwise it will shutdown the bean
+        gbeanInstanceState.fail();
 
-        target = null;
+        // tell everyone we are done
+        lifecycleBroadcaster.fireUnloadedEvent();
     }
 
     /**
@@ -337,17 +359,8 @@
      *
      * @return true if the gbean has been destroyed
      */
-    public synchronized boolean isDestroyed() {
-        return destroyed;
-    }
-
-    /**
-     * Is this gbean instance running. Operations and non-persistenct attribtes can not be accessed while not running.
-     *
-     * @return true if the gbean is runing
-     */
-    public boolean isRunning() {
-        return running;
+    public synchronized boolean isDead() {
+        return dead;
     }
 
     /**
@@ -359,7 +372,7 @@
         return type;
     }
 
-    public Object getTarget() {
+    public synchronized Object getTarget() {
         return target;
     }
 
@@ -405,7 +418,7 @@
         return NotificationType.TYPES;
     }
 
-    public final long getStartTime() {
+    public synchronized final long getStartTime() {
         return startTime;
     }
 
@@ -454,6 +467,9 @@
      */
     public final void start() {
         synchronized (this) {
+            if (dead) {
+                throw new IllegalStateException("A dead GBean can not be started: objectName=" + objectName);
+            }
             if (!enabled) {
                 throw new IllegalStateException("A disabled GBean can not be started: objectName=" + objectName);
             }
@@ -468,6 +484,9 @@
      */
     public final void startRecursive() {
         synchronized (this) {
+            if (dead) {
+                throw new IllegalStateException("A dead GBean can not be started: objectName=" + objectName);
+            }
             if (!enabled) {
                 throw new IllegalStateException("A disabled GBean can not be started: objectName=" + objectName);
             }
@@ -487,26 +506,35 @@
      * Moves this GBeanInstance to the FAILED state.  There are no calls to dependent children, but they will be
      * notified using standard J2EE management notification.
      */
-    final void fail() {
+    final void referenceFailed() {
         gbeanInstanceState.fail();
     }
 
     /**
      * Gets the gbean data for the gbean held by this gbean mbean.
+     *
      * @return the gbean data
      */
     public GBeanData getGBeanData() {
         GBeanData gbeanData = new GBeanData(objectName, gbeanInfo);
 
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
+
         // add the attributes
         for (int i = 0; i < attributes.length; i++) {
             GBeanAttribute attribute = attributes[i];
             if (attribute.isPersistent()) {
                 String name = attribute.getName();
                 Object value;
-                if ((running || attribute.isFramework()) && attribute.isReadable()) {
+                if ((state != DESTROYED || attribute.isFramework()) && attribute.isReadable()) {
                     try {
-                        value = attribute.getValue();
+                        value = attribute.getValue(instance);
                     } catch (Throwable throwable) {
                         value = attribute.getPersistentValue();
                         log.debug("Could not get the current value of persistent attribute.  The persistent " +
@@ -529,26 +557,6 @@
         return gbeanData;
     }
 
-    public void setGBeanData(GBeanData gbeanData) throws Exception, NoSuchAttributeException {
-        // set the attributes
-        Map attributes = gbeanData.getAttributes();
-        for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
-            Object value = entry.getValue();
-            setAttribute(name, value);
-        }
-
-        // add the references
-        Map references = gbeanData.getReferences();
-        for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
-            Set patterns = (Set) entry.getValue();
-            setReferencePatterns(name, patterns);
-        }
-    }
-
     /**
      * Gets the attribute value using the attribute index.  This is the most efficient way to get
      * an attribute as it avoids a HashMap lookup.
@@ -560,8 +568,17 @@
      */
     public Object getAttribute(int index) throws Exception {
         GBeanAttribute attribute = attributes[index];
-        if (running || attribute.isFramework()) {
-            return attribute.getValue();
+
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
+
+        if (state != DESTROYED || attribute.isFramework()) {
+            return attribute.getValue(instance);
         } else {
             return attribute.getPersistentValue();
         }
@@ -587,8 +604,16 @@
             throw e;
         }
 
-        if (running || attribute.isFramework()) {
-            return attribute.getValue();
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
+
+        if (state != DESTROYED || attribute.isFramework()) {
+            return attribute.getValue(instance);
         } else {
             return attribute.getPersistentValue();
         }
@@ -605,8 +630,17 @@
      */
     public void setAttribute(int index, Object value) throws Exception, IndexOutOfBoundsException {
         GBeanAttribute attribute = attributes[index];
-        if (running || attribute.isFramework()) {
-            attribute.setValue(value);
+
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
+
+        if (state != DESTROYED || attribute.isFramework()) {
+            attribute.setValue(instance, value);
         } else {
             attribute.setPersistentValue(value);
         }
@@ -623,8 +657,17 @@
      */
     public void setAttribute(String attributeName, Object value) throws Exception, NoSuchAttributeException {
         GBeanAttribute attribute = getAttributeByName(attributeName);
-        if (running || attribute.isFramework()) {
-            attribute.setValue(value);
+
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
+
+        if (state != DESTROYED || attribute.isFramework()) {
+            attribute.setValue(instance, value);
         } else {
             attribute.setPersistentValue(value);
         }
@@ -652,10 +695,19 @@
      */
     public Object invoke(int index, Object[] arguments) throws Exception {
         GBeanOperation operation = operations[index];
-        if (!running && !operation.isFramework()) {
+
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
+
+        if (state == DESTROYED && !operation.isFramework()) {
             throw new IllegalStateException("Operations can only be invoke while the GBean instance is running: " + objectName);
         }
-        return operation.invoke(arguments);
+        return operation.invoke(instance, arguments);
     }
 
     /**
@@ -678,40 +730,19 @@
             throw new NoSuchOperationException("Unknown operation " + signature);
         }
         GBeanOperation operation = operations[index.intValue()];
-        if (!running && !operation.isFramework()) {
-            throw new IllegalStateException("Operations can only be invoke while the GBean is running: " + objectName);
-        }
-        return operation.invoke(arguments);
-    }
 
-    /**
-     * Gets the object name patters for a reference.
-     *
-     * @param name the reference name
-     * @return the object name patterns for the reference
-     */
-    public Set getReferencePatterns(String name) {
-        return getReferenceByName(name).getPatterns();
-    }
-
-    /**
-     * 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
-     */
-    public void setReferencePattern(String name, ObjectName pattern) {
-        getReferenceByName(name).setPatterns(Collections.singleton(pattern));
-    }
+        // copy target into local variables from within a synchronized block to gaurentee a consistent read
+        int state;
+        Object instance;
+        synchronized (this) {
+            state = instanceState;
+            instance = target;
+        }
 
-    /**
-     * Sets the object name patterns for a reference.
-     *
-     * @param name the reference name
-     * @param patterns the new object name patterns for the reference
-     */
-    public void setReferencePatterns(String name, Set patterns) {
-        getReferenceByName(name).setPatterns(patterns);
+        if (state == DESTROYED && !operation.isFramework()) {
+            throw new IllegalStateException("Operations can only be invoke while the GBean is running: " + objectName);
+        }
+        return operation.invoke(instance, arguments);
     }
 
     private GBeanReference getReferenceByName(String name) {
@@ -723,23 +754,35 @@
         return reference;
     }
 
-    private class GBeanLifecycleCallback implements GBeanLifecycle {
-        public void doStart() throws Exception {
-            // start each of the references... if they need to wait remember the
-            // waiting exception so we can throw it later. this way we the dependecies
-            // are held until we can start
-            WaitingException waitingException = null;
+    boolean createInstance() throws Exception {
+        synchronized (this) {
+            // first check we are still in the correct state to start
+            if (instanceState == CREATING || instanceState == RUNNING) {
+                // another thread already completed starting
+                return false;
+            } else if (instanceState == DESTROYING) {
+                // this should never ever happen... this method is protected by the GBeanState class which should
+                // prevent stuff like this happening, but check anyway
+                throw new IllegalStateException("A stopping instance can not be started until fully stopped");
+            }
+            assert instanceState == DESTROYED;
+
+            // Call all start on every reference.  This way the dependecies are held until we can start
+            boolean allStarted = true;
             for (int i = 0; i < references.length; i++) {
-                try {
-                    references[i].start();
-                } catch (WaitingException e) {
-                    waitingException = e;
-                }
+                allStarted = references[i].start() && allStarted;
             }
-            if (waitingException != null) {
-                throw waitingException;
+            if (!allStarted) {
+                return false;
             }
 
+            // we are definately going to (try to) start... if this fails the must clean up these variables
+            instanceState = CREATING;
+            startTime = System.currentTimeMillis();
+        }
+
+        Object instance = null;
+        try {
             GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
             Class[] parameterTypes = constructor.getParameterTypes();
 
@@ -760,7 +803,7 @@
 
             // create instance
             try {
-                target = constructor.newInstance(parameters);
+                instance = constructor.newInstance(parameters);
             } catch (InvocationTargetException e) {
                 Throwable targetException = e.getTargetException();
                 if (targetException instanceof Exception) {
@@ -774,67 +817,191 @@
                 throw e;
             }
 
+            // write the target variable in a synchronized block so it is available to all threads
+            // we do this before calling the setters or start method so the bean can be called back
+            // from a setter start method
+            synchronized (this) {
+                target = instance;
+            }
+
             // inject the persistent attribute value into the new instance
             for (int i = 0; i < attributes.length; i++) {
-                attributes[i].inject();
+                checkIfShouldFail();
+                attributes[i].inject(instance);
             }
 
             // inject the proxies into the new instance
             for (int i = 0; i < references.length; i++) {
-                references[i].inject();
+                checkIfShouldFail();
+                references[i].inject(instance);
             }
 
-            running = true;
-            startTime = System.currentTimeMillis();
-            if (target instanceof GBeanLifecycle) {
-                ((GBeanLifecycle) target).doStart();
+            if (instance instanceof GBeanLifecycle) {
+                checkIfShouldFail();
+                ((GBeanLifecycle) instance).doStart();
+            }
+
+            // all done... we are now fully running
+            synchronized (this) {
+                checkIfShouldFail();
+                instanceState = RUNNING;
+                this.notifyAll();
+            }
+
+            return true;
+        } catch (Throwable t) {
+            // something went wrong... we need to destroy this instance
+            synchronized (this) {
+                instanceState = DESTROYING;
+            }
+
+            if (instance instanceof GBeanLifecycle) {
+                try {
+                    ((GBeanLifecycle) instance).doFail();
+                } catch (Throwable ignored) {
+                    log.error("Problem in doFail of " + objectName, ignored);
+                }
+            }
+
+            // bean has been notified... drop our reference
+            synchronized (this) {
+                // stop all of the references
+                for (int i = 0; i < references.length; i++) {
+                    references[i].stop();
+                }
+
+                target = null;
+                instanceState = DESTROYED;
+                startTime = 0;
+                this.notifyAll();
             }
+
+            if (t instanceof Exception) {
+                throw (Exception) t;
+            } else if (t instanceof Error) {
+                throw (Error) t;
+            } else {
+                throw new Error(t);
+            }
+        }
+    }
+
+    private synchronized void checkIfShouldFail() throws Exception {
+        if (shouldFail) {
+            shouldFail = false;
+            throw new Exception("A reference has failed so construction can not complete");
         }
+    }
 
-        public void doStop() throws Exception {
-            if (target instanceof GBeanLifecycle) {
-                ((GBeanLifecycle) target).doStop();
+    boolean destroyInstance(boolean stop) throws Exception {
+        Object instance;
+        synchronized (this) {
+            if (!stop && instanceState == CREATING) {
+                // signal to the creating thead that it should fail
+                shouldFail = true;
+                return false;
             }
 
-            running = false;
+            // if the instance is being created we need to wait
+            //  for it to finish before we can try to stop it
+            while (instanceState == CREATING) {
+                // todo should we limit this wait?  If so, how do we configure the wait time?
+                try {
+                    this.wait();
+                } catch (InterruptedException e) {
+                    // clear the interrupted flag
+                    Thread.interrupted();
+                    // rethrow the interrupted exception.... someone was sick of us waiting
+                    throw e;
+                }
+            }
 
-            // stop all of the references
-            for (int i = 0; i < references.length; i++) {
-                references[i].stop();
+            if (instanceState == DESTROYING || instanceState == DESTROYED) {
+                // another thread is already stopping or has already stopped
+                return false;
             }
+            assert instanceState == RUNNING;
+
+            // we are definately going to stop... if this fails the must clean up these variables
+            instanceState = DESTROYING;
+            instance = target;
+        }
 
-            if (target != null) {
-                // stop all of the attributes
+        // update the persistent attributes
+        // do not update the persistent attibute values in the case of a failure
+        // failed gbeans may have corrupted attributes that would be persisted
+        Exception problem = null;
+        if (stop && instance != null) {
+            try {
+                // get all the data but don't update in case there is an exception
+                Map data = new HashMap();
                 for (int i = 0; i < attributes.length; i++) {
                     GBeanAttribute attribute = attributes[i];
                     if (attribute.isPersistent() && attribute.isReadable()) {
                         // copy the current attribute value to the persistent value
-                        Object value = attribute.getValue();
+                        Object value = null;
+                        try {
+                            value = attribute.getValue(instance);
+                        } catch (Throwable e) {
+                            // There is no reason to create a new Exception sub class as this exception will
+                            // simply be caught and logged on GBeanInstanceState
+                            throw new Exception("Problem while updaing the persistent value of attibute: " +
+                                    "Attribute Name: " + attribute.getName() + ", " +
+                                    "Type: " + attribute.getType() + ", " +
+                                    "GBeanInstance: " + getName(), e);
+                        }
+                        data.put(attribute, value);
+                    }
+                }
+                // now we have all the data we can update the persistent values
+                for (int i = 0; i < attributes.length; i++) {
+                    GBeanAttribute attribute = attributes[i];
+                    if (attribute.isPersistent() && attribute.isReadable()) {
+                        // copy the current attribute value to the persistent value
+                        Object value = data.get(attribute);
                         attribute.setPersistentValue(value);
                     }
                 }
-
-                target = null;
+            } catch (Exception e) {
+                // the getter threw an exception; now we must to fail
+                stop = false;
+                problem = e;
             }
         }
 
-        public void doFail() {
-            running = false;
-
-            if (target instanceof GBeanLifecycle) {
-                ((GBeanLifecycle) target).doFail();
+        // we notify the bean before removing our reference so the bean can be called back while stopping
+        if (instance instanceof GBeanLifecycle) {
+            if (stop) {
+                try {
+                    ((GBeanLifecycle) instance).doStop();
+                } catch (Throwable ignored) {
+                    log.error("Problem in doStop of " + objectName, ignored);
+                }
+            } else {
+                try {
+                    ((GBeanLifecycle) instance).doFail();
+                } catch (Throwable ignored) {
+                    log.error("Problem in doFail of " + objectName, ignored);
+                }
             }
+        }
 
+        // bean has been notified... drop our reference
+        synchronized (this) {
             // stop all of the references
             for (int i = 0; i < references.length; i++) {
                 references[i].stop();
             }
 
             target = null;
+            instanceState = DESTROYED;
+            startTime = 0;
+        }
 
-            // do not stop the attibutes in the case of a failure
-            // failed gbeans may have corrupted attributes that would be persisted
+        if (problem != null) {
+            throw problem;
         }
+        return true;
     }
 
     private void addManagedObjectAttributes(Map attributesMap) {
@@ -963,36 +1130,36 @@
     private void addManagedObjectOperations(Map operationsMap) {
         operationsMap.put(new GOperationSignature("start", Collections.EMPTY_LIST),
                 GBeanOperation.createFrameworkOperation(this,
-                "start",
-                Collections.EMPTY_LIST,
-                new MethodInvoker() {
-                    public Object invoke(Object target, Object[] arguments) throws Exception {
-                        start();
-                        return null;
-                    }
-                }));
+                        "start",
+                        Collections.EMPTY_LIST,
+                        new MethodInvoker() {
+                            public Object invoke(Object target, Object[] arguments) throws Exception {
+                                start();
+                                return null;
+                            }
+                        }));
 
         operationsMap.put(new GOperationSignature("startRecursive", Collections.EMPTY_LIST),
                 GBeanOperation.createFrameworkOperation(this,
-                "startRecursive",
-                Collections.EMPTY_LIST,
-                new MethodInvoker() {
-                    public Object invoke(Object target, Object[] arguments) throws Exception {
-                        startRecursive();
-                        return null;
-                    }
-                }));
+                        "startRecursive",
+                        Collections.EMPTY_LIST,
+                        new MethodInvoker() {
+                            public Object invoke(Object target, Object[] arguments) throws Exception {
+                                startRecursive();
+                                return null;
+                            }
+                        }));
 
         operationsMap.put(new GOperationSignature("stop", Collections.EMPTY_LIST),
                 GBeanOperation.createFrameworkOperation(this,
-                "stop",
-                Collections.EMPTY_LIST,
-                new MethodInvoker() {
-                    public Object invoke(Object target, Object[] arguments) throws Exception {
-                        stop();
-                        return null;
-                    }
-                }));
+                        "stop",
+                        Collections.EMPTY_LIST,
+                        new MethodInvoker() {
+                            public Object invoke(Object target, Object[] arguments) throws Exception {
+                                stop();
+                                return null;
+                            }
+                        }));
     }
 
     private GBeanInfo rebuildGBeanInfo(GConstructorInfo constructor, String j2eeType) {
@@ -1018,6 +1185,56 @@
                 constructor,
                 operationInfos,
                 referenceInfos);
+    }
+
+    public static final class GBeanInstanceLifecycleController implements GBeanLifecycleController {
+        /**
+         * The GeronimoInstance which owns the target.
+         */
+        private final GBeanInstance gbeanInstance;
+
+        /**
+         * Creates a new context for a target.
+         *
+         * @param gbeanInstance the GeronimoInstance
+         */
+        public GBeanInstanceLifecycleController(GBeanInstance gbeanInstance) {
+            this.gbeanInstance = gbeanInstance;
+        }
+
+        /**
+         * Gets the state of this component as an int.
+         * The int return is required by the JSR77 specification.
+         *
+         * @return the current state of this component
+         */
+        public int getState() {
+            return gbeanInstance.getState();
+        }
+
+        /**
+         * Attempt to bring the component into the fully stopped state. If an exception occurs while
+         * stopping the component, tthe component is automaticaly failed.
+         * <p/>
+         * There is no guarantee that the Geronimo MBean will be stopped when the method returns.
+         *
+         * @throws Exception if a problem occurs while stopping the component
+         */
+        public void stop() throws Exception {
+            synchronized(gbeanInstance) {
+                if (gbeanInstance.instanceState == CREATING) {
+                    throw new IllegalStateException("Stop can not be called until instance is fully started");
+                } else if (gbeanInstance.instanceState == DESTROYING) {
+                    log.debug("Stop ignored.  GBean is already being stopped");
+                    return;
+                } else if (gbeanInstance.instanceState == DESTROYED) {
+                    log.debug("Stop ignored.  GBean is already stopped");
+                    return;
+                }
+            }
+            gbeanInstance.stop();
+        }
+
     }
 
     public String toString() {