rleland 2002/10/14 11:16:19 Modified: src/share/org/apache/struts/action Action.java src/share/org/apache/struts/taglib/bean StrutsTag.java src/share/org/apache/struts/taglib/html FormTag.java src/share/org/apache/struts/taglib/logic ForwardTag.java src/share/org/apache/struts/taglib/template InsertTag.java src/share/org/apache/struts/util RequestUtils.java Log: First round of factoring out getting ApplicationConfig from Request. Direct replacements. Revision Changes Path 1.48 +7 -16 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.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- Action.java 22 Sep 2002 05:46:51 -0000 1.47 +++ Action.java 14 Oct 2002 18:16:18 -0000 1.48 @@ -79,6 +79,7 @@ import org.apache.struts.config.ApplicationConfig; import org.apache.struts.taglib.html.Constants; import org.apache.struts.util.MessageResources; +import org.apache.struts.util.RequestUtils; /** @@ -526,12 +527,7 @@ // Identify the current application module ServletContext context = getServlet().getServletContext(); - ApplicationConfig appConfig = (ApplicationConfig) - request.getAttribute(Action.APPLICATION_KEY); - if (appConfig == null) { - appConfig = (ApplicationConfig) - context.getAttribute(Action.APPLICATION_KEY); - } + ApplicationConfig appConfig = RequestUtils.getApplicationConfig(request,context); // Return the requested data source instance return ((DataSource) context.getAttribute @@ -601,12 +597,7 @@ // Identify the current application module ServletContext context = getServlet().getServletContext(); - ApplicationConfig appConfig = (ApplicationConfig) - request.getAttribute(Action.APPLICATION_KEY); - if (appConfig == null) { - appConfig = (ApplicationConfig) - context.getAttribute(Action.APPLICATION_KEY); - } + ApplicationConfig appConfig = RequestUtils.getApplicationConfig(request,context); // Return the requested message resources instance return ((MessageResources) context.getAttribute 1.11 +5 -11 jakarta-struts/src/share/org/apache/struts/taglib/bean/StrutsTag.java Index: StrutsTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/StrutsTag.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- StrutsTag.java 22 Sep 2002 06:32:46 -0000 1.10 +++ StrutsTag.java 14 Oct 2002 18:16:18 -0000 1.11 @@ -177,13 +177,7 @@ } // Retrieve our application module configuration information - ApplicationConfig config = (ApplicationConfig) - pageContext.getRequest().getAttribute(Action.APPLICATION_KEY); - if (config == null) { // Backwards compatibility hack - config = (ApplicationConfig) - pageContext.getServletContext().getAttribute - (Action.APPLICATION_KEY); - } + ApplicationConfig config = RequestUtils.getApplicationConfig(pageContext); // Retrieve the requested object to be exposed Object object = null; 1.28 +6 -10 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.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- FormTag.java 10 Aug 2002 02:00:38 -0000 1.27 +++ FormTag.java 14 Oct 2002 18:16:18 -0000 1.28 @@ -848,12 +848,8 @@ protected void lookup() throws JspException { // Look up the application module configuration information we need - appConfig = (ApplicationConfig) - pageContext.getRequest().getAttribute(Action.APPLICATION_KEY); - if (appConfig == null) { // Backwards compatibility hack - appConfig = (ApplicationConfig) - pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY); - } + appConfig = RequestUtils.getApplicationConfig(pageContext); + if (appConfig == null) { JspException e = new JspException (messages.getMessage("formTag.collections")); 1.10 +5 -11 jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java Index: ForwardTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ForwardTag.java 23 Sep 2002 05:22:08 -0000 1.9 +++ ForwardTag.java 14 Oct 2002 18:16:18 -0000 1.10 @@ -136,13 +136,7 @@ // Look up the desired ActionForward entry ActionForward forward = null; - ApplicationConfig config = (ApplicationConfig) - pageContext.getRequest().getAttribute(Action.APPLICATION_KEY); - if (config == null) { // Backwards compatibility hack - config = (ApplicationConfig) - pageContext.getServletContext().getAttribute - (Action.APPLICATION_KEY); - } + ApplicationConfig config = RequestUtils.getApplicationConfig(pageContext); if (config != null) forward = (ActionForward) config.findForwardConfig(name); if (forward == null) { 1.12 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/template/InsertTag.java Index: InsertTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/InsertTag.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- InsertTag.java 12 Mar 2002 05:55:08 -0000 1.11 +++ InsertTag.java 14 Oct 2002 18:16:18 -0000 1.12 @@ -70,6 +70,7 @@ import org.apache.struts.action.Action; import org.apache.struts.config.ApplicationConfig; import org.apache.struts.taglib.template.util.*; +import org.apache.struts.util.RequestUtils; /** * This is the tag handler for <template:insert>, which includes @@ -146,8 +147,7 @@ public int doEndTag() throws JspException { String prefix = ""; - ApplicationConfig config = (ApplicationConfig) - pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY); + ApplicationConfig config = RequestUtils.getApplicationConfig(pageContext); if (config != null) { prefix = config.getPrefix(); } 1.60 +24 -13 jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java Index: RequestUtils.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- RequestUtils.java 13 Oct 2002 01:59:31 -0000 1.59 +++ RequestUtils.java 14 Oct 2002 18:16:19 -0000 1.60 @@ -387,15 +387,8 @@ } // Look up the application module configuration for this request - ApplicationConfig config = (ApplicationConfig) - pageContext.getRequest().getAttribute(Action.APPLICATION_KEY); - if (config == null) { // Backwards compatibility hack - config = (ApplicationConfig) - pageContext.getServletContext().getAttribute - (Action.APPLICATION_KEY); - pageContext.getRequest().setAttribute(Action.APPLICATION_KEY, - config); - } + ApplicationConfig config = getApplicationConfig(pageContext); + // Calculate the appropriate URL StringBuffer url = new StringBuffer(); @@ -1454,6 +1447,7 @@ * Return the ApplicationConfig object is it exists, null otherwise. * @param pageContext The page context. * @return the ApplicationConfig object + * @since 1.1b3 */ public static ApplicationConfig getApplicationConfig(PageContext pageContext) { ApplicationConfig appConfig = (ApplicationConfig) @@ -1462,6 +1456,23 @@ appConfig = (ApplicationConfig) pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY); } + return appConfig; + } + + /** + * Return the ApplicationConfig object is it exists, null otherwise. + * @param request The servlet request we are processing + * @param context The ServletContext for this web application + * @return the ApplicationConfig object + * @since 1.1b3 + */ + public static ApplicationConfig getApplicationConfig(HttpServletRequest request,ServletContext context) { + ApplicationConfig appConfig = (ApplicationConfig) + request.getAttribute(Action.APPLICATION_KEY); + if (appConfig == null) { + appConfig = (ApplicationConfig) + context.getAttribute(Action.APPLICATION_KEY); + } return appConfig; }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>