rleland 2002/11/06 21:18:27 Modified: src/share/org/apache/struts Globals.java src/share/org/apache/struts/action Action.java src/share/org/apache/struts/config ApplicationConfig.java ConfigRuleSet.java src/share/org/apache/struts/upload CommonsMultipartRequestHandler.java DiskMultipartRequestHandler.java Log: Bug 14054 Checked in More ApplicationConfig->ModuleConfig Tested using struts-example, struts-validator,struts-upload This will require users to recompile, since some public fields were added. Revision Changes Path 1.3 +28 -10 jakarta-struts/src/share/org/apache/struts/Globals.java Index: Globals.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/Globals.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Globals.java 24 Jul 2002 05:31:29 -0000 1.2 +++ Globals.java 7 Nov 2002 05:18:26 -0000 1.3 @@ -97,19 +97,37 @@ /** * <p>The base of the context attributes key under which our - * <code>ApplicationConfig</code> data structure will be stored. This + * <code>ModuleConfig</code> data structure will be stored. This * will be suffixed with the actual module prefix (including the * leading "/" character) to form the actual attributes key.</p> * * <p>For each request processed by the controller servlet, the - * <code>ApplicationConfig</code> object for the module selected by + * <code>ModuleConfig</code> object for the module selected by * the request URI currently being processed will also be exposed under * this key as a request attribute.</p> * * @since Struts 1.1 + * @deprecated Use MODULE_KEY */ public static final String APPLICATION_KEY = - "org.apache.struts.action.APPLICATION"; + "org.apache.struts.action.MODULE"; + + + /** + * <p>The base of the context attributes key under which our + * <code>ModuleConfig</code> data structure will be stored. This + * will be suffixed with the actual module prefix (including the + * leading "/" character) to form the actual attributes key.</p> + * + * <p>For each request processed by the controller servlet, the + * <code>ModuleConfig</code> object for the module selected by + * the request URI currently being processed will also be exposed under + * this key as a request attribute.</p> + * + * @since Struts 1.1 + */ + public static final String MODULE_KEY = + "org.apache.struts.action.MODULE"; /** @@ -147,7 +165,7 @@ * is normally stored, unless overridden when initializing our * ActionServlet. * - * @deprecated Replaced by collection in ApplicationConfig + * @deprecated Replaced by collection in ModuleConfig */ public static final String FORM_BEANS_KEY = "org.apache.struts.action.FORM_BEANS"; @@ -159,7 +177,7 @@ * is normally stored, unless overridden when initializing our * ActionServlet. * - * @deprecated Replaced by collection in ApplicationConfig. + * @deprecated Replaced by collection in ModuleConfig. */ public static final String FORWARDS_KEY = "org.apache.struts.action.FORWARDS"; @@ -191,7 +209,7 @@ * is normally stored, unless overridden when initializing our * ActionServlet. * - * @deprecated Replaced by collection in ApplicationConfig + * @deprecated Replaced by collection in ModuleConfig */ public static final String MAPPINGS_KEY = "org.apache.struts.action.MAPPINGS"; 1.51 +30 -25 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.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- Action.java 30 Oct 2002 02:30:31 -0000 1.50 +++ Action.java 7 Nov 2002 05:18:26 -0000 1.51 @@ -76,7 +76,7 @@ import javax.servlet.http.HttpSession; import javax.sql.DataSource; import org.apache.struts.Globals; -import org.apache.struts.config.ApplicationConfig; +import org.apache.struts.config.ModuleConfig; import org.apache.struts.taglib.html.Constants; import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; @@ -139,16 +139,17 @@ /** * <p>The base of the context attributes key under which our - * <code>ApplicationConfig</code> data structure will be stored. This + * <code>ModuleConfig</code> data structure will be stored. This * will be suffixed with the actual module prefix (including the * leading "/" character) to form the actual attributes key.</p> * * <p>For each request processed by the controller servlet, the - * <code>ApplicationConfig</code> object for the module selected by + * <code>ModuleConfig</code> object for the module selected by * the request URI currently being processed will also be exposed under * this key as a request attribute.</p> * * @since Struts 1.1 + * @deprecated Replaced by {@link org.apache.struts.Globals#MODULE_KEY} */ public static final String APPLICATION_KEY = Globals.APPLICATION_KEY; @@ -158,6 +159,7 @@ * configured data source (which must implement * <code>javax.sql.DataSource</code>) is stored, * if one is configured for this module. + * @deprecated Replaced by {@link org.apache.struts.Globals#DATA_SOURCE_KEY} */ public static final String DATA_SOURCE_KEY = Globals.DATA_SOURCE_KEY; @@ -166,6 +168,7 @@ * The request attributes key under which your action should store an * <code>org.apache.struts.action.ActionErrors</code> object, if you * are using the corresponding custom tag library elements. + * @deprecated Replaced by {@link org.apache.struts.Globals#ERROR_KEY} */ public static final String ERROR_KEY = Globals.ERROR_KEY; @@ -175,6 +178,7 @@ * <code>Throwable</code> that caused them to report a JspException at * runtime. This value can be used on an error page to provide more * detailed information about what really went wrong. + * @deprecated Replaced by {@link org.apache.struts.Globals#EXCEPTION_KEY} */ public static final String EXCEPTION_KEY = Globals.EXCEPTION_KEY; @@ -185,7 +189,7 @@ * is normally stored, unless overridden when initializing our * ActionServlet. * - * @deprecated Replaced by collection in ApplicationConfig + * @deprecated Replaced by collection in ModuleConfig */ public static final String FORM_BEANS_KEY = Globals.FORM_BEANS_KEY; @@ -196,7 +200,7 @@ * is normally stored, unless overridden when initializing our * ActionServlet. * - * @deprecated Replaced by collection in ApplicationConfig. + * @deprecated Replaced by collection in ModuleConfig. */ public static final String FORWARDS_KEY = Globals.FORWARDS_KEY; @@ -207,6 +211,7 @@ * attribute is found, the system default locale * will be used when retrieving internationalized messages. If used, this * attribute is typically set during user login processing. + * @deprecated Replaced by {@link org.apache.struts.Globals#LOCALE_KEY} */ public static final String LOCALE_KEY = Globals.LOCALE_KEY; @@ -215,6 +220,7 @@ * The request attributes key under which our * <code>org.apache.struts.ActionMapping</code> instance * is passed. + * @deprecated Replaced by {@link org.apache.struts.Globals#MAPPING_KEY} */ public static final String MAPPING_KEY = Globals.MAPPING_KEY; @@ -225,7 +231,7 @@ * is normally stored, unless overridden when initializing our * ActionServlet. * - * @deprecated Replaced by collection in ApplicationConfig + * @deprecated Replaced by collection in ModuleConfig */ public static final String MAPPINGS_KEY = Globals.MAPPINGS_KEY; @@ -236,6 +242,7 @@ * are using the corresponding custom tag library elements. * * @since Struts 1.1 + * @deprecated Replaced by {@link org.apache.struts.Globals#MESSAGE_KEY} */ public static final String MESSAGE_KEY = Globals.MESSAGE_KEY; @@ -497,7 +504,7 @@ /** - * Return the default data source for the current application module. + * Return the default data source for the current module. * * @param request The servlet request we are processing * @@ -512,8 +519,7 @@ /** - * Return the specified data source for the current application - * module. + * Return the specified data source for the current module. * * @param request The servlet request we are processing * @param key The key specified in the @@ -525,13 +531,13 @@ protected DataSource getDataSource(HttpServletRequest request, String key) { - // Identify the current application module + // Identify the current module ServletContext context = getServlet().getServletContext(); - ApplicationConfig appConfig = RequestUtils.getModuleConfig(request,context); + ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request,context); // Return the requested data source instance return ((DataSource) context.getAttribute - (key + appConfig.getPrefix())); + (key + moduleConfig.getPrefix())); } @@ -553,11 +559,11 @@ /** - * Return the message resources for the default application module. + * Return the message resources for the default module. * * @deprecated This method can only return the resources for the default - * application module. Use getResources(HttpServletRequest) to get the - * resources for the current application module. + * module. Use getResources(HttpServletRequest) to get the + * resources for the current module. */ protected MessageResources getResources() { @@ -568,7 +574,7 @@ /** - * Return the default message resources for the current application module. + * Return the default message resources for the current module. * * @param request The servlet request we are processing * @since Struts 1.1 @@ -582,8 +588,7 @@ /** - * Return the specified message resources for the current application - * module. + * Return the specified message resources for the current module. * * @param request The servlet request we are processing * @param key The key specified in the @@ -595,13 +600,13 @@ protected MessageResources getResources(HttpServletRequest request, String key) { - // Identify the current application module + // Identify the current module ServletContext context = getServlet().getServletContext(); - ApplicationConfig appConfig = RequestUtils.getModuleConfig(request,context); + ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request,context); // Return the requested message resources instance return ((MessageResources) context.getAttribute - (key + appConfig.getPrefix())); + (key + moduleConfig.getPrefix())); } 1.19 +5 -4 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.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ApplicationConfig.java 6 Nov 2002 04:48:29 -0000 1.18 +++ ApplicationConfig.java 7 Nov 2002 05:18:26 -0000 1.19 @@ -77,6 +77,7 @@ * @author Craig R. McClanahan * @version $Revision$ $Date$ * @since Struts 1.1 + * @deprecated Usage replaced by ModuleConfig Interface. */ public class ApplicationConfig extends ModuleConfigImpl { 1.13 +11 -11 jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java Index: ConfigRuleSet.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ConfigRuleSet.java 9 Jul 2002 23:57:37 -0000 1.12 +++ ConfigRuleSet.java 7 Nov 2002 05:18:26 -0000 1.13 @@ -91,7 +91,7 @@ * specified <code>Digester</code> instance, associating them with * our namespace URI (if any). This method should only be called * by a Digester instance. These rules assume that an instance of - * <code>org.apache.struts.config.ApplicationConfig</code> is pushed + * <code>org.apache.struts.config.ModuleConfig</code> is pushed * onto the evaluation stack before parsing begins.</p> * * @param digester Digester instance to which the new Rule instances @@ -318,7 +318,7 @@ /** * Class that sets the name of the class to use when creating action mapping * instances. The value is set on the object on the top of the stack, which - * must be a <code>org.apache.struts.config.ApplicationConfig</code>. + * must be a <code>org.apache.struts.config.ModuleConfig</code>. */ final class SetActionMappingClassRule extends Rule { @@ -329,8 +329,8 @@ public void begin(Attributes attributes) throws Exception { String className = attributes.getValue("type"); if (className != null) { - ApplicationConfig ac = (ApplicationConfig) digester.peek(); - ac.setActionMappingClass(className); + ModuleConfig mc = (ModuleConfig) digester.peek(); + mc.setActionMappingClass(className); } } @@ -342,7 +342,7 @@ * into account the default class name, which may have been specified on the * parent element and which is made available through the object on the top * of the stack, which must be a - * <code>org.apache.struts.config.ApplicationConfig</code>. + * <code>org.apache.struts.config.ModuleConfig</code>. */ final class ActionMappingFactory extends AbstractObjectCreationFactory { @@ -351,8 +351,8 @@ // Identify the name of the class to instantiate String className = attributes.getValue("className"); if (className == null) { - ApplicationConfig ac = (ApplicationConfig) digester.peek(); - className = ac.getActionMappingClass(); + ModuleConfig mc = (ModuleConfig) digester.peek(); + className = mc.getActionMappingClass(); } // Instantiate the new object and return it 1.4 +15 -16 jakarta-struts/src/share/org/apache/struts/upload/CommonsMultipartRequestHandler.java Index: CommonsMultipartRequestHandler.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/upload/CommonsMultipartRequestHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CommonsMultipartRequestHandler.java 17 Oct 2002 00:49:25 -0000 1.3 +++ CommonsMultipartRequestHandler.java 7 Nov 2002 05:18:26 -0000 1.4 @@ -67,7 +67,6 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.io.IOException; -import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -82,7 +81,7 @@ import org.apache.struts.action.Action; import org.apache.struts.action.ActionServlet; import org.apache.struts.action.ActionMapping; -import org.apache.struts.config.ApplicationConfig; +import org.apache.struts.config.ModuleConfig; /** @@ -211,7 +210,7 @@ throws ServletException { // Get the app config for the current request. - ApplicationConfig ac = (ApplicationConfig) request.getAttribute( + ModuleConfig ac = (ModuleConfig) request.getAttribute( Action.APPLICATION_KEY); // Create and configure a FileUpload instance. @@ -320,13 +319,13 @@ * Returns the maximum allowable size, in bytes, of an uploaded file. The * value is obtained from the current module's controller configuration. * - * @param ac The current module's application configuration. + * @param mc The current module's configuration. * * @return The maximum allowable file size, in bytes. */ - protected long getSizeMax(ApplicationConfig ac) { + protected long getSizeMax(ModuleConfig mc) { - String sizeString = ac.getControllerConfig().getMaxFileSize(); + String sizeString = mc.getControllerConfig().getMaxFileSize(); int multiplier = 1; if (sizeString.endsWith("K")) { @@ -345,7 +344,7 @@ size = Long.parseLong(sizeString); } catch (NumberFormatException nfe) { log.warn("Invalid format for maximum file size ('" - + ac.getControllerConfig().getMaxFileSize() + + mc.getControllerConfig().getMaxFileSize() + "'). Using default."); size = DEFAULT_SIZE_MAX; multiplier = 1; @@ -359,11 +358,11 @@ * Returns the size threshold which determines whether an uploaded file * will be written to disk or cached in memory. * - * @param ac The current module's application configuration. + * @param mc The current module's configuration. * * @return The size threshold, in bytes. */ - protected int getSizeThreshold(ApplicationConfig ac) { + protected int getSizeThreshold(ModuleConfig mc) { return DEFAULT_SIZE_THRESHOLD; } @@ -383,15 +382,15 @@ * property.</li> * (/ol> * - * @param ac The application config instance for which the path should be + * @param mc The module config instance for which the path should be * determined. * * @return The path to the directory to be used to store uploaded files. */ - protected String getRepositoryPath(ApplicationConfig ac) { + protected String getRepositoryPath(ModuleConfig mc) { // First, look for an explicitly defined temp dir. - String tempDir = ac.getControllerConfig().getTempDir(); + String tempDir = mc.getControllerConfig().getTempDir(); // If none, look for a container specified temp dir. if (tempDir == null || tempDir.length() == 0) { 1.20 +10 -13 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- DiskMultipartRequestHandler.java 6 Jul 2002 04:44:07 -0000 1.19 +++ DiskMultipartRequestHandler.java 7 Nov 2002 05:18:26 -0000 1.20 @@ -63,9 +63,6 @@ import java.io.File; import java.io.IOException; -import java.io.FileOutputStream; -import java.io.ByteArrayInputStream; -import java.io.UnsupportedEncodingException; import java.util.Hashtable; import java.util.Enumeration; import javax.servlet.ServletContext; @@ -76,7 +73,7 @@ import org.apache.struts.action.Action; import org.apache.struts.action.ActionServlet; import org.apache.struts.action.ActionMapping; -import org.apache.struts.config.ApplicationConfig; +import org.apache.struts.config.ModuleConfig; /** * This is a MultipartRequestHandler that writes file data directly to @@ -130,12 +127,12 @@ */ public void handleRequest(HttpServletRequest request) throws ServletException { - ApplicationConfig appConfig = (ApplicationConfig) request.getAttribute(Action.APPLICATION_KEY); - retrieveTempDir(appConfig); + ModuleConfig moduleConfig = (ModuleConfig) request.getAttribute(Action.APPLICATION_KEY); + retrieveTempDir(moduleConfig); try { - MultipartIterator iterator = new MultipartIterator(request, appConfig.getControllerConfig().getBufferSize(), - getMaxSize(appConfig.getControllerConfig().getMaxFileSize()), + MultipartIterator iterator = new MultipartIterator(request, moduleConfig.getControllerConfig().getBufferSize(), + getMaxSize(moduleConfig.getControllerConfig().getMaxFileSize()), tempDir); MultipartElement element; @@ -288,7 +285,7 @@ * Retrieves the temporary directory from either ActionServlet, a context * property, or a system property, in that order. */ - protected void retrieveTempDir(ApplicationConfig appConfig) { + protected void retrieveTempDir(ModuleConfig moduleConfig) { //attempt to retrieve the servlet container's temporary directory ActionServlet servlet = getServlet(); @@ -307,7 +304,7 @@ if (tempDir == null) { //attempt to retrieve the temporary directory from the controller - tempDir = appConfig.getControllerConfig().getTempDir(); + tempDir = moduleConfig.getControllerConfig().getTempDir(); if (tempDir == null) { //default to system-wide tempdir
-- To unsubscribe, e-mail: <mailto:struts-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-dev-help@;jakarta.apache.org>