tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amy...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans MBeanFactory.java StandardContextMBean.java StandardEngineMBean.java StandardHostMBean.java StandardServerMBean.java StandardServiceMBean.java mbeans-descriptors.xml
Date Tue, 29 Jan 2002 23:10:49 GMT
amyroh      02/01/29 15:10:49

  Modified:    catalina/src/share/org/apache/catalina/mbeans
                        MBeanFactory.java StandardContextMBean.java
                        StandardEngineMBean.java StandardHostMBean.java
                        StandardServerMBean.java StandardServiceMBean.java
                        mbeans-descriptors.xml
  Log:
  Add managedResource as one of properties for Container MBeans so its object
  is accessible from other mbeans.
  Finish createXxxx and addXxxx for mbeans.
  
  Revision  Changes    Path
  1.4       +81 -137   jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java
  
  Index: MBeanFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MBeanFactory.java	23 Jan 2002 11:04:07 -0000	1.3
  +++ MBeanFactory.java	29 Jan 2002 23:10:49 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v
1.3 2002/01/23 11:04:07 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/01/23 11:04:07 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v
1.4 2002/01/29 23:10:49 amyroh Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/01/29 23:10:49 $
    *
    * ====================================================================
    *
  @@ -102,7 +102,7 @@
    * <code>org.apache.catalina.core.StandardServer</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.3 $ $Date: 2002/01/23 11:04:07 $
  + * @version $Revision: 1.4 $ $Date: 2002/01/29 23:10:49 $
    */
   
   public class MBeanFactory extends BaseModelMBean {
  @@ -162,14 +162,12 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           AccessLogValve accessLogger = new AccessLogValve();
           accessLogger.setContainer(container);
           ObjectName oname = MBeanUtils.createObjectName(domain, accessLogger);
  @@ -197,17 +195,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Host.
  -        StandardHostMBean hostMBean = null;
  -        //Host host = hostMBean.getManagedObject();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Host host = null;
  +        if (obj instanceof Host) {
  +            host = (Host) obj;
  +        }
           StandardDefaultContext context = new StandardDefaultContext();
  -
           context.setParent(host);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, context);
           MBeanUtils.createMBean(context);
           context.setParent(null);
  @@ -216,7 +211,7 @@
   
       }
   
  -    
  +
       /**
        * Create a new FileLogger.
        *
  @@ -233,14 +228,12 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           FileLogger fileLogger = new FileLogger();
           fileLogger.setContainer(container);
           ObjectName oname = MBeanUtils.createObjectName(domain, fileLogger);
  @@ -270,21 +263,17 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Service.
  -        StandardServiceMBean serviceMBean = null;
  -        //Service service = serviceMBean.getManagedObject();
  -        //Service service = (Service) this.resource;
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Service service = null;
  +        if (obj instanceof Service) {
  +            service = (Service) obj;
  +        }
           org.apache.catalina.connector.http10.HttpConnector connector =
               new org.apache.catalina.connector.http10.HttpConnector();
  -
           connector.setAddress(address);
           connector.setPort(port);
           connector.setService(service);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, connector);
           MBeanUtils.createMBean(connector);
           connector.setService(null);
  @@ -312,21 +301,17 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Service.
  -        StandardServiceMBean serviceMBean = null;
  -        //Service service = serviceMBean.getManagedObject();
  -        //Service service = (Service) this.resource;
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Service service = null;
  +        if (obj instanceof Service) {
  +            service = (Service) obj;
  +        }
           org.apache.catalina.connector.http.HttpConnector connector =
               new org.apache.catalina.connector.http.HttpConnector();
  -
           connector.setAddress(address);
           connector.setPort(port);
           connector.setService(service);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, connector);
           MBeanUtils.createMBean(connector);
           connector.setService(null);
  @@ -352,17 +337,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           JDBCRealm realm = new JDBCRealm();
           realm.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, realm);
           MBeanUtils.createMBean(realm);
           realm.setContainer(null);
  @@ -388,17 +370,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           JNDIRealm realm = new JNDIRealm();
           realm.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, realm);
           MBeanUtils.createMBean(realm);
           realm.setContainer(null);
  @@ -424,17 +403,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           MemoryRealm realm = new MemoryRealm();
           realm.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, realm);
           MBeanUtils.createMBean(realm);
           realm.setContainer(null);
  @@ -460,17 +436,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           RemoteAddrValve valve = new RemoteAddrValve();
           valve.setContainer(container);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, valve);
           MBeanUtils.createMBean(valve);
           valve.setContainer(null);
  @@ -496,17 +469,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           RemoteHostValve valve = new RemoteHostValve();
           valve.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, valve);
           MBeanUtils.createMBean(valve);
           valve.setContainer(null);
  @@ -532,17 +502,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           RequestDumperValve valve = new RequestDumperValve();
           valve.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, valve);
           MBeanUtils.createMBean(valve);
           valve.setContainer(null);
  @@ -568,17 +535,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           SingleSignOn singleSignOn = new SingleSignOn();
           singleSignOn.setContainer(container);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, singleSignOn);
           MBeanUtils.createMBean(singleSignOn);
           singleSignOn.setContainer(null);
  @@ -605,18 +569,15 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Host.
  -        StandardHostMBean hostMBean = null;
  -        //Host host = hostMBean.getManagedObject();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Host host = null;
  +        if (obj instanceof Host) {
  +            host = (Host) obj;
  +        }
           StandardContext context = new StandardContext();
  -
           context.setPath(path);
           context.setParent(host);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, context);
           MBeanUtils.createMBean(context);
           context.setParent(null);
  @@ -643,17 +604,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Service.
  -        StandardServiceMBean serviceMBean = null;
  -        //Service service = serviceMBean.getManagedObject();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Service service = null;
  +        if (obj instanceof Service) {
  +            service = (Service) obj;
  +        }
           StandardEngine engine = new StandardEngine();
  -
           engine.setService(service);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, service);
           MBeanUtils.createMBean(service);
           engine.setService(null);
  @@ -680,18 +638,15 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Engine.
  -        StandardEngineMBean engineMBean = null;
  -        // Engine engine = engineMBean.getManagedObject();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Engine engine = null;
  +        if (obj instanceof Engine) {
  +            engine = (Engine) obj;
  +        }
           StandardHost host = new StandardHost();
  -
           host.setName(name);
           host.setParent(engine);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, host);
           MBeanUtils.createMBean(host);
           host.setParent(null);
  @@ -717,14 +672,12 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           StandardManager manager = new StandardManager();
           manager.setContainer(container);
           ObjectName oname = MBeanUtils.createObjectName(domain, manager);
  @@ -754,18 +707,15 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Server.
  -        StandardServerMBean serverMBean = null;
  -        //Server server = serverMBean.getManagedObject();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Server server = null;
  +        if (obj instanceof Server) {
  +            server = (Server) obj;
  +        }
           StandardService service = new StandardService();
  -
           service.setName(name);
           service.setServer(server);
  -
           ObjectName oname = MBeanUtils.createObjectName(domain, service);
           MBeanUtils.createMBean(service);
           service.setServer(null);
  @@ -792,17 +742,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           SystemErrLogger logger = new SystemErrLogger();
           logger.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, logger);
           MBeanUtils.createMBean(logger);
           logger.setContainer(null);
  @@ -828,17 +775,14 @@
               domain = managed.getDomain();
           if (domain == null)
               domain = mserver.getDefaultDomain();
  -
           ObjectName pname = new ObjectName(parent);
  -        ObjectInstance oinstance = mserver.getObjectInstance(pname);
  -        // look up the MBean for the owning Container.
  -        BaseModelMBean containerMBean = null;
  -        //Container container = containerMBean.getManagedResource();
  +        Object obj = mserver.getAttribute(pname, "managedResource");
           Container container = null;
  -
  +        if (obj instanceof Container) {
  +            container = (Container) obj;
  +        }
           SystemOutLogger logger = new SystemOutLogger();
           logger.setContainer(container);
  -        
           ObjectName oname = MBeanUtils.createObjectName(domain, logger);
           MBeanUtils.createMBean(logger);
           logger.setContainer(null);
  
  
  
  1.3       +40 -22    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java
  
  Index: StandardContextMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardContextMBean.java	22 Jan 2002 23:53:39 -0000	1.2
  +++ StandardContextMBean.java	29 Jan 2002 23:10:49 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java,v
1.2 2002/01/22 23:53:39 amyroh Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/22 23:53:39 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java,v
1.3 2002/01/29 23:10:49 amyroh Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/29 23:10:49 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,8 @@
   
   
   import javax.management.MBeanException;
  +import javax.management.MBeanServer;
  +import javax.management.ObjectName;
   import javax.management.RuntimeOperationsException;
   import org.apache.catalina.Loader;
   import org.apache.catalina.Logger;
  @@ -80,11 +82,15 @@
    * <code>org.apache.catalina.core.StandardContext</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.2 $ $Date: 2002/01/22 23:53:39 $
  + * @version $Revision: 1.3 $ $Date: 2002/01/29 23:10:49 $
    */
   
   public class StandardContextMBean extends BaseModelMBean {
   
  +    /**
  +     * The <code>MBeanServer</code> for this application.
  +     */
  +    private static MBeanServer mserver = MBeanUtils.createServer();
   
       // ----------------------------------------------------------- Constructors
   
  @@ -124,10 +130,12 @@
           throws Exception {
   
           StandardContext context = (StandardContext) this.resource;
  -        // look up valve's MBean in MBeanServer
  -        BaseModelMBean valveMBean = null;
  -        //Valve valveObj = valveMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(valve);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Valve valveObj = null;
  +        if (obj instanceof Valve) {
  +            valveObj = (Valve) obj;
  +        }
           context.addValve(valveObj);
   
       }
  @@ -144,10 +152,12 @@
           throws Exception {
   
           StandardContext context = (StandardContext) this.resource;
  -        // look up valve's MBean in MBeanServer
  -        BaseModelMBean valveMBean = null;
  -        //Valve valveObj = valveMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(valve);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Valve valveObj = null;
  +        if (obj instanceof Valve) {
  +            valveObj = (Valve) obj;
  +        }
           context.removeValve(valveObj);
   
       }
  @@ -164,10 +174,12 @@
           throws Exception {
   
           StandardContext context = (StandardContext) this.resource;
  -        // look up loader's MBean in MBeanServer
  -        BaseModelMBean loaderMBean = null;
  -        //Loader loaderObj = loaderMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(loader);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Loader loaderObj = null;
  +        if (obj instanceof Loader) {
  +            loaderObj = (Loader) obj;
  +        }
           context.setLoader(loaderObj);
   
       }
  @@ -184,10 +196,12 @@
           throws Exception {
   
           StandardContext context = (StandardContext) this.resource;
  -        // look up logger's MBean in MBeanServer
  -        BaseModelMBean loggerMBean = null;
  -        //logger loggerObj = loggerMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(logger);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Logger loggerObj = null;
  +        if (obj instanceof Logger) {
  +            loggerObj = (Logger) obj;
  +        }
           context.setLogger(loggerObj);
   
       }
  @@ -204,10 +218,12 @@
           throws Exception {
   
           StandardContext context = (StandardContext) this.resource;
  -        // look up manager's MBean in MBeanServer
  -        BaseModelMBean managerMBean = null;
  -        // Manager managerObj = managerMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(manager);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Manager managerObj = null;
  +        if (obj instanceof Manager) {
  +            managerObj = (Manager) obj;
  +        }
           context.setManager(managerObj);
   
       }
  @@ -224,10 +240,12 @@
           throws Exception {
   
           StandardContext context = (StandardContext) this.resource;
  -        // look up realm's MBean in MBeanServer
  -        BaseModelMBean realmMBean = null;
  -        // Realm realmObj = realmMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(realm);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Realm realmObj = null;
  +        if (obj instanceof Realm) {
  +            realmObj = (Realm) obj;
  +        }
           context.setRealm(realmObj);
   
       }
  
  
  
  1.6       +41 -23    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java
  
  Index: StandardEngineMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardEngineMBean.java	22 Jan 2002 23:53:39 -0000	1.5
  +++ StandardEngineMBean.java	29 Jan 2002 23:10:49 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java,v
1.5 2002/01/22 23:53:39 amyroh Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/01/22 23:53:39 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java,v
1.6 2002/01/29 23:10:49 amyroh Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/01/29 23:10:49 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,8 @@
   
   
   import javax.management.MBeanException;
  +import javax.management.MBeanServer;
  +import javax.management.ObjectName;
   import javax.management.RuntimeOperationsException;
   import org.apache.catalina.Container;
   import org.apache.catalina.Engine;
  @@ -83,12 +85,16 @@
    * <code>org.apache.catalina.core.StandardEngine</code> component.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2002/01/22 23:53:39 $
  + * @version $Revision: 1.6 $ $Date: 2002/01/29 23:10:49 $
    */
   
   public class StandardEngineMBean extends BaseModelMBean {
   
  -
  +    /**
  +     * The <code>MBeanServer</code> for this application.
  +     */
  +    private static MBeanServer mserver = MBeanUtils.createServer();
  +    
       // ----------------------------------------------------------- Constructors
   
   
  @@ -127,10 +133,12 @@
           throws Exception {
   
           StandardEngine engine = (StandardEngine) this.resource;
  -        // look up host's MBean in MBeanServer
  -        BaseModelMBean hostMBean = null;
  -        //Host hostObj = hostMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(host);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Host hostObj = null;
  +        if (obj instanceof Host) {
  +            hostObj = (Host) obj;
  +        }
           engine.addChild(hostObj);
   
       }
  @@ -147,10 +155,12 @@
           throws Exception {
   
           StandardEngine engine = (StandardEngine) this.resource;
  -        // look up host's MBean in MBeanServer
  -        BaseModelMBean hostMBean = null;
  -        //Host hostObj = hostMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(host);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Host hostObj = null;
  +        if (obj instanceof Host) {
  +            hostObj = (Host) obj;
  +        }
           engine.removeChild(hostObj);
   
       }
  @@ -167,10 +177,12 @@
           throws Exception {
   
           StandardEngine engine = (StandardEngine) this.resource;
  -        // look up valve's MBean in MBeanServer
  -        BaseModelMBean valveMBean = null;
  -        //Valve valveObj = valveMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(valve);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Valve valveObj = null;
  +        if (obj instanceof Valve) {
  +            valveObj = (Valve) obj;
  +        }
           engine.addValve(valveObj);
   
       }
  @@ -187,10 +199,12 @@
           throws Exception {
   
           StandardEngine engine = (StandardEngine) this.resource;
  -        // look up valve's MBean in MBeanServer
  -        BaseModelMBean valveMBean = null;
  -        //Valve valveObj = valveMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(valve);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Valve valveObj = null;
  +        if (obj instanceof Valve) {
  +            valveObj = (Valve) obj;
  +        }
           engine.removeValve(valveObj);
   
       }
  @@ -207,10 +221,12 @@
           throws Exception {
   
           StandardEngine engine = (StandardEngine) this.resource;
  -        // look up logger's MBean in MBeanServer
  -        BaseModelMBean loggerMBean = null;
  -        //logger loggerObj = loggerMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(logger);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Logger loggerObj = null;
  +        if (obj instanceof Logger) {
  +            loggerObj = (Logger) obj;
  +        }
           engine.setLogger(loggerObj);
   
       }
  @@ -227,10 +243,12 @@
           throws Exception {
   
           StandardEngine engine = (StandardEngine) this.resource;
  -        // look up realm's MBean in MBeanServer
  -        BaseModelMBean realmMBean = null;
  -        // Realm realmObj = realmMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(realm);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Realm realmObj = null;
  +        if (obj instanceof Realm) {
  +            realmObj = (Realm) obj;
  +        }
           engine.setRealm(realmObj);
   
       }
  
  
  
  1.3       +40 -25    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java
  
  Index: StandardHostMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardHostMBean.java	22 Jan 2002 23:53:39 -0000	1.2
  +++ StandardHostMBean.java	29 Jan 2002 23:10:49 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java,v
1.2 2002/01/22 23:53:39 amyroh Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/22 23:53:39 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java,v
1.3 2002/01/29 23:10:49 amyroh Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/29 23:10:49 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,7 @@
   
   import javax.management.MBeanException;
   import javax.management.MBeanServer;
  +import javax.management.ObjectName;
   import javax.management.RuntimeOperationsException;
   import org.apache.catalina.Engine;
   import org.apache.catalina.Host;
  @@ -84,11 +85,15 @@
    * <code>org.apache.catalina.core.StandardHost</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.2 $ $Date: 2002/01/22 23:53:39 $
  + * @version $Revision: 1.3 $ $Date: 2002/01/29 23:10:49 $
    */
   
   public class StandardHostMBean extends BaseModelMBean {
   
  +    /**
  +     * The <code>MBeanServer</code> for this application.
  +     */
  +    private static MBeanServer mserver = MBeanUtils.createServer();
   
       // ----------------------------------------------------------- Constructors
   
  @@ -144,10 +149,12 @@
           throws Exception {
   
           StandardHost host = (StandardHost) this.resource;
  -        // look up context's MBean in MBeanServer
  -        StandardContextMBean contextMBean = null;
  -        //StandardContext contextObj = contextMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(context);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           StandardContext contextObj = null;
  +        if (obj instanceof StandardContext) {
  +            contextObj = (StandardContext) obj;
  +        }
           host.addChild(contextObj);
   
       }
  @@ -164,10 +171,12 @@
           throws Exception {
   
           StandardHost host = (StandardHost) this.resource;
  -        // look up valve's MBean in MBeanServer
  -        BaseModelMBean valveMBean = null;
  -        //Valve valveObj = valveMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(valve);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Valve valveObj = null;
  +        if (obj instanceof Valve) {
  +            valveObj = (Valve) obj;
  +        }
           host.addValve(valveObj);
   
       }
  @@ -196,9 +205,7 @@
           throws Exception {
   
           Registry registry = MBeanUtils.createRegistry();
  -        MBeanServer mserver = MBeanUtils.createServer();
           StandardHost host = (StandardHost) this.resource;
  -
           String mname = MBeanUtils.createManagedName(host);
           ManagedBean managed = registry.findManagedBean(mname);
           String domain = null;
  @@ -209,7 +216,7 @@
               domain = mserver.getDefaultDomain();
           Valve [] valves = host.getValves();
           String [] mbeanNames = new String[valves.length];
  -        for (int i=0; i<valves.length; i++) {
  +        for (int i = 0; i < valves.length; i++) {
               mbeanNames[i] =
                   MBeanUtils.createObjectName(domain, valves[i]).toString();
           }
  @@ -246,10 +253,12 @@
           throws Exception {
   
           StandardHost host = (StandardHost) this.resource;
  -        // look up context's MBean in MBeanServer
  -        StandardContextMBean contextMBean = null;
  -        //StandardContext contextObj = contextMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(context);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           StandardContext contextObj = null;
  +        if (obj instanceof StandardContext) {
  +            contextObj = (StandardContext) obj;
  +        }
           host.removeChild(contextObj);
   
       }
  @@ -266,10 +275,12 @@
           throws Exception {
   
           StandardHost host = (StandardHost) this.resource;
  -        // look up valve's MBean in MBeanServer
  -        BaseModelMBean valveMBean = null;
  -        //Valve valveObj = valveMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(valve);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Valve valveObj = null;
  +        if (obj instanceof Valve) {
  +            valveObj = (Valve) obj;
  +        }
           host.removeValve(valveObj);
   
       }
  @@ -286,10 +297,12 @@
           throws Exception {
   
           StandardHost host = (StandardHost) this.resource;
  -        // look up logger's MBean in MBeanServer
  -        BaseModelMBean loggerMBean = null;
  -        //logger loggerObj = loggerMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(logger);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Logger loggerObj = null;
  +        if (obj instanceof Logger) {
  +            loggerObj = (Logger) obj;
  +        }
           host.setLogger(loggerObj);
   
       }
  @@ -306,10 +319,12 @@
           throws Exception {
   
           StandardHost host = (StandardHost) this.resource;
  -        // look up realm's MBean in MBeanServer
  -        BaseModelMBean realmMBean = null;
  -        // Realm realmObj = realmMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(realm);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Realm realmObj = null;
  +        if (obj instanceof Realm) {
  +            realmObj = (Realm) obj;
  +        }
           host.setRealm(realmObj);
   
       }
  
  
  
  1.5       +21 -10    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java
  
  Index: StandardServerMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StandardServerMBean.java	22 Jan 2002 23:53:39 -0000	1.4
  +++ StandardServerMBean.java	29 Jan 2002 23:10:49 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v
1.4 2002/01/22 23:53:39 amyroh Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/01/22 23:53:39 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v
1.5 2002/01/29 23:10:49 amyroh Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/01/29 23:10:49 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,8 @@
   
   
   import javax.management.MBeanException;
  +import javax.management.MBeanServer;
  +import javax.management.ObjectName;
   import javax.management.RuntimeOperationsException;
   import org.apache.catalina.Server;
   import org.apache.catalina.Service;
  @@ -77,11 +79,16 @@
    * <code>org.apache.catalina.core.StandardServer</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.4 $ $Date: 2002/01/22 23:53:39 $
  + * @version $Revision: 1.5 $ $Date: 2002/01/29 23:10:49 $
    */
   
   public class StandardServerMBean extends BaseModelMBean {
   
  +    /**
  +     * The <code>MBeanServer</code> for this application.
  +     */
  +    private static MBeanServer mserver = MBeanUtils.createServer();
  +    
   
       // ----------------------------------------------------------- Constructors
   
  @@ -122,10 +129,12 @@
           throws Exception {
   
           Server server = (Server) this.resource;
  -        // look up service's MBean in MBeanServer
  -        StandardServiceMBean serviceMBean = null;
  -        //Service serviceObj = serviceMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(service);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Service serviceObj = null;
  +        if (obj instanceof Service) {
  +            serviceObj = (Service) obj;
  +        }
           server.addService(serviceObj);
   
       }
  @@ -141,10 +150,12 @@
           throws Exception {
   
           Server server = (Server) this.resource;
  -        // look up service's MBean in MBeanServer
  -        StandardServiceMBean serviceMBean = null;
  -        //Service service = serviceMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(service);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Service serviceObj = null;
  +        if (obj instanceof Service) {
  +            serviceObj = (Service) obj;
  +        }
           MBeanUtils.destroyMBean(serviceObj);
           server.removeService(serviceObj);
   
  
  
  
  1.7       +21 -11    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java
  
  Index: StandardServiceMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StandardServiceMBean.java	22 Jan 2002 23:53:39 -0000	1.6
  +++ StandardServiceMBean.java	29 Jan 2002 23:10:49 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java,v
1.6 2002/01/22 23:53:39 amyroh Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/01/22 23:53:39 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java,v
1.7 2002/01/29 23:10:49 amyroh Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/01/29 23:10:49 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,8 @@
   
   
   import javax.management.MBeanException;
  +import javax.management.MBeanServer;
  +import javax.management.ObjectName;
   import javax.management.RuntimeOperationsException;
   import org.apache.catalina.Connector;
   import org.apache.catalina.Service;
  @@ -76,12 +78,16 @@
    * <code>org.apache.catalina.core.StandardService</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.6 $ $Date: 2002/01/22 23:53:39 $
  + * @version $Revision: 1.7 $ $Date: 2002/01/29 23:10:49 $
    */
   
   public class StandardServiceMBean extends BaseModelMBean {
   
  -
  +    /**
  +     * The <code>MBeanServer</code> for this application.
  +     */
  +    private static MBeanServer mserver = MBeanUtils.createServer();
  +    
       // ----------------------------------------------------------- Constructors
   
   
  @@ -120,10 +126,12 @@
           throws Exception {
   
           Service service = (Service) this.resource;
  -        // look up connector's MBean in MBeanServer
  -        BaseModelMBean connectorMBean = null;
  -        //Connector = connectorMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(connector);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Connector connectorObj = null;
  +        if (obj instanceof Connector) {
  +            connectorObj = (Connector) obj;
  +        }
           service.addConnector(connectorObj);
   
       }
  @@ -140,10 +148,12 @@
           throws Exception {
   
           Service service = (Service) this.resource;
  -        // look up connector's MBean in MBeanServer
  -        BaseModelMBean connectorMBean = null;
  -        //Connector = connectorMBean.getManagedResource();
  +        ObjectName oname = new ObjectName(connector);
  +        Object obj = mserver.getAttribute(oname, "managedResource");
           Connector connectorObj = null;
  +        if (obj instanceof Connector) {
  +            connectorObj = (Connector) obj;
  +        }
           service.removeConnector(connectorObj);
   
       }
  
  
  
  1.24      +25 -1     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/mbeans-descriptors.xml
  
  Index: mbeans-descriptors.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/mbeans-descriptors.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- mbeans-descriptors.xml	26 Jan 2002 00:59:42 -0000	1.23
  +++ mbeans-descriptors.xml	29 Jan 2002 23:10:49 -0000	1.24
  @@ -6,7 +6,7 @@
   <!--
        Descriptions of JMX MBeans for Catalina
   
  -     $Id: mbeans-descriptors.xml,v 1.23 2002/01/26 00:59:42 craigmcc Exp $
  +     $Id: mbeans-descriptors.xml,v 1.24 2002/01/29 23:10:49 amyroh Exp $
    -->
   
   <mbeans-descriptors>
  @@ -880,6 +880,10 @@
             description="The document root for this web application"
                    type="java.lang.String"/>
   
  +    <attribute   name="managedResource"
  +          description="The managed resource this MBean is associated with"
  +                 type="java.lang.Object"/>
  +
       <attribute   name="override"
             description="The DefaultContext override flag for this web application"
                    type="boolean"/>
  @@ -973,6 +977,10 @@
             description="Name of the default Host for this Engine"
                    type="java.lang.String"/>
   
  +    <attribute   name="managedResource"
  +          description="The managed resource this MBean is associated with"
  +                 type="java.lang.Object"/>
  +                 
       <attribute   name="name"
             description="Unique name of this Engine"
                    type="java.lang.String"/>
  @@ -1049,6 +1057,10 @@
             description="The debugging detail level for this component"
                    type="int"/>
   
  +    <attribute   name="managedResource"
  +          description="The managed resource this MBean is associated with"
  +                 type="java.lang.Object"/>
  +                 
       <attribute   name="name"
             description="Unique name of this Host"
                    type="java.lang.String"/>
  @@ -1169,6 +1181,10 @@
             description="A String initialization parameter used to increase the entropy of
the initialization of our random number generator"
                    type="java.lang.String"/>
   
  +    <attribute   name="managedResource"
  +          description="The managed resource this MBean is associated with"
  +                 type="java.lang.Object"/>
  +                 
       <attribute   name="maxActiveSessions"
             description="The maximum number of active Sessions allowed, or -1 for no limit"
                    type="int"/>
  @@ -1200,6 +1216,10 @@
             description="The debugging detail level for this component"
                    type="int"/>
   
  +    <attribute   name="managedResource"
  +          description="The managed resource this MBean is associated with"
  +                 type="java.lang.Object"/>
  +                 
       <attribute   name="port"
             description="TCP port for shutdown messages"
                    type="int"/>
  @@ -1235,6 +1255,10 @@
                  domain="Catalina"
                   group="Service"
                    type="org.apache.catalina.core.StandardService">
  +                 
  +    <attribute   name="managedResource"
  +          description="The managed resource this MBean is associated with"
  +                 type="java.lang.Object"/>
   
       <attribute   name="name"
             description="Unique name of this Service"
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message