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 MBeanUtils.java
Date Tue, 22 Jan 2002 23:46:01 GMT
amyroh      02/01/22 15:46:01

  Modified:    catalina/src/share/org/apache/catalina/mbeans
                        MBeanUtils.java
  Log:
  Add createMBean, createObjectName, and destroyMBean for DefaultContext.
  
  Revision  Changes    Path
  1.13      +91 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java
  
  Index: MBeanUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MBeanUtils.java	22 Jan 2002 23:22:23 -0000	1.12
  +++ MBeanUtils.java	22 Jan 2002 23:46:01 -0000	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v
1.12 2002/01/22 23:22:23 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2002/01/22 23:22:23 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v
1.13 2002/01/22 23:46:01 amyroh Exp $
  + * $Revision: 1.13 $
  + * $Date: 2002/01/22 23:46:01 $
    *
    * ====================================================================
    *
  @@ -79,6 +79,7 @@
   import org.apache.catalina.Connector;
   import org.apache.catalina.Container;
   import org.apache.catalina.Context;
  +import org.apache.catalina.DefaultContext;
   import org.apache.catalina.Engine;
   import org.apache.catalina.Group;
   import org.apache.catalina.Host;
  @@ -106,7 +107,7 @@
    *
    * @author Craig R. McClanahan
    * @author Amy Roh
  - * @version $Revision: 1.12 $ $Date: 2002/01/22 23:22:23 $
  + * @version $Revision: 1.13 $ $Date: 2002/01/22 23:46:01 $
    */
   
   public class MBeanUtils {
  @@ -229,6 +230,33 @@
   
       /**
        * Create, register, and return an MBean for this
  +     * <code>DefaultContext</code> object.
  +     *
  +     * @param context The DefaultContext to be managed
  +     *
  +     * @exception Exception if an MBean cannot be created or registered
  +     */
  +    public static ModelMBean createMBean(DefaultContext context)
  +        throws Exception {
  +
  +        String mname = createManagedName(context);
  +        ManagedBean managed = registry.findManagedBean(mname);
  +        if (managed == null) {
  +            return null;
  +        }
  +        String domain = managed.getDomain();
  +        if (domain == null)
  +            domain = mserver.getDefaultDomain();
  +        ModelMBean mbean = managed.createMBean(context);
  +        ObjectName oname = createObjectName(domain, context);
  +        mserver.registerMBean(mbean, oname);
  +        return (mbean);
  +
  +    }
  +
  +
  +    /**
  +     * Create, register, and return an MBean for this
        * <code>Engine</code> object.
        *
        * @param engine The Engine to be managed
  @@ -412,6 +440,8 @@
           return (mbean);
   
       }
  +
  +
       /**
        * Create, register, and return an MBean for this
        * <code>Server</code> object.
  @@ -623,6 +653,38 @@
   
       /**
        * Create an <code>ObjectName</code> for this
  +     * <code>DefaultContext</code> object.
  +     *
  +     * @param domain Domain in which this name is to be created
  +     * @param context The DefaultContext to be named
  +     *
  +     * @exception MalformedObjectNameException if a name cannot be created
  +     */
  +    public static ObjectName createObjectName(String domain,
  +                                              DefaultContext context)
  +        throws MalformedObjectNameException {
  +
  +        ObjectName name = null;
  +        Container container = context.getParent();
  +        if (container instanceof Host) {
  +            Host host = (Host) container;
  +            Service service = ((Engine)host.getParent()).getService();
  +            name = new ObjectName(domain + ":type=DefaultContext,host=" +
  +                              host.getName() + ",service=" +
  +                              service.getName());
  +        } else if (container instanceof Engine) {
  +            Engine engine = (Engine) container;
  +            Service service = engine.getService();
  +            name = new ObjectName(domain + ":type=DefaultContext,,service=" +
  +                              service.getName());
  +        }
  +
  +        return (name);
  +
  +    }
  +
  +    /**
  +     * Create an <code>ObjectName</code> for this
        * <code>Engine</code> object.
        *
        * @param domain Domain in which this name is to be created
  @@ -1048,6 +1110,31 @@
        * @exception Exception if an MBean cannot be deregistered
        */
       public static void destroyMBean(Context context)
  +        throws Exception {
  +
  +        String mname = createManagedName(context);
  +        ManagedBean managed = registry.findManagedBean(mname);
  +        if (managed == null) {
  +            return;
  +        }
  +        String domain = managed.getDomain();
  +        if (domain == null)
  +            domain = mserver.getDefaultDomain();
  +        ObjectName oname = createObjectName(domain, context);
  +        mserver.unregisterMBean(oname);
  +
  +    }
  +
  +
  +    /**
  +     * Deregister the MBean for this
  +     * <code>DefaultContext</code> object.
  +     *
  +     * @param context The DefaultContext to be managed
  +     *
  +     * @exception Exception if an MBean cannot be deregistered
  +     */
  +    public static void destroyMBean(DefaultContext context)
           throws Exception {
   
           String mname = createManagedName(context);
  
  
  

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