You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2002/03/06 07:49:12 UTC

cvs commit: jakarta-tomcat-4.0/webapps/admin/service service.jsp addService.jsp

craigmcc    02/03/05 22:49:12

  Modified:    catalina/src/share/org/apache/catalina Server.java
               catalina/src/share/org/apache/catalina/core
                        StandardEngine.java StandardServer.java
                        StandardService.java
               catalina/src/share/org/apache/catalina/mbeans
                        MBeanFactory.java ServerLifecycleListener.java
                        mbeans-descriptors.xml
               webapps/admin server.jsp
               webapps/admin/WEB-INF struts-config.xml
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        ActionTag.java ApplicationResources_en.properties
                        LabelValueBean.java TomcatTreeBuilder.java
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service
                        ServiceForm.java
               webapps/admin/host host.jsp
               webapps/admin/service service.jsp
  Added:       webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service
                        EditServiceAction.java SaveServiceAction.java
  Removed:     webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service
                        AddServiceAction.java AddServiceForm.java
                        ServiceAction.java
               webapps/admin/service addService.jsp
  Log:
  Refactor admin application logic (and UI) for re-use of shared logic.
  
  Add event notification generation on StandardServer and StandardService
  (and required listeners in ServerLifecycleListener) to support dynamic
  creation and removal of Service and Engine components.
  
  Comment out "Available Actions" choices that are not yet functional.
  
  Revision  Changes    Path
  1.10      +13 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Server.java
  
  Index: Server.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Server.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Server.java	3 Jan 2002 01:48:48 -0000	1.9
  +++ Server.java	6 Mar 2002 06:49:10 -0000	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Server.java,v 1.9 2002/01/03 01:48:48 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2002/01/03 01:48:48 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Server.java,v 1.10 2002/03/06 06:49:10 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2002/03/06 06:49:10 $
    *
    * ====================================================================
    *
  @@ -88,7 +88,7 @@
    * class in its constructor(s).
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2002/01/03 01:48:48 $
  + * @version $Revision: 1.10 $ $Date: 2002/03/06 06:49:10 $
    */
   
   public interface Server {
  @@ -163,6 +163,15 @@
        * Wait until a proper shutdown command is received, then return.
        */
       public void await();
  +
  +
  +    /**
  +     * Return the specified Service (if it exists); otherwise return
  +     * <code>null</code>.
  +     *
  +     * @param name Name of the Service to be returned
  +     */
  +    public Service findService(String name);
   
   
       /**
  
  
  
  1.14      +9 -5      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardEngine.java
  
  Index: StandardEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardEngine.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StandardEngine.java	14 Jan 2002 23:37:49 -0000	1.13
  +++ StandardEngine.java	6 Mar 2002 06:49:11 -0000	1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardEngine.java,v 1.13 2002/01/14 23:37:49 remm Exp $
  - * $Revision: 1.13 $
  - * $Date: 2002/01/14 23:37:49 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardEngine.java,v 1.14 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.14 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -86,7 +86,7 @@
    * fully qualified host name of that virtual host.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.13 $ $Date: 2002/01/14 23:37:49 $
  + * @version $Revision: 1.14 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public class StandardEngine
  @@ -172,7 +172,11 @@
       public void setDefaultHost(String host) {
   
           String oldDefaultHost = this.defaultHost;
  -        this.defaultHost = host.toLowerCase();
  +        if (host == null) {
  +            this.defaultHost = null;
  +        } else {
  +            this.defaultHost = host.toLowerCase();
  +        }
           support.firePropertyChange("defaultHost", oldDefaultHost,
                                      this.defaultHost);
   
  
  
  
  1.22      +56 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- StandardServer.java	31 Jan 2002 20:56:03 -0000	1.21
  +++ StandardServer.java	6 Mar 2002 06:49:11 -0000	1.22
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v 1.21 2002/01/31 20:56:03 craigmcc Exp $
  - * $Revision: 1.21 $
  - * $Date: 2002/01/31 20:56:03 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v 1.22 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.22 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,6 +65,7 @@
   package org.apache.catalina.core;
   
   
  +import java.beans.PropertyChangeListener;
   import java.beans.PropertyChangeSupport;
   import java.io.InputStream;
   import java.io.IOException;
  @@ -92,7 +93,7 @@
    * (but not required) when deploying and starting Catalina.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.21 $ $Date: 2002/01/31 20:56:03 $
  + * @version $Revision: 1.22 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public final class StandardServer
  @@ -466,6 +467,29 @@
   
   
       /**
  +     * Return the specified Service (if it exists); otherwise return
  +     * <code>null</code>.
  +     *
  +     * @param name Name of the Service to be returned
  +     */
  +    public Service findService(String name) {
  +
  +        if (name == null) {
  +            return (null);
  +        }
  +        synchronized (services) {
  +            for (int i = 0; i < services.length; i++) {
  +                if (name.equals(services[i].getName())) {
  +                    return (services[i]);
  +                }
  +            }
  +        }
  +        return (null);
  +
  +    }
  +
  +
  +    /**
        * Return the set of Services defined within this Server.
        */
       public Service[] findServices() {
  @@ -511,6 +535,33 @@
               // Report this property change to interested listeners
               support.firePropertyChange("service", service, null);
           }
  +
  +    }
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Add a property change listener to this component.
  +     *
  +     * @param listener The listener to add
  +     */
  +    public void addPropertyChangeListener(PropertyChangeListener listener) {
  +
  +        support.addPropertyChangeListener(listener);
  +
  +    }
  +
  +
  +    /**
  +     * Remove a property change listener from this component.
  +     *
  +     * @param listener The listener to remove
  +     */
  +    public void removePropertyChangeListener(PropertyChangeListener listener) {
  +
  +        support.removePropertyChangeListener(listener);
   
       }
   
  
  
  
  1.9       +92 -15    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardService.java
  
  Index: StandardService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StandardService.java	9 Nov 2001 19:39:11 -0000	1.8
  +++ StandardService.java	6 Mar 2002 06:49:11 -0000	1.9
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardService.java,v 1.8 2001/11/09 19:39:11 remm Exp $
  - * $Revision: 1.8 $
  - * $Date: 2001/11/09 19:39:11 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardService.java,v 1.9 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,6 +65,8 @@
   package org.apache.catalina.core;
   
   
  +import java.beans.PropertyChangeListener;
  +import java.beans.PropertyChangeSupport;
   import org.apache.catalina.Connector;
   import org.apache.catalina.Container;
   import org.apache.catalina.Engine;
  @@ -84,7 +86,7 @@
    * not required.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2001/11/09 19:39:11 $
  + * @version $Revision: 1.9 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public final class StandardService
  @@ -107,6 +109,12 @@
   
   
       /**
  +     * The debugging detail level for this component.
  +     */
  +    private int debug = 0;
  +
  +
  +    /**
        * Descriptive information about this component implementation.
        */
       private static final String info =
  @@ -114,6 +122,12 @@
   
   
       /**
  +     * Has this component been initialized?
  +     */
  +    private boolean initialized = false;
  +
  +
  +    /**
        * The name of this service.
        */
       private String name = null;
  @@ -143,9 +157,9 @@
   
   
       /**
  -     * Has this component been initialized?
  +     * The property change support for this component.
        */
  -    private boolean initialized = false;
  +    protected PropertyChangeSupport support = new PropertyChangeSupport(this);
   
   
       // ------------------------------------------------------------- Properties
  @@ -197,6 +211,31 @@
               }
           }
   
  +        // Report this property change to interested listeners
  +        support.firePropertyChange("container", oldContainer, this.container);
  +
  +    }
  +
  +
  +    /**
  +     * Return the debugging detail level of this component.
  +     */
  +    public int getDebug() {
  +
  +        return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the debugging detail level of this component.
  +     *
  +     * @param debug The new debugging detail level
  +     */
  +    public void setDebug(int debug) {
  +
  +        this.debug = debug;
  +
       }
   
   
  @@ -290,12 +329,27 @@
                       ;
                   }
               }
  +
  +            // Report this property change to interested listeners
  +            support.firePropertyChange("connector", null, connector);
           }
   
       }
   
   
       /**
  +     * Add a property change listener to this component.
  +     *
  +     * @param listener The listener to add
  +     */
  +    public void addPropertyChangeListener(PropertyChangeListener listener) {
  +
  +        support.addPropertyChangeListener(listener);
  +
  +    }
  +
  +
  +    /**
        * Find and return the set of Connectors associated with this Service.
        */
       public Connector[] findConnectors() {
  @@ -340,12 +394,27 @@
                       results[k++] = connectors[i];
               }
               connectors = results;
  +
  +            // Report this property change to interested listeners
  +            support.firePropertyChange("connector", connector, null);
           }
   
       }
   
   
       /**
  +     * Remove a property change listener from this component.
  +     *
  +     * @param listener The listener to remove
  +     */
  +    public void removePropertyChangeListener(PropertyChangeListener listener) {
  +
  +        support.removePropertyChangeListener(listener);
  +
  +    }
  +
  +
  +    /**
        * Return a String representation of this component.
        */
       public String toString() {
  @@ -410,9 +479,10 @@
       public void start() throws LifecycleException {
   
           // Validate and update our current component state
  -        if (started)
  +        if (started) {
               throw new LifecycleException
                   (sm.getString("standardService.start.started"));
  +        }
   
           System.out.println
               (sm.getString("standardService.start.name", this.name));
  @@ -420,9 +490,12 @@
           started = true;
   
           // Start our defined Container first
  -        synchronized (container) {
  -            if ((container != null) && (container instanceof Lifecycle))
  -                ((Lifecycle) container).start();
  +        if (container != null) {
  +            synchronized (container) {
  +                if (container instanceof Lifecycle) {
  +                    ((Lifecycle) container).start();
  +                }
  +            }
           }
   
           // Start our defined Connectors second
  @@ -449,9 +522,10 @@
       public void stop() throws LifecycleException {
   
           // Validate and update our current component state
  -        if (!started)
  +        if (!started) {
               throw new LifecycleException
                   (sm.getString("standardService.stop.notStarted"));
  +        }
           lifecycle.fireLifecycleEvent(STOP_EVENT, null);
   
           System.out.println
  @@ -467,9 +541,12 @@
           }
   
           // Stop our defined Container second
  -        synchronized (container) {
  -            if ((container != null) && (container instanceof Lifecycle))
  -                ((Lifecycle) container).stop();
  +        if (container != null) {
  +            synchronized (container) {
  +                if (container instanceof Lifecycle) {
  +                    ((Lifecycle) container).stop();
  +                }
  +            }
           }
   
       }
  
  
  
  1.7       +67 -75    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MBeanFactory.java	7 Feb 2002 19:18:40 -0000	1.6
  +++ MBeanFactory.java	6 Mar 2002 06:49:11 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.6 2002/02/07 19:18:40 amyroh Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/02/07 19:18:40 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.7 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -70,9 +70,11 @@
   import javax.management.ObjectInstance;
   import javax.management.RuntimeOperationsException;
   import org.apache.catalina.Container;
  +import org.apache.catalina.Context;
   import org.apache.catalina.Engine;
   import org.apache.catalina.Host;
   import org.apache.catalina.Server;
  +import org.apache.catalina.ServerFactory;
   import org.apache.catalina.Service;
   import org.apache.catalina.authenticator.SingleSignOn;
   import org.apache.catalina.core.StandardContext;
  @@ -104,7 +106,7 @@
    * <code>org.apache.catalina.core.StandardServer</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.6 $ $Date: 2002/02/07 19:18:40 $
  + * @version $Revision: 1.7 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public class MBeanFactory extends BaseModelMBean {
  @@ -599,32 +601,31 @@
        *
        * @param parent MBean Name of the associated parent component
        * @param path The context path for this Context
  +     * @param docBase Document base directory (or WAR) for this Context
        *
        * @exception Exception if an MBean cannot be created or registered
        */
  -    public String createStandardContext(String parent, String path)
  +    public String createStandardContext(String parent, String path,
  +                                        String docBase)
           throws Exception {
   
  -        String tname = "StandardHost";
  -        ManagedBean managed = registry.findManagedBean(tname);
  -        String domain = null;
  -        if (managed != null)
  -            domain = managed.getDomain();
  -        if (domain == null)
  -            domain = mserver.getDefaultDomain();
  -        ObjectName pname = new ObjectName(parent);
  -        Object obj = mserver.getAttribute(pname, "managedResource");
  -        Host host = null;
  -        if (obj instanceof Host) {
  -            host = (Host) obj;
  -        }
  +        // Create a new StandardContext instance
           StandardContext context = new StandardContext();
           context.setPath(path);
  -        context.setParent(host);
  -        ObjectName oname = MBeanUtils.createObjectName(domain, context);
  -        MBeanUtils.createMBean(context);
  -        context.setParent(null);
  +        context.setDocBase(docBase);
   
  +        // Add the new instance to its parent component
  +        ObjectName pname = new ObjectName(parent);
  +        Server server = ServerFactory.getServer();
  +        Service service = server.findService(pname.getKeyProperty("service"));
  +        Engine engine = (Engine) service.getContainer();
  +        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
  +        host.addChild(context);
  +
  +        // Return the corresponding MBean name
  +        ManagedBean managed = registry.findManagedBean("StandardContext");
  +        ObjectName oname =
  +            MBeanUtils.createObjectName(managed.getDomain(), context);
           return (oname.toString());
   
       }
  @@ -635,31 +636,30 @@
        * Create a new StandardEngine.
        *
        * @param parent MBean Name of the associated parent component
  +     * @param name Unique name of this Engine
  +     * @param defaultHost Default hostname of this Engine
        *
        * @exception Exception if an MBean cannot be created or registered
        */
  -    public String createStandardEngine(String parent)
  +    public String createStandardEngine(String parent, String name,
  +                                       String defaultHost)
           throws Exception {
   
  -        String tname = "StandardService";
  -        ManagedBean managed = registry.findManagedBean(tname);
  -        String domain = null;
  -        if (managed != null)
  -            domain = managed.getDomain();
  -        if (domain == null)
  -            domain = mserver.getDefaultDomain();
  -        ObjectName pname = new ObjectName(parent);
  -        Object obj = mserver.getAttribute(pname, "managedResource");
  -        StandardService service = null;
  -        if (obj instanceof StandardService) {
  -            service = (StandardService) obj;
  -        }
  +        // Create a new StandardEngine instance
           StandardEngine engine = new StandardEngine();
  -        engine.setService(service);
  -        ObjectName oname = MBeanUtils.createObjectName(domain, service);
  -        MBeanUtils.createMBean(engine);
  -        engine.setService(null);
  +        engine.setName(name);
  +        engine.setDefaultHost(defaultHost);
   
  +        // Add the new instance to its parent component
  +        ObjectName pname = new ObjectName(parent);
  +        Server server = ServerFactory.getServer();
  +        Service service = server.findService(pname.getKeyProperty("name"));
  +        service.setContainer(engine);
  +
  +        // Return the corresponding MBean name
  +        ManagedBean managed = registry.findManagedBean("StandardEngine");
  +        ObjectName oname =
  +            MBeanUtils.createObjectName(managed.getDomain(), engine);
           return (oname.toString());
   
       }
  @@ -670,32 +670,32 @@
        *
        * @param parent MBean Name of the associated parent component
        * @param name Unique name of this Host
  +     * @param appBase Application base directory name
  +     * @param unpackWARs Should we unpack WARs when auto deploying?
        *
        * @exception Exception if an MBean cannot be created or registered
        */
  -    public String createStandardHost(String parent, String name)
  +    public String createStandardHost(String parent, String name,
  +                                     String appBase, boolean unpackWARs)
           throws Exception {
   
  -        String tname = "StandardEngine";
  -        ManagedBean managed = registry.findManagedBean(tname);
  -        String domain = null;
  -        if (managed != null)
  -            domain = managed.getDomain();
  -        if (domain == null)
  -            domain = mserver.getDefaultDomain();
  -        ObjectName pname = new ObjectName(parent);
  -        Object obj = mserver.getAttribute(pname, "managedResource");
  -        Engine engine = null;
  -        if (obj instanceof Engine) {
  -            engine = (Engine) obj;
  -        }
  +        // Create a new StandardHost instance
           StandardHost host = new StandardHost();
           host.setName(name);
  -        host.setParent(engine);
  -        ObjectName oname = MBeanUtils.createObjectName(domain, host);
  -        MBeanUtils.createMBean(host);
  -        host.setParent(null);
  +        host.setAppBase(appBase);
  +        host.setUnpackWARs(unpackWARs);
   
  +        // Add the new instance to its parent component
  +        ObjectName pname = new ObjectName(parent);
  +        Server server = ServerFactory.getServer();
  +        Service service = server.findService(pname.getKeyProperty("service"));
  +        Engine engine = (Engine) service.getContainer();
  +        engine.addChild(host);
  +
  +        // Return the corresponding MBean name
  +        ManagedBean managed = registry.findManagedBean("StandardHost");
  +        ObjectName oname =
  +            MBeanUtils.createObjectName(managed.getDomain(), host);
           return (oname.toString());
   
       }
  @@ -748,26 +748,18 @@
       public String createStandardService(String parent, String name)
           throws Exception {
   
  -        String tname = "StandardServer";
  -        ManagedBean managed = registry.findManagedBean(tname);
  -        String domain = null;
  -        if (managed != null)
  -            domain = managed.getDomain();
  -        if (domain == null)
  -            domain = mserver.getDefaultDomain();
  -        ObjectName pname = new ObjectName(parent);
  -        Object obj = mserver.getAttribute(pname, "managedResource");
  -        StandardServer server = null;
  -        if (obj instanceof StandardServer) {
  -            server = (StandardServer) obj;
  -        }
  +        // Create a new StandardService instance
           StandardService service = new StandardService();
           service.setName(name);
  -        service.setServer(server);
  -        ObjectName oname = MBeanUtils.createObjectName(domain, service);
  -        MBeanUtils.createMBean(service);
  -        service.setServer(null);
   
  +        // Add the new instance to its parent component
  +        Server server = ServerFactory.getServer();
  +        server.addService(service);
  +
  +        // Return the corresponding MBean name
  +        ManagedBean managed = registry.findManagedBean("StandardService");
  +        ObjectName oname =
  +            MBeanUtils.createObjectName(managed.getDomain(), service);
           return (oname.toString());
   
       }
  
  
  
  1.21      +240 -25   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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ServerLifecycleListener.java	19 Feb 2002 22:16:00 -0000	1.20
  +++ ServerLifecycleListener.java	6 Mar 2002 06:49:11 -0000	1.21
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v 1.20 2002/02/19 22:16:00 craigmcc Exp $
  - * $Revision: 1.20 $
  - * $Date: 2002/02/19 22:16:00 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v 1.21 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.21 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -96,6 +96,8 @@
   import org.apache.catalina.core.StandardContext;
   import org.apache.catalina.core.StandardEngine;
   import org.apache.catalina.core.StandardHost;
  +import org.apache.catalina.core.StandardServer;
  +import org.apache.catalina.core.StandardService;
   
   
   /**
  @@ -105,7 +107,7 @@
    *
    * @author Craig R. McClanahan
    * @author Amy Roh
  - * @version $Revision: 1.20 $ $Date: 2002/02/19 22:16:00 $
  + * @version $Revision: 1.21 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public class ServerLifecycleListener
  @@ -220,7 +222,25 @@
                                                  event.getOldValue(),
                                                  event.getNewValue());
               } catch (Exception e) {
  -                log("Exception handling property change", e);
  +                log("Exception handling Container property change", e);
  +            }
  +        } else if (event.getSource() instanceof Server) {
  +            try {
  +                processServerPropertyChange((Server) event.getSource(),
  +                                            event.getPropertyName(),
  +                                            event.getOldValue(),
  +                                            event.getNewValue());
  +            } catch (Exception e) {
  +                log("Exception handing Server property change", e);
  +            }
  +        } else if (event.getSource() instanceof Service) {
  +            try {
  +                processServicePropertyChange((Service) event.getSource(),
  +                                             event.getPropertyName(),
  +                                             event.getOldValue(),
  +                                             event.getNewValue());
  +            } catch (Exception e) {
  +                log("Exception handing Service property change", e);
               }
           }
   
  @@ -258,6 +278,23 @@
   
   
       /**
  +     * Create the MBeans for the specified Connector and its nested components.
  +     *
  +     * @param connector Connector for which to create MBeans
  +     *
  +     * @exception Exception if an exception is thrown during MBean creation
  +     */
  +    protected void createMBeans(Connector connector) throws Exception {
  +
  +        // Create the MBean for the Connnector itself
  +        if (debug >= 5)
  +            log("Creating MBean for Connector " + connector);
  +        MBeanUtils.createMBean(connector);
  +
  +    }
  +
  +
  +    /**
        * Create the MBeans for the specified Context and its nested components.
        *
        * @param context Context for which to create MBeans
  @@ -465,6 +502,9 @@
           if (debug >= 2)
               log("Creating MBean for Server " + server);
           MBeanUtils.createMBean(server);
  +        if (server instanceof StandardServer) {
  +            ((StandardServer) server).addPropertyChangeListener(this);
  +        }
   
           // Create the MBeans for each child Service
           Service services[] = server.findServices();
  @@ -496,37 +536,46 @@
           if (debug >= 2)
               log("Creating MBean for Service " + service);
           MBeanUtils.createMBean(service);
  +        if (service instanceof StandardService) {
  +            ((StandardService) service).addPropertyChangeListener(this);
  +        }
   
           // Create the MBeans for the corresponding Connectors
           Connector connectors[] = service.findConnectors();
           for (int j = 0; j < connectors.length; j++) {
  -            if (debug >= 2)
  -                log("Creating MBean for Connector " + connectors[j]);
  -            MBeanUtils.createMBean(connectors[j]);
  +            createMBeans(connectors[j]);
           }
   
           // Create the MBean for the associated Engine and friends
           Engine engine = (Engine) service.getContainer();
  -        createMBeans(engine);
  +        if (engine != null) {
  +            createMBeans(engine);
  +        }
   
       }
   
   
       /**
  -     * Log a message.
  +     * Deregister the MBeans for the specified Connector and its nested
  +     * components.
        *
  -     * @param message The message to be logged
  +     * @param connector Connector for which to deregister MBeans
  +     *
  +     * @exception Exception if an exception is thrown during MBean creation
        */
  -    protected void log(String message) {
  +    protected void destroyMBeans(Connector connector) throws Exception {
   
  -        System.out.print("ServerLifecycleListener: ");
  -        System.out.println(message);
  +        // deregister the MBean for the Connector itself
  +        if (debug >= 5)
  +            log("Destroying MBean for Connector " + connector);
  +        MBeanUtils.destroyMBean(connector);
   
       }
   
   
       /**
  -     * Deregister the MBeans for the specified Context and its nested components.
  +     * Deregister the MBeans for the specified Context and its nested
  +     * components.
        *
        * @param context Context for which to deregister MBeans
        *
  @@ -589,6 +638,58 @@
   
   
       /**
  +     * Deregister the MBeans for the specified Engine and its nested
  +     * components.
  +     *
  +     * @param engine Engine for which to destroy MBeans
  +     *
  +     * @exception Exception if an exception is thrown during MBean creation
  +     */
  +    protected void destroyMBeans(Engine engine) throws Exception {
  +
  +        // Deregister the MBean for the Engine itself
  +        if (debug >= 2) {
  +            log("Destroying MBean for Engine " + engine);
  +        }
  +        MBeanUtils.destroyMBean(engine);
  +
  +        // Deregister the MBeans for the associated nested components
  +        Logger eLogger = engine.getLogger();
  +        if (eLogger != null) {
  +            if (debug >= 3)
  +                log("Destroying MBean for Logger " + eLogger);
  +            MBeanUtils.destroyMBean(eLogger);
  +        }
  +        Realm eRealm = engine.getRealm();
  +        if (eRealm != null) {
  +            if (debug >= 3)
  +                log("Destroying MBean for Realm " + eRealm);
  +            MBeanUtils.destroyMBean(eRealm);
  +        }
  +
  +        // Deregister the MBeans for the associated Valves
  +        if (engine instanceof StandardEngine) {
  +            Valve eValves[] = ((StandardEngine)engine).getValves();
  +            for (int k = 0; k < eValves.length; k++) {
  +                if (debug >= 3)
  +                    log("Destroying MBean for Valve " + eValves[k]);
  +                MBeanUtils.destroyMBean(eValves[k]);
  +            }
  +        }
  +
  +        // Deregister the MBeans for each child Host
  +        Container hosts[] = engine.findChildren();
  +        for (int k = 0; k < hosts.length; k++) {
  +            destroyMBeans((Host) hosts[k]);
  +        }
  +
  +        // Deregister ourselves as a ContainerListener
  +        engine.removeContainerListener(this);
  +
  +    }
  +
  +
  +    /**
        * Deregister the MBeans for the specified Host and its nested components.
        *
        * @param host Host for which to destroy MBeans
  @@ -642,6 +743,53 @@
   
   
       /**
  +     * Deregister the MBeans for the specified Service and its nested
  +     * components.
  +     *
  +     * @param service Service for which to destroy MBeans
  +     *
  +     * @exception Exception if an exception is thrown during MBean creation
  +     */
  +    protected void destroyMBeans(Service service) throws Exception {
  +
  +        // Deregister the MBean for the Service itself
  +        if (debug >= 2) {
  +            log("Destroying MBean for Service " + service);
  +        }
  +        MBeanUtils.destroyMBean(service);
  +        if (service instanceof StandardService) {
  +            ((StandardService) service).removePropertyChangeListener(this);
  +        }
  +
  +        // Deregister the MBeans for the corresponding Connectors
  +        Connector connectors[] = service.findConnectors();
  +        for (int j = 0; j < connectors.length; j++) {
  +            destroyMBeans(connectors[j]);
  +        }
  +
  +        // Deregister the MBeans for the associated Engine
  +        Engine engine = (Engine) service.getContainer();
  +        if (engine != null) {
  +            destroyMBeans(engine);
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Log a message.
  +     *
  +     * @param message The message to be logged
  +     */
  +    protected void log(String message) {
  +
  +        System.out.print("ServerLifecycleListener: ");
  +        System.out.println(message);
  +
  +    }
  +
  +
  +    /**
        * Log a message and associated exception.
        *
        * @param message The message to be logged
  @@ -798,19 +946,11 @@
                   MBeanUtils.createMBean((Realm) newValue);
               }
           } else if ("service".equals(propertyName)) {
  -            // removeService() has non-null oldValue
               if (oldValue != null) {
  -                if (debug >= 5) {
  -                    log("Removing MBean for Service " + oldValue);
  -                }
  -                MBeanUtils.destroyMBean((Service) oldValue);
  +                destroyMBeans((Service) oldValue);
               }
  -            // addService() has non-null newValue
               if (newValue != null) {
  -                if (debug >= 5) {
  -                    log("Creating MBean for Service " + newValue);
  -                }
  -                MBeanUtils.createMBean((Service) newValue);
  +                createMBeans((Service) newValue);
               }
           }
   
  @@ -888,6 +1028,81 @@
               log("processContainerRemoveValve: MBeanException", e);
           } catch (Throwable t) {
               log("processContainerRemoveValve: Throwable", t);
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Process a property change event on a Server.
  +     *
  +     * @param server The server on which this event occurred
  +     * @param propertyName The name of the property that changed
  +     * @param oldValue The previous value (may be <code>null</code>)
  +     * @param newValue The new value (may be <code>null</code>)
  +     *
  +     * @exception Exception if an exception is thrown
  +     */
  +    protected void processServerPropertyChange(Server server,
  +                                               String propertyName,
  +                                               Object oldValue,
  +                                               Object newValue)
  +        throws Exception {
  +
  +        if (debug >= 6) {
  +            log("propertyChange[server=" + server +
  +                ",propertyName=" + propertyName +
  +                ",oldValue=" + oldValue +
  +                ",newValue=" + newValue + "]");
  +        }
  +        if ("service".equals(propertyName)) {
  +            if (oldValue != null) {
  +                destroyMBeans((Service) oldValue);
  +            }
  +            if (newValue != null) {
  +                createMBeans((Service) newValue);
  +            }
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Process a property change event on a Service.
  +     *
  +     * @param service The service on which this event occurred
  +     * @param propertyName The name of the property that changed
  +     * @param oldValue The previous value (may be <code>null</code>)
  +     * @param newValue The new value (may be <code>null</code>)
  +     *
  +     * @exception Exception if an exception is thrown
  +     */
  +    protected void processServicePropertyChange(Service service,
  +                                                String propertyName,
  +                                                Object oldValue,
  +                                                Object newValue)
  +        throws Exception {
  +
  +        if (debug >= 6) {
  +            log("propertyChange[service=" + service +
  +                ",propertyName=" + propertyName +
  +                ",oldValue=" + oldValue +
  +                ",newValue=" + newValue + "]");
  +        }
  +        if ("connector".equals(propertyName)) {
  +            if (oldValue != null) {
  +                destroyMBeans((Connector) oldValue);
  +            }
  +            if (newValue != null) {
  +                createMBeans((Connector) newValue);
  +            }
  +        } else if ("container".equals(propertyName)) {
  +            if (oldValue != null) {
  +                destroyMBeans((Engine) oldValue);
  +            }
  +            if (newValue != null) {
  +                createMBeans((Engine) newValue);
  +            }
           }
   
       }
  
  
  
  1.33      +27 -8     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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- mbeans-descriptors.xml	19 Feb 2002 02:15:27 -0000	1.32
  +++ mbeans-descriptors.xml	6 Mar 2002 06:49:11 -0000	1.33
  @@ -6,7 +6,7 @@
   <!--
        Descriptions of JMX MBeans for Catalina
   
  -     $Id: mbeans-descriptors.xml,v 1.32 2002/02/19 02:15:27 craigmcc Exp $
  +     $Id: mbeans-descriptors.xml,v 1.33 2002/03/06 06:49:11 craigmcc Exp $
    -->
   
   <mbeans-descriptors>
  @@ -76,14 +76,14 @@
                    type="java.lang.String"
               writeable="false"/>
   
  -    <attribute   name="debug"
  -          description="The debugging detail level for this component"
  -                 type="int"/>
  -
       <attribute   name="connectionTimeout"
             description="Timeout value on the incoming connection"
                    type="int"/>
   
  +    <attribute   name="debug"
  +          description="The debugging detail level for this component"
  +                 type="int"/>
  +
       <attribute   name="enableLookups"
             description="The 'enable DNS lookups' flag for this Connector"
                    type="boolean"/>
  @@ -1060,7 +1060,10 @@
             description="MBean Name of the associated parent component"
                    type="java.lang.String"/>
         <parameter name="path"
  -          description="path The context path for this Context"
  +          description="The context path for this Context"
  +                 type="java.lang.String"/>
  +      <parameter name="docBase"
  +          description="Document base directory (or WAR) for ths Context"
                    type="java.lang.String"/>
       </operation>
   
  @@ -1071,18 +1074,30 @@
         <parameter name="parent"
             description="MBean Name of the associated parent component"
                    type="java.lang.String"/>
  +      <parameter name="name"
  +          description="Unique name of this Engine"
  +                 type="java.lang.String"/>
  +      <parameter name="defaultHost"
  +          description="Default host name for this Engine"
  +                 type="java.lang.String"/>
       </operation>
   
       <operation   name="createStandardHost"
             description="Create a new StandardHost"
                  impact="ACTION"
              returnType="java.lang.String">
  +      <parameter name="parent"
  +          description="MBean Name of the associated parent component"
  +                 type="java.lang.String"/>
         <parameter name="name"
             description="Unique name of this Host"
                    type="java.lang.String"/>
  -      <parameter name="parent"
  -          description="MBean Name of the associated parent component"
  +      <parameter name="appBase"
  +          description="Application base directory for this Host"
                    type="java.lang.String"/>
  +      <parameter name="unpackWARs"
  +          description="Should we unpack WARs when auto-deploying?"
  +                 type="boolean"/>
       </operation>
   
       <operation   name="createStandardManager"
  @@ -1948,6 +1963,10 @@
                  domain="Catalina"
                   group="Service"
                    type="org.apache.catalina.core.StandardService">
  +
  +    <attribute   name="debug"
  +          description="The debugging detail level for this component"
  +                 type="int"/>
   
       <attribute   name="managedResource"
             description="The managed resource this MBean is associated with"
  
  
  
  1.11      +3 -1      jakarta-tomcat-4.0/webapps/admin/server.jsp
  
  Index: server.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/server.jsp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- server.jsp	14 Feb 2002 20:37:21 -0000	1.10
  +++ server.jsp	6 Mar 2002 06:49:11 -0000	1.11
  @@ -30,8 +30,10 @@
           <controls:actions>
               <controls:action selected="true"> ----<bean:message key="actions.available.actions"/>---- </controls:action>
               <controls:action> --------------------------------- </controls:action>
  -            <controls:action url="setUpAddService.do">  <bean:message key="actions.services.create"/> </controls:action>
  +            <controls:action url="AddService.do">  <bean:message key="actions.services.create"/> </controls:action>
  +            <%--
               <controls:action url="setUpDeleteService.do">  <bean:message key="actions.services.delete"/> </controls:action>
  +            --%>
           </controls:actions>
           </div>
         </td>
  
  
  
  1.33      +31 -31    jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- struts-config.xml	15 Feb 2002 21:04:37 -0000	1.32
  +++ struts-config.xml	6 Mar 2002 06:49:11 -0000	1.33
  @@ -27,10 +27,6 @@
       <form-bean      name="deleteServiceForm"
                       type="org.apache.webapp.admin.service.DeleteServiceForm"/>
   
  -    <!-- Add Service form bean -->
  -    <form-bean      name="addServiceForm"
  -                    type="org.apache.webapp.admin.service.AddServiceForm"/>
  -
       <!-- Connector form bean -->
       <form-bean      name="connectorForm"
                       type="org.apache.webapp.admin.connector.ConnectorForm"/>
  @@ -137,10 +133,6 @@
                       path="/service/deleteService.jsp"
                   redirect="false"/>
   
  -    <forward        name="Add Service"
  -                    path="/service/addService.jsp"
  -                redirect="false"/>
  -
       <forward        name="Connector"
                       path="/connector.jsp"
                   redirect="false"/>
  @@ -270,34 +262,13 @@
                     redirect="true"/>
       </action>
   
  -    <!-- Set up Server -->
  +    <!-- Set up Edit Server transaction -->
       <action    path="/setUpServer"
                  type="org.apache.webapp.admin.SetUpServerAction"
                  name="serverForm"
                  scope="session">
       </action>
   
  -   <!-- Set up Service datastructure -->
  -    <action    path="/setUpService"
  -               type="org.apache.webapp.admin.service.SetUpServiceAction"
  -               name="serviceForm"
  -               scope="session">
  -    </action>
  -
  -   <!-- Set up Delete Service datastructure -->
  -    <action    path="/setUpDeleteService"
  -               type="org.apache.webapp.admin.service.SetUpDeleteServiceAction"
  -               name="deleteServiceForm"
  -               scope="session">
  -    </action>
  -        
  -    <!-- Set up Add Service datastructure -->
  -    <action    path="/setUpAddService"
  -               type="org.apache.webapp.admin.service.SetUpAddServiceAction"
  -               name="addServiceForm"
  -               scope="session">
  -    </action>
  -    
      <!-- Set up Connector datastructure -->
       <action    path="/setUpConnector"
                  type="org.apache.webapp.admin.connector.SetUpConnectorAction"
  @@ -461,7 +432,7 @@
       <!-- Add service action -->
       <action    path="/addService"
                 input="/service/addService.jsp"
  -               name="addServiceForm"
  +               name="serviceForm"
                 scope="request"
                  type="org.apache.webapp.admin.service.AddServiceAction"/>
   
  @@ -493,7 +464,36 @@
                  scope="session"
                  input="/realm/userDBRealm.jsp"/>
   
  +    <!-- ============= Service Module ============== -->
  +
  +    <!-- Set up Add Service transaction -->
  +    <action    path="/AddService"
  +               type="org.apache.webapp.admin.service.AddServiceAction"
  +               name="serviceForm"
  +               scope="request">
  +    </action>
  +
  +    <!-- Set up Edit Service transaction -->
  +    <action    path="/EditService"
  +               type="org.apache.webapp.admin.service.EditServiceAction"
  +               name="serviceForm"
  +               scope="request">
  +    </action>
   
  +    <!-- Perform Save Service transaction -->
  +    <action    path="/SaveService"
  +               type="org.apache.webapp.admin.service.SaveServiceAction"
  +               name="serviceForm"
  +               scope="request"/>
  +
  +
  +    <!-- FIXME - Set up Delete Service transaction -->
  +    <action    path="/setUpDeleteService"
  +               type="org.apache.webapp.admin.service.SetUpDeleteServiceAction"
  +               name="deleteServiceForm"
  +               scope="request">
  +    </action>
  +        
       <!-- ========== User Database Module ========== -->
   
       <action    path="/users/deleteGroups"
  
  
  
  1.3       +7 -4      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ActionTag.java
  
  Index: ActionTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ActionTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ActionTag.java	30 Jan 2002 02:05:44 -0000	1.2
  +++ ActionTag.java	6 Mar 2002 06:49:11 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ActionTag.java,v 1.2 2002/01/30 02:05:44 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/30 02:05:44 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ActionTag.java,v 1.3 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -92,7 +92,7 @@
    * <strong>FIXME</strong> - Internationalize the exception messages!
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/01/30 02:05:44 $
  + * @version $Revision: 1.3 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public class ActionTag extends BodyTagSupport {
  @@ -184,6 +184,9 @@
   
           // Find our parent ActionsTag instance
           Tag parent = getParent();
  +        while ((parent != null) && !(parent instanceof ActionsTag)) {
  +            parent = parent.getParent();
  +        }
           if ((parent == null) || !(parent instanceof ActionsTag))
               throw new JspException("Must be nested in an ActionsTag isntance");
           ActionsTag actions = (ActionsTag) parent;
  
  
  
  1.30      +10 -3     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties
  
  Index: ApplicationResources_en.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ApplicationResources_en.properties	27 Feb 2002 05:40:57 -0000	1.29
  +++ ApplicationResources_en.properties	6 Mar 2002 06:49:11 -0000	1.30
  @@ -25,7 +25,7 @@
   server.portnumber=Port Number
   server.debuglevel=Debug Level
   server.shutdown=Shutdown
  -server.properties=Properties
  +server.properties=Server Properties
   error.portNumber.required=<li>PortNumber cannot be empty</li>
   error.portNumber.format=<li>PortNumber not a valid integer!</li>
   error.portNumber.range=<li>PortNumber seems out of range. Valid range is 1-65535. </li>
  @@ -58,7 +58,7 @@
   error.hostName.exists=<li>Hostname already exists</li>
   error.appBase.required=<li>Application Base is required</li>
   service.name=Name
  -service.engine.props=Engine properties
  +service.engine.props=Engine Properties
   service.defaulthostname=Default Hostname
   service.properties=Service Properties
   service.property=Property
  @@ -66,7 +66,8 @@
   service.create.new=Create New Service
   actions.available.actions=Available Actions
   actions.services.create=Create New Service
  -actions.services.delete=Delete Services
  +actions.services.delete=Delete This Service
  +actions.services.edit=Edit Existing Service
   actions.accesslogger.create=Create New Access Logger
   actions.accesslogger.delete=Delete Access Logger
   actions.connector.create=Create New Connector
  @@ -203,6 +204,12 @@
   error.connPassword.required=<li>Connection password is required.</li>
   error.connURL.required=<li>Connection URL is required.</li>
   error.connName.required=<li>Connection name is required.</li>
  +
  +# ------------- Service Module -------------
  +services.actions.create=Create New Service
  +services.actions.delete=Delete Existing Services
  +services.actions.edit=Edit Existing Service
  +# ------------- ------- ------ -------------
   
   # ---------- User Database Module ----------
   users.actions.group.create=Create New Group
  
  
  
  1.3       +7 -5      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LabelValueBean.java
  
  Index: LabelValueBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LabelValueBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LabelValueBean.java	10 Jan 2002 03:41:13 -0000	1.2
  +++ LabelValueBean.java	6 Mar 2002 06:49:11 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LabelValueBean.java,v 1.2 2002/01/10 03:41:13 patrickl Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/10 03:41:13 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LabelValueBean.java,v 1.3 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -62,15 +62,17 @@
   
   package org.apache.webapp.admin;
   
  +import java.io.Serializable;
  +
   /**
    * Simple JavaBean to represent label-value pairs for use in collections
    * that are utilized by the <code>&lt;form:options&gt;</code> tag.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/01/10 03:41:13 $
  + * @version $Revision: 1.3 $ $Date: 2002/03/06 06:49:11 $
    */
   
  -public class LabelValueBean {
  +public class LabelValueBean implements Serializable {
   
   
       // ----------------------------------------------------------- Constructors
  
  
  
  1.17      +6 -6      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java
  
  Index: TomcatTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TomcatTreeBuilder.java	15 Feb 2002 21:04:37 -0000	1.16
  +++ TomcatTreeBuilder.java	6 Mar 2002 06:49:11 -0000	1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.16 2002/02/15 21:04:37 manveen Exp $
  - * $Revision: 1.16 $
  - * $Date: 2002/02/15 21:04:37 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.17 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.17 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    *
    * @author Jazmin Jonson
    * @author Manveen Kaur
  - * @version $Revision: 1.16 $ $Date: 2002/02/15 21:04:37 $
  + * @version $Revision: 1.17 $ $Date: 2002/03/06 06:49:11 $
    */
   
   
  @@ -205,7 +205,7 @@
               new TreeControlNode(service.getObjectName().toString(),
               "folder_16_pad.gif",
               nodeLabel,
  -            "setUpService.do?select=" + encodedServiceName
  +            "EditService.do?select=" + encodedServiceName
               +"&nodeLabel=" + encodedNodeLabel,
               "content", true);
               
  @@ -331,7 +331,7 @@
               nodeLabel,
               "setUpContext.do?select=" + encodedContextName
               +"&nodeLabel="+ encodedNodeLabel,
  -            "content", true);
  +            "content", false);
               
               hostNode.addChild(contextNode);
               //get all loggers for this context
  
  
  
  1.3       +125 -10   jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceForm.java
  
  Index: ServiceForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceForm.java	14 Feb 2002 20:37:21 -0000	1.2
  +++ ServiceForm.java	6 Mar 2002 06:49:11 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceForm.java,v 1.2 2002/02/14 20:37:21 manveen Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/14 20:37:21 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceForm.java,v 1.3 2002/03/06 06:49:11 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/03/06 06:49:11 $
    *
    * ====================================================================
    *
  @@ -73,13 +73,32 @@
    * Form bean for the service page.
    *
    * @author Manveen Kaur
  - * @version $Revision: 1.2 $ $Date: 2002/02/14 20:37:21 $
  + * @version $Revision: 1.3 $ $Date: 2002/03/06 06:49:11 $
    */
   
   public final class ServiceForm extends ActionForm {
       
       // ----------------------------------------------------- Instance Variables
       
  +
  +    /**
  +     * The administrative action represented by this form.
  +     */
  +    private String adminAction = "Edit";
  +
  +
  +    /**
  +     * The object name of the Engine this bean refers to.
  +     */
  +    private String engineObjectName = null;
  +
  +
  +    /**
  +     * The object name of the Service this bean refers to.
  +     */
  +    private String objectName = null;
  +
  +
       /**
        * The text for the serviceName.
        */
  @@ -104,13 +123,76 @@
       /**
        * The text for the defaultHost Name.
        */
  -    private String defaultHost = " ";
  +    private String defaultHost = "";
       
       private ArrayList debugLvlVals = null;
       private ArrayList hostNameVals = null;
  +
  +
       // ------------------------------------------------------------- Properties
       
  -       /**
  +
  +    /**
  +     * Return the administrative action represented by this form.
  +     */
  +    public String getAdminAction() {
  +
  +        return this.adminAction;
  +
  +    }
  +
  +
  +    /**
  +     * Set the administrative action represented by this form.
  +     */
  +    public void setAdminAction(String adminAction) {
  +
  +        this.adminAction = adminAction;
  +
  +    }
  +
  +
  +    /**
  +     * Return the object name of the Engine this bean refers to.
  +     */
  +    public String getEngineObjectName() {
  +
  +        return this.engineObjectName;
  +
  +    }
  +
  +
  +    /**
  +     * Set the object name of the Engine this bean refers to.
  +     */
  +    public void setEngineObjectName(String engineObjectName) {
  +
  +        this.engineObjectName = engineObjectName;
  +
  +    }
  +
  +
  +    /**
  +     * Return the object name of the Service this bean refers to.
  +     */
  +    public String getObjectName() {
  +
  +        return this.objectName;
  +
  +    }
  +
  +
  +    /**
  +     * Set the object name of the Service this bean refers to.
  +     */
  +    public void setObjectName(String objectName) {
  +
  +        this.objectName = objectName;
  +
  +    }
  +
  +
  +    /**
        * Return the label of the node that was clicked.
        */
       public String getNodeLabel() {
  @@ -236,10 +318,16 @@
        * Set the default Host.
        */
       public void setDefaultHost(String defaultHost) {
  -        
  -        this.defaultHost = defaultHost;
  -        
  +
  +        if (defaultHost == null) {
  +            this.defaultHost = "";
  +        } else {
  +            this.defaultHost = defaultHost;
  +        }
  +
       }
  +
  +
       // --------------------------------------------------------- Public Methods
       
       /**
  @@ -250,12 +338,39 @@
        */
       public void reset(ActionMapping mapping, HttpServletRequest request) {
           
  +        this.engineObjectName = null;
  +        this.objectName = null;
           this.serviceName = null;
           this.engineName = null;
           this.debugLvl = "0";
  -        this.defaultHost = " ";
  +        this.defaultHost = "";
       }
       
  +    /**
  +     * Render this object as a String.
  +     */
  +    public String toString() {
  +
  +        StringBuffer sb = new StringBuffer("ServiceForm[adminAction=");
  +        sb.append(adminAction);
  +        sb.append(",debugLvl=");
  +        sb.append(debugLvl);
  +        sb.append(",defaultHost=");
  +        sb.append(defaultHost);
  +        sb.append(",engineName=");
  +        sb.append(engineName);
  +        sb.append(",engineObjectName='");
  +        sb.append(engineObjectName);
  +        sb.append("',objectName='");
  +        sb.append(objectName);
  +        sb.append("',serviceName=");
  +        sb.append(serviceName);
  +        sb.append("]");
  +        return (sb.toString());
  +
  +    }
  +
  +
       /**
        * Validate the properties that have been set from this HTTP request,
        * and return an <code>ActionErrors</code> object that encapsulates any
  
  
  
  1.1                  jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/EditServiceAction.java
  
  Index: EditServiceAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/EditServiceAction.java,v 1.1 2002/03/06 06:49:11 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/06 06:49:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.webapp.admin.service;
  
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Locale;
  import java.util.ArrayList;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  import javax.management.MBeanServer;
  import javax.management.ObjectInstance;
  import javax.management.ObjectName;
  import javax.management.JMException;
  
  import org.apache.struts.util.MessageResources;
  
  import org.apache.webapp.admin.LabelValueBean;
  import org.apache.webapp.admin.ApplicationServlet;
  import org.apache.webapp.admin.TomcatTreeBuilder;
  
  /**
   * The <code>Action</code> that sets up <em>Edit Service</em> transactions.
   *
   * @author Manveen Kaur
   * @version $Revision: 1.1 $ $Date: 2002/03/06 06:49:11 $
   */
  
  public class EditServiceAction extends Action {
      
  
      /**
       * The MBeanServer we will be interacting with.
       */
      private MBeanServer mBServer = null;
      
  
      /**
       * The MessageResources we will be retrieving messages from.
       */
      private MessageResources resources = null;
      
      private ArrayList debugLvlList = null;
      private ArrayList hostNameList = null;
      
      
      // --------------------------------------------------------- Public Methods
      
      /**
       * Process the specified HTTP request, and create the corresponding HTTP
       * response (or forward to another web component that will create it).
       * Return an <code>ActionForward</code> instance describing where and how
       * control should be forwarded, or <code>null</code> if the response has
       * already been completed.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
          throws IOException, ServletException {
          
          // Initialize our debug levels list
          if (debugLvlList == null) {
               debugLvlList = new ArrayList();
               debugLvlList.add(new LabelValueBean("0", "0"));
               debugLvlList.add(new LabelValueBean("1", "1"));
               debugLvlList.add(new LabelValueBean("2", "2"));
               debugLvlList.add(new LabelValueBean("3", "3"));
               debugLvlList.add(new LabelValueBean("4", "4"));
               debugLvlList.add(new LabelValueBean("5", "5"));
               debugLvlList.add(new LabelValueBean("6", "6"));
               debugLvlList.add(new LabelValueBean("7", "7"));
               debugLvlList.add(new LabelValueBean("8", "8"));
               debugLvlList.add(new LabelValueBean("9", "9"));
          }
          
          // Acquire the resources that we need
          HttpSession session = request.getSession();
          Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
          if (resources == null) {
              resources = getServlet().getResources();
          }
          
          // Acquire a reference to the MBeanServer containing our MBeans
          try {
              mBServer = ((ApplicationServlet) getServlet()).getServer();
          } catch (Throwable t) {
              throw new ServletException
              ("Cannot acquire MBeanServer reference", t);
          }
          
          // Set up the object names of the MBeans we are manipulating
          ObjectName sname = null;
          ObjectName ename = null;
          StringBuffer sb = null;
          try {
              sname = new ObjectName(request.getParameter("select"));
          } catch (Exception e) {
              String message = "Invalid service name '" +
                  request.getParameter("select") + "'";
              getServlet().log(message);
              response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
              return (null);
          }
          try {
              sb = new StringBuffer(sname.getDomain());
              sb.append(":type=Engine,service=");
              sb.append(sname.getKeyProperty("name"));
              ename = new ObjectName(sb.toString());
          } catch (Exception e) {
              String message = "Invalid engine name '" +
                  sb.toString() + "'";
              getServlet().log(message);
              response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
          }
  
          // Fill in the form values for display and editing
          ServiceForm serviceFm = new ServiceForm();
          request.setAttribute(mapping.getAttribute(), serviceFm);
          serviceFm.setAdminAction("Edit");
          serviceFm.setObjectName(sname.toString());
          serviceFm.setEngineObjectName(ename.toString());
          sb = new StringBuffer("Service (");
          sb.append(sname.getKeyProperty("name"));
          sb.append(")");
          serviceFm.setNodeLabel(sb.toString());
          serviceFm.setDebugLvlVals(debugLvlList);
          String attribute = null;
          try {
  
              // Copy scalar properties
              attribute = "name";
              serviceFm.setServiceName
                  ((String) mBServer.getAttribute(sname, attribute));
              attribute = "name";
              serviceFm.setEngineName
                  ((String) mBServer.getAttribute(ename, attribute));
              attribute = "debug";
              serviceFm.setDebugLvl
                  (((Integer) mBServer.getAttribute(ename, attribute)).toString());
              attribute = "defaultHost";
              serviceFm.setDefaultHost
                  ((String) mBServer.getAttribute(ename, attribute));
  
              // Build the list of available hosts
              ArrayList hosts = new ArrayList();
              hosts.add(new LabelValueBean("---------",""));
              attribute = "hosts";
              sb = new StringBuffer(TomcatTreeBuilder.HOST_TYPE);
              sb.append(TomcatTreeBuilder.WILDCARD);
              sb.append(",service=");
              sb.append(sname.getKeyProperty("name"));
              String search = sb.toString();
              Iterator hnames =
                  mBServer.queryNames(new ObjectName(search), null).iterator();
              while (hnames.hasNext()) {
                  ObjectName hname = (ObjectName) hnames.next();
                  String hostName =
                      (String) mBServer.getAttribute(hname, "name");
                  hosts.add(new LabelValueBean(hostName, hostName));
              }
              serviceFm.setHostNameVals(hosts);
  
          } catch (Throwable t) {
              getServlet().log
                  (resources.getMessage(locale, "users.error.attribute.get",
                                        attribute), t);
              response.sendError
                  (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                   resources.getMessage(locale, "users.error.attribute.get",
                                        attribute));
              return (null);
          }
          
          // Forward to the service display page
          return (mapping.findForward("Service"));
          
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/SaveServiceAction.java
  
  Index: SaveServiceAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/SaveServiceAction.java,v 1.1 2002/03/06 06:49:11 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/06 06:49:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.webapp.admin.service;
  
  
  import java.net.URLEncoder;
  import java.util.Iterator;
  import java.util.Locale;
  import java.io.IOException;
  import javax.management.Attribute;
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.management.QueryExp;
  import javax.management.Query;
  import javax.management.ObjectInstance;
  import javax.management.ObjectName;
  import javax.management.JMException;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.util.MessageResources;
  import org.apache.webapp.admin.ApplicationServlet;
  import org.apache.webapp.admin.TomcatTreeBuilder;
  import org.apache.webapp.admin.TreeControl;
  import org.apache.webapp.admin.TreeControlNode;
  
  
  
  /**
   * The <code>Action</code> that completes <em>Add Service</em> and
   * <em>Edit Service</em> transactions.
   *
   * @author Manveen Kaur
   * @version $Revision: 1.1 $ $Date: 2002/03/06 06:49:11 $
   */
  
  public final class SaveServiceAction extends Action {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * Signature for the <code>createStandardEngine</code> operation.
       */
      private String createStandardEngineTypes[] =
      { "java.lang.String",     // parent
        "java.lang.String",     // name
        "java.lang.String",     // defaultHost
      };
  
  
      /**
       * Signature for the <code>createStandardService</code> operation.
       */
      private String createStandardServiceTypes[] =
      { "java.lang.String",     // parent
        "java.lang.String",     // name
      };
  
  
      /**
       * The MBeanServer we will be interacting with.
       */
      private MBeanServer mBServer = null;
      
  
      /**
       * The MessageResources we will be retrieving messages from.
       */
      private MessageResources resources = null;
  
  
      // --------------------------------------------------------- Public Methods
      
      
      /**
       * Process the specified HTTP request, and create the corresponding HTTP
       * response (or forward to another web component that will create it).
       * Return an <code>ActionForward</code> instance describing where and how
       * control should be forwarded, or <code>null</code> if the response has
       * already been completed.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
          throws IOException, ServletException {
          
          // Acquire the resources that we need
          HttpSession session = request.getSession();
          Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
          if (resources == null) {
              resources = getServlet().getResources();
          }
          
          // Acquire a reference to the MBeanServer containing our MBeans
          try {
              mBServer = ((ApplicationServlet) getServlet()).getServer();
          } catch (Throwable t) {
              throw new ServletException
              ("Cannot acquire MBeanServer reference", t);
          }
          
          // Identify the requested action
          ServiceForm sform = (ServiceForm) form;
          String adminAction = sform.getAdminAction();
          String sObjectName = sform.getObjectName();
          String eObjectName = sform.getEngineObjectName();
  
          // Perform a "Create Service" transaction (if requested)
          if ("Create".equals(adminAction)) {
  
              String operation = null;
              String values[] = null;
  
              try {
  
                  // Look up our MBeanFactory MBean
                  ObjectName fname =
                      new ObjectName(TomcatTreeBuilder.FACTORY_TYPE);
  
                  // Create a new StandardService object
                  values = new String[2];
                  values[0] = TomcatTreeBuilder.SERVER_TYPE;
                  values[1] = sform.getServiceName();
                  operation = "createStandardService";
                  sObjectName = (String)
                      mBServer.invoke(fname, operation,
                                      values, createStandardServiceTypes);
  
                  // Create a new StandardEngine object
                  values = new String[3];
                  values[0] = sObjectName;
                  values[1] = sform.getEngineName();
                  values[2] = sform.getDefaultHost();
                  if ("".equals(values[2])) {
                      values[2] = null;
                  }
                  operation = "createStandardEngine";
                  eObjectName = (String)
                      mBServer.invoke(fname, operation,
                                      values, createStandardEngineTypes);
  
                  // Add the new Service to our tree control node
                  TreeControl control = (TreeControl)
                      session.getAttribute("treeControlTest");
                  if (control != null) {
                      String parentName = TomcatTreeBuilder.SERVER_TYPE;
                      TreeControlNode parentNode = control.findNode(parentName);
                      if (parentNode != null) {
                          String nodeLabel =
                              "Service (" + sform.getServiceName() + ")";
                          String encodedName =
                              URLEncoder.encode(sObjectName);
                          TreeControlNode childNode =
                              new TreeControlNode(sObjectName,
                                                  "folder_16_pad.gif",
                                                  nodeLabel,
                                                  "EditService.do?select=" +
                                                  encodedName,
                                                  "content",
                                                  true);
                          parentNode.addChild(childNode);
                          // FIXME - force a redisplay
                      } else {
                          getServlet().log
                              ("Cannot find parent node '" + parentName + "'");
                      }
                  } else {
                      getServlet().log
                          ("Cannot find TreeControlNode!");
                  }
  
              } catch (Exception e) {
  
                  getServlet().log
                      (resources.getMessage(locale, "users.error.invoke",
                                            operation), e);
                  response.sendError
                      (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                       resources.getMessage(locale, "users.error.invoke",
                                            operation));
                  return (null);
  
              }
  
          }
  
          // Perform attribute updates as requested
          String attribute = null;
          try {
  
              attribute = "debug";
              int debug = 0;
              try {
                  debug = Integer.parseInt(sform.getDebugLvl());
              } catch (Throwable t) {
                  debug = 0;
              }
              mBServer.setAttribute(new ObjectName(sObjectName),
                                    new Attribute("debug", new Integer(debug)));
              mBServer.setAttribute(new ObjectName(eObjectName),
                                    new Attribute("debug", new Integer(debug)));
  
          } catch (Exception e) {
  
              getServlet().log
                  (resources.getMessage(locale, "users.error.attribute.set",
                                        attribute), e);
              response.sendError
                  (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                   resources.getMessage(locale, "users.error.attribute.set",
                                        attribute));
              return (null);
          }
          
          if (servlet.getDebug() >= 1)
              servlet.log(" Forwarding to success page");
          // Forward back to the test page
          return (mapping.findForward("Save Successful"));
          
      }
      
  }
  
  
  
  1.2       +2 -0      jakarta-tomcat-4.0/webapps/admin/host/host.jsp
  
  Index: host.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/host/host.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- host.jsp	14 Feb 2002 20:37:22 -0000	1.1
  +++ host.jsp	6 Mar 2002 06:49:11 -0000	1.2
  @@ -52,10 +52,12 @@
               <controls:action url="">  <bean:message key="actions.valve.delete"/> </controls:action>
               <controls:action> ------------------------------------- </controls:action>
               --%>
  +            <%--
               <controls:action url='<%= "/setUpDeleteHost.do?this=" + 
                                java.net.URLEncoder.encode(hostName.toString()) %>'>  
                   <bean:message key="actions.thishost.delete"/> 
               </controls:action>
  +            --%>
           </controls:actions>
             </div>
         </td>
  
  
  
  1.4       +191 -100  jakarta-tomcat-4.0/webapps/admin/service/service.jsp
  
  Index: service.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/service/service.jsp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- service.jsp	15 Feb 2002 21:04:37 -0000	1.3
  +++ service.jsp	6 Mar 2002 06:49:11 -0000	1.4
  @@ -1,6 +1,6 @@
   <!-- Standard Struts Entries -->
   
  -<%@ page language="java" %>
  +<%@ page language="java" import="java.net.URLEncoder" %>
   <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
   <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
   <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  @@ -17,150 +17,241 @@
   
   <html:errors/>
   
  -<html:form method="POST" action="/service">
  +<html:form method="POST" action="/SaveService">
  +
  +  <bean:define id="serviceName" name="serviceForm" property="serviceName"/>
  +  <html:hidden property="adminAction"/>
  +  <html:hidden property="objectName"/>
  +  <html:hidden property="engineObjectName"/>
  +
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
       <tr class="page-title-row">
         <td width="81%"> 
           <div class="page-title-text" align="left">
  -        <bean:write name="serviceForm" property="nodeLabel" scope="session"/>
  -        <bean:define id="serviceName" name="serviceForm" property="serviceName"/>
  +          <logic:equal name="serviceForm" property="adminAction" value="Create">
  +            <bean:message key="actions.services.create"/>
  +          </logic:equal>
  +          <logic:equal name="serviceForm" property="adminAction" value="Edit">
  +            <bean:message key="actions.services.edit"/>
  +          </logic:equal>
           </div>
         </td>
         <td width="19%"> 
           <div align="right">
  -        <controls:actions>
  -            <controls:action selected="true"> -----<bean:message key="actions.available.actions"/>----- </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            <%--
  -            <controls:action url="">  <bean:message key="actions.accesslogger.create"/> </controls:action>
  -            <controls:action url="">  <bean:message key="actions.accesslogger.delete"/> </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            <controls:action url="">  <bean:message key="actions.connector.create"/> </controls:action>
  -            <controls:action url="">  <bean:message key="actions.connector.delete"/> </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            --%>
  -            <controls:action url='<%= "/setUpAddHost.do?serviceName=" + serviceName %>'>  
  -                    <bean:message key="actions.host.create"/> 
  -            </controls:action>
  -            <controls:action url='<%= "/setUpDeleteHost.do?serviceName=" + serviceName %>'>  
  -                    <bean:message key="actions.host.delete"/> 
  +          <controls:actions>
  +            <controls:action selected="true">
  +              -----<bean:message key="actions.available.actions"/>-----
               </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>            
  -            <%--
  -            <controls:action url="">  <bean:message key="actions.logger.create"/> </controls:action>
  -            <controls:action url="">  <bean:message key="actions.logger.delete"/> </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            <controls:action url="">  <bean:message key="actions.requestfilter.create"/> </controls:action>
  -            <controls:action url="">  <bean:message key="actions.requestfilter.delete"/> </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            <controls:action url="">  <bean:message key="actions.userrealm.create"/> </controls:action>
  -            <controls:action url="">  <bean:message key="actions.userrealm.delete"/> </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            <controls:action url="">  <bean:message key="actions.valve.create"/> </controls:action>
  -            <controls:action url="">  <bean:message key="actions.valve.delete"/> </controls:action>
  -            <controls:action> ------------------------------------- </controls:action>
  -            --%>
  -            <controls:action url='<%= "/setUpDeleteService.do?this=" + serviceName %>'>  
  -                    <bean:message key="actions.service.delete"/> 
  +            <controls:action>
  +              -------------------------------------
               </controls:action>
  -        </controls:actions>
  -          </div>
  +            <logic:notEqual name="serviceForm" property="adminAction" value="Create">
  +              <%--
  +              <controls:action url="">
  +                <bean:message key="actions.accesslogger.create"/>
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.accesslogger.delete"/>
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.connector.create"/>
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.connector.delete"/>
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              --%>
  +              <%--
  +              <controls:action url='<%= "/setUpAddHost.do?serviceName=" +
  +                                        serviceName %>'>  
  +                <bean:message key="actions.host.create"/>
  +              </controls:action>
  +              <controls:action url='<%= "/setUpDeleteHost.do?serviceName=" +
  +                                        serviceName %>'>
  +                <bean:message key="actions.host.delete"/> 
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              --%>
  +              <%--
  +              <controls:action url="">
  +                <bean:message key="actions.logger.create"/>
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.logger.delete"/>
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.requestfilter.create"/>
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.requestfilter.delete"/>
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.userrealm.create"/>
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.userrealm.delete"/>
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.valve.create"/>
  +              </controls:action>
  +              <controls:action url="">
  +                <bean:message key="actions.valve.delete"/>
  +              </controls:action>
  +              <controls:action>
  +                -------------------------------------
  +              </controls:action>
  +              --%>
  +              <%--
  +              <controls:action url='<%= "/setUpDeleteService.do?this=" +
  +                                        serviceName %>'>  
  +                <bean:message key="actions.service.delete"/>
  +              </controls:action>
  +              --%>
  +            </logic:notEqual>
  +          </controls:actions>
  +        </div>
         </td>
       </tr>
     </table>
   
     <%@ include file="../buttons.jsp" %>
   
  - <%-- Heading --%>
  - 
  - <table border="0" cellspacing="0" cellpadding="0" width="100%">
  -    <tr> <td>  <div class="table-title-text">  
  -            <bean:message key="service.properties"/>
  -    </div> </td> </tr>
  +  <%-- Service Properties --%>
  +
  +  <table border="0" cellspacing="0" cellpadding="0" width="100%">
  +    <tr><td><div class="table-title-text">  
  +      <bean:message key="service.properties"/>
  +    </div></td></tr>
     </table>
   
  -  <table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%">
  +  <table class="back-table" border="0"
  +         cellspacing="0" cellpadding="1" width="100%">
       <tr> 
         <td> 
           <controls:table tableStyle="front-table" lineStyle="line-row">
  -            <controls:row header="true" 
  -                labelStyle="table-header-text" dataStyle="table-header-text">
  -            <controls:label><bean:message key="service.property"/></controls:label>
  -            <controls:data><bean:message key="service.value"/> </controls:data>
  -        </controls:row>
  -
  -        <controls:row labelStyle="table-label-text" dataStyle="table-normal-text">
  -            <controls:label><bean:message key="service.name"/>:</controls:label>
  +          <controls:row header="true" 
  +              labelStyle="table-header-text" dataStyle="table-header-text">
  +            <controls:label>
  +              <bean:message key="service.property"/>
  +            </controls:label>
               <controls:data>
  -              <html:hidden property="serviceName"/>
  -              <bean:write name="serviceForm" property="serviceName" 
  -                          scope="session"/> 
  +              <bean:message key="service.value"/>
               </controls:data>
  -        </controls:row>
  -
  -    </controls:table>
  +          </controls:row>
  +          <controls:row header="false"
  +              labelStyle="table-label-text" dataStyle="table-normal-text">
  +            <controls:label>
  +              <bean:message key="service.name"/>:
  +            </controls:label>
  +            <controls:data>
  +              <logic:equal name="serviceForm" property="adminAction" value="Create">
   
  -    </td>
  +                <html:text property="serviceName" size="24" maxlength="24"/>
  +              </logic:equal>
  +              <logic:equal name="serviceForm" property="adminAction" value="Edit">
  +                <html:hidden property="serviceName"/>
  +                <bean:write name="serviceForm" property="serviceName"/>
  +              </logic:equal>
  +            </controls:data>
  +          </controls:row>
  +        </controls:table>
  +      </td>
       </tr>
     </table>
   
  -<br>
  +  <br>
  +
  +  <%-- Engine Properties --%>
   
     <table border="0" cellspacing="0" cellpadding="0" width="100%">
  -    <tr> <td> <div class="table-title-text">  
  -        <bean:message key="service.engine.props"/> 
  -    </div> </td> </tr>
  +    <tr><td><div class="table-title-text">  
  +      <bean:message key="service.engine.props"/>
  +    </div></td></tr>
     </table>
  - 
  -  <table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%">
  +
  +  <table class="back-table" border="0"
  +         cellspacing="0" cellpadding="1" width="100%">
       <tr> 
         <td> 
           <controls:table tableStyle="front-table" lineStyle="line-row">
  -            <controls:row header="true" 
  -                labelStyle="table-header-text" dataStyle="table-header-text">
  -            <controls:label><bean:message key="service.property"/></controls:label>
  -            <controls:data><bean:message key="service.value"/> </controls:data>
  -        </controls:row>
  -
  -        <controls:row labelStyle="table-label-text" dataStyle="table-normal-text">
  -            <controls:label><bean:message key="service.name"/>:</controls:label>
  +          <controls:row header="true" 
  +              labelStyle="table-header-text" dataStyle="table-header-text">
  +            <controls:label>
  +              <bean:message key="service.property"/>
  +            </controls:label>
               <controls:data>
  -              <html:text property="engineName" size="24" maxlength="24"/>
  +              <bean:message key="service.value"/>
               </controls:data>
  -        </controls:row>
  +          </controls:row>
  +          <controls:row header="false"
  +              labelStyle="table-label-text" dataStyle="table-normal-text">
  +            <controls:label>
  +              <bean:message key="service.name"/>:
  +            </controls:label>
  +            <controls:data>
  +              <logic:equal name="serviceForm" property="adminAction" value="Create">
   
  -        <controls:row labelStyle="table-label-text" dataStyle="table-normal-text">
  -            <controls:label><bean:message key="server.debuglevel"/>:</controls:label>
  +                <html:text property="engineName" size="24" maxlength="24"/>
  +              </logic:equal>
  +              <logic:equal name="serviceForm" property="adminAction" value="Edit">
  +                <html:hidden property="engineName"/>
  +                <bean:write name="serviceForm" property="engineName"/>
  +              </logic:equal>
  +            </controls:data>
  +          </controls:row>
  +          <controls:row header="false"
  +              labelStyle="table-label-text" dataStyle="table-normal-text">
  +            <controls:label>
  +              <bean:message key="server.debuglevel"/>:
  +            </controls:label>
               <controls:data>
  -                <html:select property="debugLvl">
  -                     <bean:define id="debugLvlVals" name="serviceForm" property="debugLvlVals"/>
  -                     <html:options collection="debugLvlVals" property="value"
  -                   labelProperty="label"/>
  -                </html:select>
  +              <bean:define id="debugLvlVals" name="serviceForm"
  +                           property="debugLvlVals"/>
  +              <html:select property="debugLvl">
  +                <html:options collection="debugLvlVals" property="value"
  +                              labelProperty="label"/>
  +              </html:select>
               </controls:data>
  -        </controls:row>
  -
  -        <controls:row labelStyle="table-label-text" dataStyle="table-normal-text">
  -            <controls:label><bean:message key="service.defaulthostname"/>:</controls:label>
  +          </controls:row>
  +          <controls:row header="false"
  +              labelStyle="table-label-text" dataStyle="table-normal-text">
  +            <controls:label>
  +              <bean:message key="service.defaulthostname"/>:
  +            </controls:label>
               <controls:data>
  -                <html:select property="defaultHost">
  -                     <bean:define id="hostNameVals" 
  -                            name="serviceForm" property="hostNameVals"/>
  -                     <html:options collection="hostNameVals" property="value"
  -                            labelProperty="label"/>
  -                </html:select>
  +              <bean:define id="hostNameVals" name="serviceForm"
  +                           property="hostNameVals"/>
  +              <html:select property="defaultHost">
  +                <html:options collection="hostNameVals" property="value"
  +                              labelProperty="label"/>
  +              </html:select>
               </controls:data>
  -        </controls:row>
  -
  -    </controls:table>
  -    </td>
  +          </controls:row>
  +        </controls:table>
  +      </td>
       </tr>
     </table>
  +
     <br>
   
     <%@ include file="../buttons.jsp" %>
   
  -  </html:form>
  +</html:form>
   </body>
  -
   </html:html>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>