tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manv...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger AddLoggerAction.java DeleteLoggerAction.java EditLoggerAction.java LoggerForm.java SaveLoggerAction.java
Date Thu, 21 Mar 2002 17:11:28 GMT
manveen     02/03/21 09:11:28

  Modified:    webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger
                        DeleteLoggerAction.java EditLoggerAction.java
                        LoggerForm.java SaveLoggerAction.java
  Added:       webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger
                        AddLoggerAction.java
  Log:
  Added Add logger implementation.
  
  Revision  Changes    Path
  1.2       +33 -29    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/DeleteLoggerAction.java
  
  Index: DeleteLoggerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/DeleteLoggerAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeleteLoggerAction.java	19 Mar 2002 18:38:00 -0000	1.1
  +++ DeleteLoggerAction.java	21 Mar 2002 17:11:28 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/DeleteLoggerAction.java,v
1.1 2002/03/19 18:38:00 manveen Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/19 18:38:00 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/DeleteLoggerAction.java,v
1.2 2002/03/21 17:11:28 manveen Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/21 17:11:28 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    * The <code>Action</code> that sets up <em>Delete Loggers</em>
transactions.
    *
    * @author Manveen Kaur
  - * @version $Revision: 1.1 $ $Date: 2002/03/19 18:38:00 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/21 17:11:28 $
    */
   
   public class DeleteLoggerAction extends Action {
  @@ -172,31 +172,7 @@
           
           if (parent != null) {
               try {
  -                // Form the pattern that gets the logger for this particular
  -                // service, host or context.
  -                StringBuffer sb = new StringBuffer(TomcatTreeBuilder.LOGGER_TYPE);
  -                ObjectName poname = new ObjectName(parent);
  -                String type = poname.getKeyProperty("type");
  -                if ("Context".equalsIgnoreCase(type)) { // container is context
  -                    sb.append(",path=");
  -                    sb.append(poname.getKeyProperty("path"));
  -                    sb.append(",host=");
  -                    sb.append(poname.getKeyProperty("host"));
  -                    sb.append(",service=");
  -                    sb.append(poname.getKeyProperty("service"));
  -                }
  -                if ("Host".equalsIgnoreCase(type)) {    // container is host
  -                    sb.append(",host=");
  -                    sb.append(poname.getKeyProperty("name"));
  -                    sb.append(",service=");
  -                    sb.append(poname.getKeyProperty("service"));
  -                }
  -                if ("Service".equalsIgnoreCase(type)) {  // container is service
  -                    sb.append(",service=");
  -                    sb.append(poname.getKeyProperty("name"));
  -                }
  -                pattern = sb.toString();
  -                
  +                pattern = getObjectName(parent);
               } catch (Exception e) {
                   getServlet().log
                   (resources.getMessage(locale, "users.error.select"));
  @@ -230,4 +206,32 @@
           
       }
       
  +    public static String getObjectName(String parent)
  +    throws Exception{
  +        
  +        // Form the pattern that gets the logger for this particular
  +        // service, host or context.
  +        StringBuffer sb = new StringBuffer(TomcatTreeBuilder.LOGGER_TYPE);
  +        ObjectName poname = new ObjectName(parent);
  +        String type = poname.getKeyProperty("type");
  +        if ("Context".equalsIgnoreCase(type)) { // container is context
  +            sb.append(",path=");
  +            sb.append(poname.getKeyProperty("path"));
  +            sb.append(",host=");
  +            sb.append(poname.getKeyProperty("host"));
  +            sb.append(",service=");
  +            sb.append(poname.getKeyProperty("service"));
  +        }
  +        if ("Host".equalsIgnoreCase(type)) {    // container is host
  +            sb.append(",host=");
  +            sb.append(poname.getKeyProperty("name"));
  +            sb.append(",service=");
  +            sb.append(poname.getKeyProperty("service"));
  +        }
  +        if ("Service".equalsIgnoreCase(type)) {  // container is service
  +            sb.append(",service=");
  +            sb.append(poname.getKeyProperty("name"));
  +        }
  +        return sb.toString();  
  +    }
   }
  
  
  
  1.2       +7 -8      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/EditLoggerAction.java
  
  Index: EditLoggerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/EditLoggerAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EditLoggerAction.java	15 Mar 2002 09:44:18 -0000	1.1
  +++ EditLoggerAction.java	21 Mar 2002 17:11:28 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/EditLoggerAction.java,v
1.1 2002/03/15 09:44:18 manveen Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/15 09:44:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/EditLoggerAction.java,v
1.2 2002/03/21 17:11:28 manveen Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/21 17:11:28 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,7 @@
    * The <code>Action</code> that sets up <em>Edit Logger</em> transactions.
    *
    * @author Manveen Kaur
  - * @version $Revision: 1.1 $ $Date: 2002/03/15 09:44:18 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/21 17:11:28 $
    */
   
   public class EditLoggerAction extends Action {
  @@ -166,16 +166,15 @@
           session.setAttribute("loggerForm", loggerFm);
           loggerFm.setAdminAction("Edit");
           loggerFm.setObjectName(lname.toString());
  +        loggerFm.setParentObjectName("");
           sb = new StringBuffer("Logger (");
  -        // FIX ME
           sb.append(lname.getKeyProperty("className"));
           sb.append(")");
           loggerFm.setNodeLabel(sb.toString());
  -        // FIX ME
  -        loggerFm.setLoggerName("Logger");
           loggerFm.setDebugLvlVals(Lists.getDebugLevels());        
           loggerFm.setVerbosityLvlVals(Lists.getVerbosityLevels());        
  -        loggerFm.setBooleanVals(Lists.getBooleanValues());
  +        loggerFm.setBooleanVals(Lists.getBooleanValues());        
  +      
           String attribute = null;
           try {
   
  
  
  
  1.3       +52 -32    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java
  
  Index: LoggerForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LoggerForm.java	15 Mar 2002 09:44:18 -0000	1.2
  +++ LoggerForm.java	21 Mar 2002 17:11:28 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java,v
1.2 2002/03/15 09:44:18 manveen Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/03/15 09:44:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java,v
1.3 2002/03/21 17:11:28 manveen Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/03/21 17:11:28 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    * Form bean for the logger page.
    *
    * @author Manveen Kaur
  - * @version $Revision: 1.2 $ $Date: 2002/03/15 09:44:18 $
  + * @version $Revision: 1.3 $ $Date: 2002/03/21 17:11:28 $
    */
   
   public final class LoggerForm extends ActionForm {
  @@ -89,13 +89,12 @@
        * The object name of the Logger this bean refers to.
        */
       private String objectName = null;
  -    
  +   
       /**
  -     * The text for the logger name, used to retrieve
  -     * the corresponding logger mBean.
  +     * The object name of the parent of this Logger.
        */
  -    private String loggerName = null;
  -    
  +    private String parentObjectName = null;
  +   
       /**
        * The text for the logger type. 
        * Specifies if it is a FileLogger, or SysErr or SysOut Logger.
  @@ -140,7 +139,8 @@
       private List debugLvlVals = null;
       private List verbosityLvlVals = null;
       private List booleanVals = null;
  -    
  +    private List loggerTypeVals = null;
  +
       // ------------------------------------------------------------- Properties
       
          /**
  @@ -180,25 +180,27 @@
           this.objectName = objectName;
   
       }
  -
  +    
  +    
       /**
  -     * Return the Logger Name.
  +     * Return the parent object name of the Logger this bean refers to.
        */
  -    public String getLoggerName() {
  -        
  -        return this.loggerName;
  -        
  +    public String getParentObjectName() {
  +
  +        return this.parentObjectName;
  +
       }
  -    
  +
  +
       /**
  -     * Set the Logger Name.
  +     * Set the parent object name of the Logger this bean refers to.
        */
  -    public void setLoggerName(String loggerName) {
  -        
  -        this.loggerName = loggerName;
  -        
  +    public void setParentObjectName(String parentObjectName) {
  +
  +        this.parentObjectName = parentObjectName;
  +
       }
  -        
  +    
       /**
        * Return the Logger type.
        */
  @@ -397,6 +399,24 @@
           
       }
       
  +        /**
  +     * Return the loggerTypeVals.
  +     */
  +    public List getLoggerTypeVals() {
  +        
  +        return this.loggerTypeVals;
  +        
  +    }
  +    
  +    /**
  +     * Set the loggerTypeVals.
  +     */
  +    public void setLoggerTypeVals(List loggerTypeVals) {
  +        
  +        this.loggerTypeVals = loggerTypeVals;
  +        
  +    }
  +    
       // --------------------------------------------------------- Public Methods
       
       /**
  @@ -408,8 +428,8 @@
       public void reset(ActionMapping mapping, HttpServletRequest request) {
           
           this.objectName = null;
  -        this.loggerName = null;
           this.loggerType = null;
  +        this.parentObjectName = null;
           this.debugLvl = "0";
           this.verbosityLvl = "0";        
           this.directory = null;
  @@ -428,20 +448,20 @@
           sb.append(adminAction);
           sb.append(",debugLvl=");
           sb.append(debugLvl);
  -        sb.append("verbosityLvl,=");
  +        sb.append(",verbosityLvl=");
           sb.append(verbosityLvl);
           sb.append(",directory=");
           sb.append(directory);
  -        sb.append(",prefix='");
  +        sb.append(",prefix=");
           sb.append(prefix);
  -        sb.append(",suffix='");
  +        sb.append(",suffix=");
           sb.append(suffix);
  -        sb.append(",loggerType='");
  +        sb.append(",loggerType=");
           sb.append(loggerType);
  -        sb.append("',objectName='");
  +        sb.append(",objectName=");
           sb.append(objectName);
  -        sb.append("',loggerName=");
  -        sb.append(loggerName);
  +        sb.append(",parentObjectName=");
  +        sb.append(parentObjectName);
           sb.append("]");
           return (sb.toString());
   
  @@ -470,7 +490,7 @@
           // these checks should be done only if it is FileLogger. 
           // No checks needed otherwise        
           if ((submit != null)
  -           && (SetUpLoggerAction.FILE_LOGGER).equalsIgnoreCase(type)) {
  +           && ("FileLogger").equalsIgnoreCase(type)) {
                
               if ((directory == null) || (directory.length() < 1)) {
                   errors.add("directory",
  
  
  
  1.2       +42 -29    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/SaveLoggerAction.java
  
  Index: SaveLoggerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/SaveLoggerAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SaveLoggerAction.java	15 Mar 2002 09:44:18 -0000	1.1
  +++ SaveLoggerAction.java	21 Mar 2002 17:11:28 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/SaveLoggerAction.java,v
1.1 2002/03/15 09:44:18 manveen Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/15 09:44:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/SaveLoggerAction.java,v
1.2 2002/03/21 17:11:28 manveen Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/21 17:11:28 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * <em>Edit Logger</em> transactions.
    *
    * @author Manveen Kaur
  - * @version $Revision: 1.1 $ $Date: 2002/03/15 09:44:18 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/21 17:11:28 $
    */
   
   public final class SaveLoggerAction extends Action {
  @@ -109,8 +109,7 @@
        * Signature for the <code>createStandardLogger</code> operation.
        */
       private String createStandardLoggerTypes[] =
  -    { "java.lang.String",     // parent
  -      "java.lang.String",     // name
  +    { "java.lang.String"     // parent
       };
   
   
  @@ -161,12 +160,13 @@
           } catch (Throwable t) {
               throw new ServletException
               ("Cannot acquire MBeanServer reference", t);
  -        }
  +        }    
           
           // Identify the requested action
           LoggerForm lform = (LoggerForm) form;
           String adminAction = lform.getAdminAction();
           String lObjectName = lform.getObjectName();
  +        String loggerType = lform.getLoggerType();
   
           // Perform a "Create Logger" transaction (if requested)
           if ("Create".equals(adminAction)) {
  @@ -175,11 +175,34 @@
               String values[] = null;
   
               try {
  -
  +   
  +                String parent = lform.getParentObjectName();                
  +                String objectName = DeleteLoggerAction.getObjectName(parent);
  +                
  +                ObjectName pname = new ObjectName(parent);                            
   
  +                StringBuffer sb = new StringBuffer(pname.getDomain());                
   
  +                
  +                // System.out.println("Parent mBean = " + parent);
  +                // FIX ME-- should Service be converted to Engine,
  +                // as createLogger in MBeanFactory requires Engine ObjectName??       
      
  +                try {                        
  +                    if ("Service".equalsIgnoreCase(pname.getKeyProperty("type"))) {
  +                        sb.append(":type=Engine,service=");
  +                        sb.append(pname.getKeyProperty("name"));
  +                        objectName = sb.toString();
  +                    }
  +                } catch (Exception e) {
  +                    String message =
  +                        resources.getMessage("error.engineName.bad",
  +                                         sb.toString());
  +                    getServlet().log(message);
  +                    response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
  +                    return (null);
  +                }
  +                
                   // Ensure that the requested logger name is unique
                   ObjectName oname =
  -                    new ObjectName(TomcatTreeBuilder.LOGGER_TYPE +
  -                                   ",className=" + lform.getLoggerName());
  +                    new ObjectName(objectName);
                   if (mBServer.isRegistered(oname)) {
                       ActionErrors errors = new ActionErrors();
                       errors.add("loggerName",
  @@ -193,23 +216,22 @@
                       new ObjectName(TomcatTreeBuilder.FACTORY_TYPE);
   
                   // Create a new StandardLogger object
  -                values = new String[2];
  -                values[0] = TomcatTreeBuilder.SERVER_TYPE;
  -                values[1] = lform.getLoggerName();
  -                operation = "createStandardLogger";
  +                values = new String[1];
  +                values[0] = parent;
  +                operation = "create" + loggerType;
                   lObjectName = (String)
                       mBServer.invoke(fname, operation,
                                       values, createStandardLoggerTypes);
  -
  +               
                   // Add the new Logger to our tree control node
                   TreeControl control = (TreeControl)
                       session.getAttribute("treeControlTest");
                   if (control != null) {
  -                    String parentName = TomcatTreeBuilder.SERVER_TYPE;
  -                    TreeControlNode parentNode = control.findNode(parentName);
  +                    //String parentName = TomcatTreeBuilder.SERVER_TYPE;
  +                    TreeControlNode parentNode = control.findNode(parent);
                       if (parentNode != null) {
                           String nodeLabel =
  -                            "Logger (" + lform.getLoggerName() + ")";
  +                           "Logger for " + parentNode.getLabel();
                           String encodedName =
                               URLEncoder.encode(lObjectName);
                           TreeControlNode childNode =
  @@ -224,7 +246,7 @@
                           // FIXME - force a redisplay
                       } else {
                           getServlet().log
  -                            ("Cannot find parent node '" + parentName + "'");
  +                            ("Cannot find parent node '" + parent + "'");
                       }
                   } else {
                       getServlet().log
  @@ -261,7 +283,7 @@
               }
               mBServer.setAttribute(loname,
                                     new Attribute("debug", new Integer(debug)));
  -            attribute = "debug";
  +            attribute = "verbosity";
               int verbosity = 0;
               try {
                   verbosity = Integer.parseInt(lform.getVerbosityLvl());
  @@ -270,7 +292,6 @@
               }
               mBServer.setAttribute(loname,
                                     new Attribute("verbosity", new Integer(verbosity)));
           
  -            String loggerType = lform.getLoggerType();
               if("FileLogger".equalsIgnoreCase(loggerType)) {
                   attribute = "directory";              
                   mBServer.setAttribute(loname,
  @@ -282,13 +303,6 @@
                   mBServer.setAttribute(loname,
                                     new Attribute("suffix", lform.getSuffix()));        
   
                   attribute = "timestamp";              
  -/*                String timestamp = "false";
  -                try {
  -                    timestamp = lform.getTimestamp();
  -                } catch (Throwable t) {
  -                    timestamp = "false";
  -                }
  - */
                   mBServer.setAttribute(loname,
                          new Attribute("timestamp", new Boolean(lform.getTimestamp())));;
                           
               }
  @@ -304,7 +318,6 @@
                                         attribute));
               return (null);
           }
  -        
           // Forward to the success reporting page
           session.removeAttribute(mapping.getAttribute());
           return (mapping.findForward("Save Successful"));
  
  
  
  1.1                  jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/AddLoggerAction.java
  
  Index: AddLoggerAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/AddLoggerAction.java,v
1.1 2002/03/21 17:11:28 manveen Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/21 17:11:28 $
   *
   * ====================================================================
   *
   * 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.logger;
  
  import java.io.IOException;
  import java.net.URLEncoder;
  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 org.apache.struts.util.MessageResources;
  import org.apache.webapp.admin.LabelValueBean;
  import org.apache.webapp.admin.Lists;
  
  /**
   * The <code>Action</code> that sets up <em>Add Logger</em> transactions.
   *
   * @author Manveen Kaur
   * @version $Revision: 1.1 $ $Date: 2002/03/21 17:11:28 $
   */
  
  public class AddLoggerAction extends Action {
          
      /**
       * 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();
          }
          
          // Fill in the form values for display and editing
          LoggerForm loggerFm = new LoggerForm();
          session.setAttribute("loggerForm", loggerFm);
          loggerFm.setAdminAction("Create");
          loggerFm.setObjectName("");
          String parent = request.getParameter("parent");
          loggerFm.setParentObjectName(parent);
          String type = request.getParameter("type");
          if (type == null)
              type = "FileLogger";    // default type is FileLogger
          loggerFm.setLoggerType(type);
          loggerFm.setDebugLvl("0");
          loggerFm.setDebugLvlVals(Lists.getDebugLevels());
          loggerFm.setVerbosityLvlVals(Lists.getVerbosityLevels());        
          loggerFm.setBooleanVals(Lists.getBooleanValues());        
        
          String loggerTypes[] = new String[3];
          loggerTypes[0] = "FileLogger";
          loggerTypes[1] = "SystemErrLogger";
          loggerTypes[2] = "SystemOutLogger";
          
          ArrayList types = new ArrayList();    
          // the first element in the select list should be the type selected
          types.add(new LabelValueBean(type,
                  "/admin/AddLogger.do?parent=" + URLEncoder.encode(parent) 
                  + "&type=" + type));        
          for (int i=0; i< loggerTypes.length; i++) {
              if (!type.equalsIgnoreCase(loggerTypes[i])) {
                  types.add(new LabelValueBean(loggerTypes[i],
                  "/admin/AddLogger.do?parent=" + URLEncoder.encode(parent) 
                  + "&type=" + loggerTypes[i]));        
              }
          }
          loggerFm.setLoggerTypeVals(types);
          
          // Forward to the logger display page
          return (mapping.findForward("Logger"));
          
      }
      
  }
  
  
  

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


Mime
View raw message