geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/plan DestroyMBeanInstance.java
Date Mon, 18 Aug 2003 22:05:55 GMT
dain        2003/08/18 15:05:55

  Modified:    modules/core/src/java/org/apache/geronimo/deployment/plan
                        DestroyMBeanInstance.java
  Log:
  Moved stop call to the StopMBeanInstance class.
  
  DestroyMBeanInstance can not only run if all of the dependent MBean have stopped.
  
  Revision  Changes    Path
  1.3       +18 -32    incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/plan/DestroyMBeanInstance.java
  
  Index: DestroyMBeanInstance.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/plan/DestroyMBeanInstance.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DestroyMBeanInstance.java	14 Aug 2003 00:02:38 -0000	1.2
  +++ DestroyMBeanInstance.java	18 Aug 2003 22:05:55 -0000	1.3
  @@ -55,15 +55,15 @@
    */
   package org.apache.geronimo.deployment.plan;
   
  +import javax.management.AttributeNotFoundException;
   import javax.management.InstanceNotFoundException;
  -import javax.management.MBeanException;
   import javax.management.MBeanRegistrationException;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  -import javax.management.ReflectionException;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.geronimo.common.State;
   import org.apache.geronimo.deployment.DeploymentException;
   
   /**
  @@ -82,40 +82,26 @@
       }
   
       public boolean canRun() throws DeploymentException {
  -        return true;
  -    }
  -
  -    public void perform() {
           try {
  -            server.invoke(name, "stop", null, null);
  -        } catch (InstanceNotFoundException e) {
  -            log.warn("MBean was already removed " + name, e);
  -            return;
  -        } catch (MBeanException e) {
  -            log.error("Error while stopping MBean " + name, e);
  -        } catch (ReflectionException e) {
  -            if (e.getTargetException() instanceof NoSuchMethodException) {
  -                // did not have a stop method - ok
  -            } else {
  -                log.error("Error while stopping MBean " + name, e);
  +            log.trace("Checking if MBean is stopped: name=" + name);
  +            if (((Integer) server.getAttribute(name, "State")).intValue() != State.STOPPED_INDEX)
{
  +                log.trace("Cannot run because MBean is not stopped: name=" + name);
  +                return false;
               }
  -        }
  -
  -        try {
  -            server.invoke(name, "destroy", null, null);
  +            log.trace("MBean is stopped: name=" + name);
  +        } catch (AttributeNotFoundException e) {
  +            // ok -- MBean is not state manageable
  +            log.trace("MBean does not have a State attibute");
           } catch (InstanceNotFoundException e) {
  -            log.warn("MBean was already removed " + name, e);
  -            return;
  -        } catch (MBeanException e) {
  -            log.error("Error while destroying MBean " + name, e);
  -        } catch (ReflectionException e) {
  -            if (e.getTargetException() instanceof NoSuchMethodException) {
  -                // did not have a destroy method - ok
  -            } else {
  -                log.error("Error while destroying MBean " + name, e);
  -            }
  +            // instance already removed -- we are good to go
  +        } catch (Exception e) {
  +            // problem getting the attribute, MBean has most likely failed
  +            log.trace("An error occurred while checking if MBean is stopped; MBean will
be unregistered: name=" + name);
           }
  +        return true;
  +    }
   
  +    public void perform() {
           try {
               server.unregisterMBean(name);
           } catch (InstanceNotFoundException e) {
  
  
  

Mime
View raw message