craigmcc    02/03/22 15:47:18

  Modified:    src/example/org/apache/struts/webapp/example/memory
                        MemoryDatabasePlugIn.java
               src/share/org/apache/struts/action Action.java
                        ActionServlet.java PlugIn.java
               src/share/org/apache/struts/config ApplicationConfig.java
               src/share/org/apache/struts/taglib/html FormTag.java
               src/share/org/apache/struts/upload
                        DiskMultipartRequestHandler.java
               src/share/org/apache/struts/validator ValidatorPlugIn.java
  Log:
  In order to make org.apache.struts.config.ApplicationConfig live up to the
  contract for "implements Serializable", it was necessary to remove references
  to non-Serializable objects (in particular, the ActionServlet and
  RequestProcessor objects).  An additional change will be necessary to the
  way that plug-ins are initialized, so that the "config" tree is pure
  configuration data, and thus can be serialized and deserialized on containers
  that do this to servlet context attributes.
  
  WARNING:  THIS REQUIRED A SMALL CHANGE TO THE PlugIn API!  Now, the init
  method signature takes two arguments (ActionServlet and ApplicationConfig)
  instead of just the ApplicationConfig.  Sorry about the breakage, but it
  is important to get this right before a 1.1 final release.
  
  PR: Bugzilla #7365
  Submitted by: Josh Spiewak <jspiewak at axeda.com>
  
  Revision  Changes    Path
  1.2       +7 -5      
