tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/webapps/admin admin.xml
Date Sat, 27 Oct 2001 18:56:23 GMT
craigmcc    01/10/27 11:56:23

  Modified:    catalina/src/share/org/apache/catalina Globals.java
               catalina/src/share/org/apache/catalina/mbeans
                        ServerLifecycleListener.java
               webapps/admin admin.xml
  Log:
  Make the MBeanServer available to privileged contexts that are added
  dynamically later (via processContainerAddChild()) as well as those that
  are configured in server.xml.
  
  Make the Modeler's "Registry" implementation object available as well in
  case this is needed.
  
  Remove the two servlet context attributes when a child Context is removed.
  
  Deregister the corresponding MBeans when Context or Host components are
  removed.  (FIXME - do this for all other cases of component removal too).
  
  Revision  Changes    Path
  1.42      +14 -7     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java
  
  Index: Globals.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- Globals.java	2001/10/27 02:53:01	1.41
  +++ Globals.java	2001/10/27 18:56:22	1.42
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
1.41 2001/10/27 02:53:01 remm Exp $
  - * $Revision: 1.41 $
  - * $Date: 2001/10/27 02:53:01 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
1.42 2001/10/27 18:56:22 craigmcc Exp $
  + * $Revision: 1.42 $
  + * $Date: 2001/10/27 18:56:22 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,7 @@
    * Global constants that are applicable to multiple packages within Catalina.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.41 $ $Date: 2001/10/27 02:53:01 $
  + * @version $Revision: 1.42 $ $Date: 2001/10/27 18:56:22 $
    */
   
   public final class Globals {
  @@ -185,9 +185,16 @@
   
   
       /**
  -     * The request attribute under which the Invoker servlet will store
  -     * the invoking servlet path, if it was used to execute a servlet
  -     * indirectly instead of through a servlet mapping.
  +     * The servlet context attribute under which the managed bean Registry
  +     * will be stored for privileged contexts (if enabled).
  +     */
  +    public static final String MBEAN_REGISTRY_ATTR =
  +        "org.apache.catalina.Registry";
  +
  +
  +    /**
  +     * The servlet context attribute under which the MBeanServer will be stored
  +     * for privileged contexts (if enabled).
        */
       public static final String MBEAN_SERVER_ATTR =
           "org.apache.catalina.MBeanServer";
  
  
  
  1.4       +56 -11    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java
  
  Index: ServerLifecycleListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerLifecycleListener.java	2001/10/27 02:58:35	1.3
  +++ ServerLifecycleListener.java	2001/10/27 18:56:23	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v
1.3 2001/10/27 02:58:35 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/10/27 02:58:35 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v
1.4 2001/10/27 18:56:23 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/10/27 18:56:23 $
    *
    * ====================================================================
    *
  @@ -69,6 +69,7 @@
   import java.util.Collection;
   import java.util.Iterator;
   import javax.management.MBeanException;
  +import javax.management.MBeanServer;
   import javax.management.ObjectName;
   import com.sun.jdmk.comm.AuthInfo;
   import com.sun.jdmk.comm.HtmlAdaptorServer;
  @@ -96,7 +97,7 @@
    *
    * @author Craig R. McClanahan
    * @author Amy Roh
  - * @version $Revision: 1.3 $ $Date: 2001/10/27 02:58:35 $
  + * @version $Revision: 1.4 $ $Date: 2001/10/27 18:56:23 $
    */
   
   public class ServerLifecycleListener
  @@ -315,6 +316,9 @@
                           // in a servlet context attribute
                           if (context.getPrivileged()) {
                               context.getServletContext().setAttribute
  +                                (Globals.MBEAN_REGISTRY_ATTR,
  +                                 MBeanUtils.createRegistry());
  +                            context.getServletContext().setAttribute
                                   (Globals.MBEAN_SERVER_ATTR, 
                                    MBeanUtils.createServer());
                           }
  @@ -394,15 +398,25 @@
   
           try {
               if (child instanceof Context) {
  +                Context context = (Context) child;
  +                if (context.getPrivileged()) {
  +                    context.getServletContext().setAttribute
  +                        (Globals.MBEAN_REGISTRY_ATTR, 
  +                         MBeanUtils.createRegistry());
  +                    context.getServletContext().setAttribute
  +                        (Globals.MBEAN_SERVER_ATTR, 
  +                         MBeanUtils.createServer());
  +                }
                   if (debug >= 4)
  -                    log("  Creating MBean for Context " + child);
  -                MBeanUtils.createMBean((Context) child);
  -                // child.addContainerListener(this);
  +                    log("  Creating MBean for Context " + context);
  +                MBeanUtils.createMBean(context);
  +                // context.addContainerListener(this);
               } else if (child instanceof Host) {
  +                Host host = (Host) child;
                   if (debug >= 3)
  -                    log("  Creating MBean for Host " + child);
  -                MBeanUtils.createMBean((Host) child);
  -                child.addContainerListener(this);
  +                    log("  Creating MBean for Host " + host);
  +                MBeanUtils.createMBean(host);
  +                host.addContainerListener(this);
               }
           } catch (MBeanException t) {
               Exception e = t.getTargetException();
  @@ -447,7 +461,38 @@
               log("Process removeChild[parent=" + parent + ",child=" +
                   child + "]");
   
  -        ; // FIXME - processContainerRemoveChild()
  +        try {
  +            if (child instanceof Context) {
  +                Context context = (Context) child;
  +                if (context.getPrivileged()) {
  +                    context.getServletContext().removeAttribute
  +                        (Globals.MBEAN_REGISTRY_ATTR);
  +                    context.getServletContext().removeAttribute
  +                        (Globals.MBEAN_SERVER_ATTR);
  +                }
  +                if (debug >= 4)
  +                    log("  Removing MBean for Context " + context);
  +                MBeanServer mserver = MBeanUtils.createServer();
  +                mserver.unregisterMBean
  +                    (MBeanUtils.createObjectName(mserver.getDefaultDomain(),
  +                                                 context));
  +                ; // FIXME - child component MBeans?
  +            } else if (child instanceof Host) {
  +                Host host = (Host) child;
  +                MBeanServer mserver = MBeanUtils.createServer();
  +                mserver.unregisterMBean
  +                    (MBeanUtils.createObjectName(mserver.getDefaultDomain(),
  +                                                 host));
  +                ; // FIXME - child component MBeans?
  +            }
  +        } catch (MBeanException t) {
  +            Exception e = t.getTargetException();
  +            if (e == null)
  +                e = t;
  +            log("processContainerRemoveChild: MBeanException", e);
  +        } catch (Throwable t) {
  +            log("processContainerRemoveChild: Throwable", t);
  +        }
   
       }
   
  
  
  
  1.2       +2 -2      jakarta-tomcat-4.0/webapps/admin/admin.xml
  
  Index: admin.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/admin.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- admin.xml	2001/10/25 16:36:05	1.1
  +++ admin.xml	2001/10/27 18:56:23	1.2
  @@ -2,13 +2,13 @@
   
       Context configuration file for the Tomcat Administration Web App
   
  -    $Id: admin.xml,v 1.1 2001/10/25 16:36:05 craigmcc Exp $
  +    $Id: admin.xml,v 1.2 2001/10/27 18:56:23 craigmcc Exp $
   
   -->
   
   
   <Context path="/admin" docBase="../server/webapps/admin"
  -        debug="0" privileged="false">
  +        debug="0" privileged="true">
   
     <Logger className="org.apache.catalina.logger.FileLogger"
                prefix="localhost_admin_log." suffix=".txt"
  
  
  

--
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