View Javadoc

1   /*
2    * $Id: ActionServletWrapper.java 421119 2006-07-12 04:49:11Z wsmoak $
3    *
4    * Copyright 2000-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts.action;
19  
20  import org.apache.struts.upload.MultipartRequestHandler;
21  
22  import java.io.Serializable;
23  
24  /***
25   * <p>Provide a wrapper around an {@link ActionServlet} to expose only those
26   * methods needed by other objects. When used with an {@link ActionForm},
27   * subclasses must be careful that they do not return an object with public
28   * getters and setters that could be exploited by automatic population of
29   * properties.</p>
30   *
31   * @version $Rev: 421119 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
32   *          $
33   * @since Struts 1.0.1
34   */
35  public class ActionServletWrapper implements Serializable {
36      /***
37       * <p>The servlet instance to which we are attached.</p>
38       */
39      protected transient ActionServlet servlet = null;
40  
41      /***
42       * <p>Create object and set <code>servlet</code> property.</p>
43       *
44       * @param servlet <code>ActionServlet</code> to wrap
45       */
46      public ActionServletWrapper(ActionServlet servlet) {
47          super();
48          this.servlet = servlet;
49      }
50  
51      /***
52       * <p>Set servlet to a <code>MultipartRequestHandler</code>.</p>
53       *
54       * @param object The MultipartRequestHandler
55       */
56      public void setServletFor(MultipartRequestHandler object) {
57          object.setServlet(this.servlet);
58  
59          // :FIXME: Should this be based on an "setServlet"
60          // interface or introspection for a setServlet method?
61          // Or, is it safer to just add the types we want as we want them?
62      }
63  }