jakarta-struts/src/example/org/apache/struts/webapp/example/memory/MemoryDatabasePlugIn.java
  
  Index: MemoryDatabasePlugIn.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/memory/MemoryDatabasePlugIn.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MemoryDatabasePlugIn.java 5 Mar 2002 04:23:57 -0000       1.1
  +++ MemoryDatabasePlugIn.java 22 Mar 2002 23:47:18 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/memory/MemoryDatabasePlugIn.java,v
 1.1 2002/03/05 04:23:57 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/05 04:23:57 $
  + * $Header: 
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/memory/MemoryDatabasePlugIn.java,v
 1.2 2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    * of your servlet container.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/05 04:23:57 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/22 23:47:18 $
    */
   
   public final class MemoryDatabasePlugIn implements PlugIn {
  @@ -178,18 +178,20 @@
       /**
        * Initialize and load our initial database from persistent storage.
        *
  +     * @param servlet The ActionServlet for this web application
        * @param config The ApplicationConfig for our owning sub-application
        *
        * @exception ServletException if we cannot configure ourselves correctly
        */
  -    public void init(ApplicationConfig config) throws ServletException {
  +    public void init(ActionServlet servlet, ApplicationConfig config)
  +        throws ServletException {
   
           log.info("Initializing memory database plug in from '" +
                    pathname + "'");
   
           // Remember our associated configuration and servlet
           this.config = config;
  -        this.servlet = config.getServlet();
  +        this.servlet = servlet;
   
           // Construct a new database and make it available
           database = new MemoryUserDatabase();
  
  
  
  1.37      +14 -4     jakarta-struts/src/share/org/apache/struts/action/Action.java
  
  Index: Action.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Action.java       22 Jan 2002 01:18:07 -0000      1.36
  +++ Action.java       22 Mar 2002 23:47:18 -0000      1.37
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.36 
2002/01/22 01:18:07 craigmcc Exp $
  - * $Revision: 1.36 $
  - * $Date: 2002/01/22 01:18:07 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.37 
2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.37 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -109,7 +109,7 @@
    * by this Action.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.36 $ $Date: 2002/01/22 01:18:07 $
  + * @version $Revision: 1.37 $ $Date: 2002/03/22 23:47:18 $
    */
   
   public class Action {
  @@ -255,6 +255,16 @@
        */
       public static final String MULTIPART_KEY =
           "org.apache.struts.action.mapping.multipartclass";
  +
  +
  +    /**
  +     * <p>The base of the context attributes key under which our
  +     * <code>RequestProcessor</code> instance will be stored.  This
  +     * will be suffixed with the actual application prefix (including the
  +     * leading "/" character) to form the actual attributes key.</p>
  +     */
  +    public static final String REQUEST_PROCESSOR_KEY =
  +        "org.apache.struts.action.REQUEST_PROCESSOR";
   
   
       /**
  
  
  
  1.98      +41 -8     
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.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- ActionServlet.java        14 Mar 2002 06:15:55 -0000      1.97
  +++ ActionServlet.java        22 Mar 2002 23:47:18 -0000      1.98
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.97 
2002/03/14 06:15:55 craigmcc Exp $
  - * $Revision: 1.97 $
  - * $Date: 2002/03/14 06:15:55 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.98 
2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.98 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -269,7 +269,7 @@
    *
    * @author Craig R. McClanahan
    * @author Ted Husted
  - * @version $Revision: 1.97 $ $Date: 2002/03/14 06:15:55 $
  + * @version $Revision: 1.98 $ $Date: 2002/03/22 23:47:18 $
    */
   
   public class ActionServlet
  @@ -651,7 +651,7 @@
               if (value instanceof ApplicationConfig) {
                   ApplicationConfig config = (ApplicationConfig) value;
                   try {
  -                    config.getProcessor().destroy();
  +                    getRequestProcessor(config).destroy();
                   } catch (Throwable t) {
                       ;
                   }
  @@ -738,6 +738,39 @@
   
   
       /**
  +     * Look up and return the {@link RequestProcessor} responsible for the
  +     * specified sub-application, creating a new one if necessary.
  +     *
  +     * @param appConfig The sub-application configuration for which to
  +     *  acquire and return a RequestProcessor.
  +     *
  +     * @exception ServletException if we cannot instantiate a RequestProcessor
  +     *  instance
  +     */
  +    protected synchronized RequestProcessor
  +        getRequestProcessor(ApplicationConfig config) throws ServletException {
  +
  +        String key = Action.REQUEST_PROCESSOR_KEY + config.getPrefix();
  +        RequestProcessor processor = (RequestProcessor)
  +            getServletContext().getAttribute(key);
  +        if (processor == null) {
  +            try {
  +                processor = (RequestProcessor)
  +                    RequestUtils.applicationInstance
  +                    (config.getControllerConfig().getProcessorClass());
  +                processor.init(this, config);
  +                getServletContext().setAttribute(key, processor);
  +            } catch (Throwable t) {
  +                throw new UnavailableException
  +                    ("Cannot initialize RequestProcessor of class " +
  +                     config.getControllerConfig().getProcessorClass()
  +                     + ": " + t);
  +            }
  +        }
  +        return (processor);
  +
  +    }
  +    /**
        * <p>Initialize the application configuration information for the
        * specified sub-application.</p>
        *
  @@ -760,7 +793,7 @@
           InputStream input = null;
           String mapping = null;
           try {
  -            config = new ApplicationConfig(prefix, this);
  +            config = new ApplicationConfig(prefix);
   
               // Support for application-wide ActionMapping override
               mapping = getServletConfig().getInitParameter("mapping");
  @@ -881,7 +914,7 @@
   
           PlugIn plugIns[] = config.findPlugIns();
           for (int i = 0; i < plugIns.length; i++) {
  -            plugIns[i].init(config);
  +            plugIns[i].init(this, config);
           }
   
   
  @@ -1106,7 +1139,7 @@
           throws IOException, ServletException {
   
           RequestUtils.selectApplication(request, getServletContext());
  -        getApplicationConfig(request).getProcessor().process
  +        getRequestProcessor(getApplicationConfig(request)).process
               (request, response);
   
       }
  
  
  
  1.2       +8 -5      jakarta-struts/src/share/org/apache/struts/action/PlugIn.java
  
  Index: PlugIn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/PlugIn.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlugIn.java       23 Feb 2002 22:54:17 -0000      1.1
  +++ PlugIn.java       22 Mar 2002 23:47:18 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/PlugIn.java,v 1.1 
2002/02/23 22:54:17 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/23 22:54:17 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/PlugIn.java,v 1.2 
2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -83,7 +83,7 @@
    * been called before the <code>init()</code> method is invoked.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/02/23 22:54:17 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/22 23:47:18 $
    */
   
   public interface PlugIn {
  @@ -100,13 +100,16 @@
        * <p>Receive notification that the specified sub-applicaiton is being
        * started up.</p>
        *
  +     * @param servlet ActionServlet that is managing all the sub-applications
  +     *  in this web application
        * @param config ApplicationConfig for the sub-application with which
        *  this plug in is associated
        *
        * @exception ServletException if this <code>PlugIn</code> cannot
        *  be successfully initialized
        */
  -    public void init(ApplicationConfig config) throws ServletException;
  +    public void init(ActionServlet servlet, ApplicationConfig config)
  +        throws ServletException;
   
   
   }
  
  
  
  1.13      +5 -47     
jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java
  
  Index: ApplicationConfig.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ApplicationConfig.java    10 Mar 2002 01:23:30 -0000      1.12
  +++ ApplicationConfig.java    22 Mar 2002 23:47:18 -0000      1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v 
1.12 2002/03/10 01:23:30 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2002/03/10 01:23:30 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v 
1.13 2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.13 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -68,10 +68,7 @@
   import java.util.HashMap;
   import javax.servlet.ServletException;
   import javax.servlet.UnavailableException;
  -import org.apache.struts.action.ActionServlet;
   import org.apache.struts.action.PlugIn;
  -import org.apache.struts.action.RequestProcessor;
  -import org.apache.struts.util.RequestUtils;
    
   
   
  @@ -85,7 +82,7 @@
    * previous Struts behavior that only supported one application.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.12 $ $Date: 2002/03/10 01:23:30 $
  + * @version $Revision: 1.13 $ $Date: 2002/03/22 23:47:18 $
    * @since Struts 1.1
    */
   
  @@ -100,13 +97,11 @@
        * parameter values.
        *
        * @param prefix Context-relative URI prefix for this application
  -     * @param servlet ActionServlet that is managing this application
        */
  -    public ApplicationConfig(String prefix, ActionServlet servlet) {
  +    public ApplicationConfig(String prefix) {
   
           super();
           this.prefix = prefix;
  -        this.servlet = servlet;
   
       }
   
  @@ -208,43 +203,6 @@
   
       public String getPrefix() {
           return (this.prefix);
  -    }
  -
  -
  -    /**
  -     * The initialized RequestProcessor instance to be used for processing
  -     * requests for this application.
  -     */
  -    protected RequestProcessor processor = null;
  -
  -    public synchronized RequestProcessor getProcessor()
  -        throws ServletException {
  -
  -        if (processor == null) {
  -            try {
  -                processor = (RequestProcessor)
  -                    RequestUtils.applicationInstance
  -                    (getControllerConfig().getProcessorClass());
  -                processor.init(servlet, this);
  -            } catch (Throwable t) {
  -                throw new UnavailableException
  -                    ("Cannot initialize RequestProcessor of class " +
  -                     getControllerConfig().getProcessorClass() + ": " + t);
  -            }
  -        }
  -        return (this.processor);
  -
  -    }
  -
  -
  -    /**
  -     * The <code>ActionServlet</code> instance that is managing this
  -     * application.
  -     */
  -    protected ActionServlet servlet = null;
  -
  -    public ActionServlet getServlet() {
  -        return (this.servlet);
       }
   
   
  
  
  
  1.19      +6 -5      
jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java
  
  Index: FormTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- FormTag.java      28 Jan 2002 06:07:38 -0000      1.18
  +++ FormTag.java      22 Mar 2002 23:47:18 -0000      1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java,v 1.18 
2002/01/28 06:07:38 martinc Exp $
  - * $Revision: 1.18 $
  - * $Date: 2002/01/28 06:07:38 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java,v 1.19 
2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.19 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -88,7 +88,7 @@
    * properties correspond to the various fields of the form.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.18 $ $Date: 2002/01/28 06:07:38 $
  + * @version $Revision: 1.19 $ $Date: 2002/03/22 23:47:18 $
    */
   
   public class FormTag extends TagSupport {
  @@ -819,7 +819,8 @@
                                        PageContext.REQUEST_SCOPE);
               throw e;
           }
  -        servlet = appConfig.getServlet();
  +        servlet = (ActionServlet)
  +            pageContext.getServletContext().getAttribute(Action.ACTION_SERVLET_KEY);
   
           // Look up the action mapping we will be submitting to
           String mappingName = getActionMappingName();
  
  
  
  1.15      +2 -3      
jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java
  
  Index: DiskMultipartRequestHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DiskMultipartRequestHandler.java  9 Mar 2002 22:26:35 -0000       1.14
  +++ DiskMultipartRequestHandler.java  22 Mar 2002 23:47:18 -0000      1.15
  @@ -229,8 +229,7 @@
       protected void retrieveTempDir(ApplicationConfig appConfig) { 
           
           //attempt to retrieve the servlet container's temporary directory
  -        ServletContext context =
  -            appConfig.getServlet().getServletContext();
  +        ServletContext context = getServlet().getServletContext();
          
           try {
               tempDir =
  @@ -248,7 +247,7 @@
                   //default to system-wide tempdir
                   tempDir = System.getProperty("java.io.tmpdir");
   
  -                if (appConfig.getServlet().getDebug() > 1) {
  +                if (getServlet().getDebug() > 1) {
                       log.debug("DiskMultipartRequestHandler.handleRequest(): " +
                       "defaulting to java.io.tmpdir directory \"" +
                       tempDir);
  
  
  
  1.2       +7 -5      
jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java
  
  Index: ValidatorPlugIn.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValidatorPlugIn.java      18 Mar 2002 01:42:51 -0000      1.1
  +++ ValidatorPlugIn.java      22 Mar 2002 23:47:18 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java,v 
1.1 2002/03/18 01:42:51 dwinterfeldt Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 01:42:51 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java,v 
1.2 2002/03/22 23:47:18 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/22 23:47:18 $
    *
    * ====================================================================
    *
  @@ -152,15 +152,17 @@
       /**
        * Initialize and load our resources.
        *
  +     * @param servlet The ActionServlet for our application
        * @param config The ApplicationConfig for our owning sub-application
        *
        * @exception ServletException if we cannot configure ourselves correctly
       */
  -    public void init(ApplicationConfig config) throws ServletException {
  +    public void init(ActionServlet servlet, ApplicationConfig config)
  +        throws ServletException {
   
           // Remember our associated configuration and servlet
           this.config = config;
  -        this.servlet = config.getServlet();
  +        this.servlet = servlet;
   
        // Load our database from persistent storage
        try {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to