struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-struts/web/example/WEB-INF struts-config.xml
Date Sat, 07 Oct 2000 22:55:14 GMT
craigmcc    00/10/07 15:55:14

  Modified:    src/doc  release.xml
               src/share/org/apache/struts/action
                        ActionResources.properties ActionServlet.java
               web/example/WEB-INF struts-config.xml
  Added:       src/share/org/apache/struts/actions AddFormBeanAction.java
                        AddForwardAction.java AddMappingAction.java
                        ReloadAction.java RemoveFormBeanAction.java
                        RemoveForwardAction.java RemoveMappingAction.java
  Log:
  Add a simple set of standard actions that can be utlilized (if desired) to
  dynamically modify the configuration of a running Struts controller
  servlet.  If used, these options should be protected by security
  constraints to avoid the potential for indiscriminate interference with
  the operation of your application.  However, they can be very useful
  during application development.
  
  Revision  Changes    Path
  1.3       +10 -2     jakarta-struts/src/doc/release.xml
  
  Index: release.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/release.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- release.xml	2000/10/01 02:17:44	1.2
  +++ release.xml	2000/10/07 22:55:13	1.3
  @@ -31,13 +31,21 @@
         be phased out by the 1.0 release.</li>
     <li>If enabled by setting the <code>locale</code> servlet initialization
         parameter to <code>true</code>, the controller servlet will now calculate
  -      a Locale for this user (based on the HTTP headers included with the
  -      request) and store it in the user's session, unless the application
  +      a Locale for this user (based on the Locale returned by the servlet
  +      container, or by the HTTP headers included with the request)
  +      and store it in the user's session, unless the application
         has stored one there already.</li>
     <li>Application <code>Action</code> instances now have lifecycle support.
         The controller servlet will call <code>setServlet()</code> with a
         non-null argument when the instance is first created, and call it with
         a <code>null</code> argument when the instance is being shut down.</li>
  +  <li>The collection of "standard" Struts actions (in package
  +      <code>org.apache.struts.actions</code>) is kicked off with a set of
  +      simple actions that allow on-the-fly changes in the form bean, forward,
  +      and mapping definitions registered with the controller servlet.  These
  +      actions would normally be configured behind security constraints to
  +      prevent interference with the operation of your application but can be
  +      very useful during development.</li>
     </ul>
   
     </section>
  
  
  
  1.3       +1 -0      jakarta-struts/src/share/org/apache/struts/action/ActionResources.properties
  
  Index: ActionResources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionResources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ActionResources.properties	2000/06/15 19:39:00	1.2
  +++ ActionResources.properties	2000/10/07 22:55:13	1.3
  @@ -9,4 +9,5 @@
   finalizing=Finalizing this controller servlet
   processInvalid=Invalid path {0} was requested
   processPath=No process path included in this request
  +reloading=Reloading from configuration files
   sessionCreate=No user session could be created
  
  
  
  1.28      +31 -4     jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ActionServlet.java	2000/10/07 20:57:42	1.27
  +++ ActionServlet.java	2000/10/07 22:55:13	1.28
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.27 2000/10/07 20:57:42 craigmcc Exp $
  - * $Revision: 1.27 $
  - * $Date: 2000/10/07 20:57:42 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.28 2000/10/07 22:55:13 craigmcc Exp $
  + * $Revision: 1.28 $
  + * $Date: 2000/10/07 22:55:13 $
    *
    * ====================================================================
    *
  @@ -197,7 +197,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.27 $ $Date: 2000/10/07 20:57:42 $
  + * @version $Revision: 1.28 $ $Date: 2000/10/07 22:55:13 $
    */
   
   public class ActionServlet
  @@ -540,6 +540,33 @@
   
           if (debug >= level)
               log(message);
  +
  +    }
  +
  +
  +    /**
  +     * Reload the configuration of this controller servlet from our
  +     * underlying configuration files.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     * @exception ServletException if a servlet exception occurs
  +     */
  +    public void reload() throws IOException, ServletException {
  +
  +        if (debug >= 1)
  +            log(internal.getMessage("reloading"));
  +
  +        // Shut down our existing environment
  +        destroyActions();
  +        destroyApplication();
  +        destroyInternal();
  +
  +        // Restart from our confirmation files
  +        initInternal();
  +        initDebug();
  +        initApplication();
  +        initMapping();
  +        initOther();
   
       }
   
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/AddFormBeanAction.java
  
  Index: AddFormBeanAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/AddFormBeanAction.java,v 1.1 2000/10/07 22:55:13 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:13 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionFormBean;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>addFormBean()</code> method of our controller servlet to add a new
   * action form definition dynamically.  The new definition replaces any
   * existing definition for the same bean name.  This action expects request
   * parameters whose names match the properties of <code>ActionFormBean</code>.
   * </p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:13 $
   */
  
  public class AddFormBeanAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          // Construct a new ActionFormBean instance
          ActionFormBean formBean = null;
          try {
              Class clazz = Class.forName(getServlet().getFormBeanClass());
              formBean = (ActionFormBean) clazz.newInstance();
          } catch (Throwable t) {
              throw new ServletException("ActionFormBean", t);
          }
          BeanUtils.populate(formBean, request);
  
          // Validate the parameters of the new instance
          boolean ok = true;
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
          if (formBean.getName() == null) {
              writer.println("FAIL - Missing 'name' parameter");
              ok = false;
          }
          if (formBean.getType() == null) {
              writer.println("FAIL - Missing 'type' parameter");
              ok = false;
          }
          if (!ok) {
              writer.flush();
              writer.close();
              return (null);
          }
  
          // Update the configuration of our controller servlet
          getServlet().addFormBean(formBean);
  
          // Return a successful response
          writer.println("OK");
          writer.flush();
          writer.close();
          return (null);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/AddForwardAction.java
  
  Index: AddForwardAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/AddForwardAction.java,v 1.1 2000/10/07 22:55:14 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>addForward()</code> method of our controller servlet to add a new
   * action forward definition dynamically.  The new definition replaces any
   * existing definition for the same name.  This action expects request
   * parameters whose names match the properties of <code>ActionForward</code>.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:14 $
   */
  
  public class AddForwardAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          // Construct a new ActionForward instance
          ActionForward forward = null;
          try {
              Class clazz = Class.forName(getServlet().getForwardClass());
              forward = (ActionForward) clazz.newInstance();
          } catch (Throwable t) {
              throw new ServletException("ActionForward", t);
          }
          BeanUtils.populate(forward, request);
  
          // Validate the parameters of the new instance
          boolean ok = true;
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
          if (forward.getName() == null) {
              writer.println("FAIL - Missing 'name' parameter");
              ok = false;
          }
          if (forward.getPath() == null) {
              writer.println("FAIL - Missing 'path' parameter");
              ok = false;
          }
          if (!ok) {
              writer.flush();
              writer.close();
              return (null);
          }
  
          // Update the configuration of our controller servlet
          getServlet().addForward(forward);
  
          // Return a successful response
          writer.println("OK");
          writer.flush();
          writer.close();
          return (null);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/AddMappingAction.java
  
  Index: AddMappingAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/AddMappingAction.java,v 1.1 2000/10/07 22:55:14 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>addMapping()</code> method of our controller servlet to add a new
   * action mapping definition dynamically.  The new definition replaces any
   * existing definition for the same name.  This action expects request
   * parameters whose names match the properties of <code>ActionMapping</code>.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:14 $
   */
  
  public class AddMappingAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          // Construct a new ActionMapping instance
          mapping = null;
          try {
              Class clazz = Class.forName(getServlet().getMappingClass());
              mapping = (ActionMapping) clazz.newInstance();
          } catch (Throwable t) {
              throw new ServletException("ActionMapping", t);
          }
          BeanUtils.populate(mapping, request);
  
          // Validate the parameters of the new instance
          boolean ok = true;
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
          if (mapping.getPath() == null) {
              writer.println("FAIL - Missing 'path' parameter");
              ok = false;
          }
          if (mapping.getType() == null) {
              writer.println("FAIL - Missing 'type' parameter");
              ok = false;
          }
          if (!ok) {
              writer.flush();
              writer.close();
              return (null);
          }
  
          // Update the configuration of our controller servlet
          getServlet().addMapping(mapping);
  
          // Return a successful response
          writer.println("OK");
          writer.flush();
          writer.close();
          return (null);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/ReloadAction.java
  
  Index: ReloadAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/ReloadAction.java,v 1.1 2000/10/07 22:55:14 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>reload()</code> method of our controller servlet to
   * reload its configuration information from the configuration
   * files (which have presumably been updated) dynamically.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:14 $
   */
  
  public class ReloadAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          try {
              getServlet().reload();
              writer.println("OK");
          } catch (IOException e) {
              writer.println("FAIL - " + e.toString());
              getServlet().log("ReloadAction", e);
          } catch (ServletException e) {
              writer.println("FAIL - " + e.toString());
              getServlet().log("ReloadAction", e);
          }
  
          writer.flush();
          writer.close();
  
          return (null);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/RemoveFormBeanAction.java
  
  Index: RemoveFormBeanAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/RemoveFormBeanAction.java,v 1.1 2000/10/07 22:55:14 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionFormBean;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>removeFormBean()</code> method of our controller servlet to remove an
   * action form definition dynamically.  The definition to be removed is
   * specified by the <code>name</code> requestparameter.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:14 $
   */
  
  public class RemoveFormBeanAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          String name = request.getParameter("name");
          if (name == null)
              writer.println("FAIL - Missing 'name' parameter");
          else {
              ActionFormBean formBean = getServlet().findFormBean(name);
              if (formBean == null)
                  writer.println("FAIL - Unknown form bean '" + name + "'");
              else {
                  getServlet().removeFormBean(formBean);
                  writer.println("OK");
              }
          }
  
          writer.flush();
          writer.close();
          return (null);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/RemoveForwardAction.java
  
  Index: RemoveForwardAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/RemoveForwardAction.java,v 1.1 2000/10/07 22:55:14 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>removeForward()</code> method of our controller servlet to remove an
   * action forward definition dynamically.  The definition to be removed is
   * specified by the <code>name</code> requestparameter.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:14 $
   */
  
  public class RemoveForwardAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          String name = request.getParameter("name");
          if (name == null)
              writer.println("FAIL - Missing 'name' parameter");
          else {
              ActionForward forward = getServlet().findForward(name);
              if (forward == null)
                  writer.println("FAIL - Unknown forward '" + name + "'");
              else {
                  getServlet().removeForward(forward);
                  writer.println("OK");
              }
          }
  
          writer.flush();
          writer.close();
          return (null);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/actions/RemoveMappingAction.java
  
  Index: RemoveMappingAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/actions/RemoveMappingAction.java,v 1.1 2000/10/07 22:55:14 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/07 22:55:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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.struts.actions;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  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.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  /**
   * <p>A standard <strong>Action</strong> that calls the
   * <code>removeMapping()</code> method of our controller servlet to remove an
   * action mapping definition dynamically.  The definition to be removed is
   * specified by the <code>path</code> requestparameter.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/07 22:55:14 $
   */
  
  public class RemoveMappingAction extends Action {
  
  
      // --------------------------------------------------------- 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 {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          String path = request.getParameter("path");
          if (path == null)
              writer.println("FAIL - Missing 'path' parameter");
          else {
              mapping = getServlet().findMapping(path);
              if (mapping == null)
                  writer.println("FAIL - Unknown mapping '" + path + "'");
              else {
                  getServlet().removeMapping(mapping);
                  writer.println("OK");
              }
          }
  
          writer.flush();
          writer.close();
          return (null);
  
      }
  
  
  }
  
  
  
  1.2       +20 -0     jakarta-struts/web/example/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/WEB-INF/struts-config.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- struts-config.xml	2000/09/20 04:13:01	1.1
  +++ struts-config.xml	2000/10/07 22:55:14	1.2
  @@ -89,6 +89,26 @@
         <forward name="success"         path="/editRegistration.do?action=Edit"/>
       </action>
   
  +
  +    <!-- The standard administrative actions available with Struts -->
  +    <!-- These would be either omitted or protected by security -->
  +    <!-- in a real application deployment -->
  +    <action    path="/admin/addFormBean"
  +               type="org.apache.struts.actions.AddFormBeanAction"/>
  +    <action    path="/admin/addForward"
  +               type="org.apache.struts.actions.AddForwardAction"/>
  +    <action    path="/admin/addMapping"
  +               type="org.apache.struts.actions.AddMappingAction"/>
  +    <action    path="/admin/reload"
  +               type="org.apache.struts.actions.ReloadAction"/>
  +    <action    path="/admin/removeFormBean"
  +               type="org.apache.struts.actions.RemoveFormBeanAction"/>
  +    <action    path="/admin/removeForward"
  +               type="org.apache.struts.actions.RemoveForwardAction"/>
  +    <action    path="/admin/removeMapping"
  +               type="org.apache.struts.actions.RemoveMappingAction"/>
  +
  +
     </action-mappings>
   
   </struts-config>
  
  
  

Mime
View raw message