Author: mrdon Date: Tue Sep 25 03:39:07 2007 New Revision: 579186 URL: http://svn.apache.org/viewvc?rev=579186&view=rev Log: Cleaning up unnecessary dispatcher.getInstance calls, spelling cleanups WW-1715
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/I18n.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/TagModel.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java struts/struts2/trunk/core/src/site/resources/tags/i18n.html struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormResetInterceptor.java struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormValidationInterceptor.java struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/Struts1Action.java struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/I18n.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/I18n.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/I18n.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/I18n.java Tue Sep 25 03:39:07 2007 @@ -33,6 +33,8 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.LocaleProvider; import com.opensymphony.xwork2.TextProviderFactory; +import com.opensymphony.xwork2.inject.Container; +import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.LocalizedTextUtil; import com.opensymphony.xwork2.util.ValueStack; @@ -86,10 +88,16 @@ public class I18n extends Component { protected boolean pushed; protected String name; + protected Container container; public I18n(ValueStack stack) { super(stack); } + + @Inject + public void setContainer(Container container) { + this.container = container; + } public boolean start(Writer writer) { boolean result = super.start(writer); @@ -105,7 +113,7 @@ if (bundle != null) { final Locale locale = (Locale) getStack().getContext().get(ActionContext.LOCALE); TextProviderFactory tpf = new TextProviderFactory(); - Dispatcher.getInstance().getContainer().inject(tpf); + container.inject(tpf); getStack().push(tpf.createInstance(bundle, new LocaleProvider() { public Locale getLocale() { return locale; @@ -129,7 +137,7 @@ return super.end(writer, body); } - @StrutsTagAttribute(description="Name of ressource bundle to use (eg foo/bar/customBundle)", required=true, defaultValue="String") + @StrutsTagAttribute(description="Name of resource bundle to use (eg foo/bar/customBundle)", required=true, defaultValue="String") public void setName(String name) { this.name = name; } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/TagModel.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/TagModel.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/TagModel.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/TagModel.java Tue Sep 25 03:39:07 2007 @@ -34,6 +34,7 @@ import org.apache.struts2.components.Component; import org.apache.struts2.dispatcher.Dispatcher; +import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.util.ValueStack; @@ -60,7 +61,7 @@ public Writer getWriter(Writer writer, Map params) throws TemplateModelException, IOException { Component bean = getBean(); - Container container = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getContainer(); + Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); Map unwrappedParameters = unwrapParameters(params); Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java Tue Sep 25 03:39:07 2007 @@ -38,6 +38,7 @@ import org.apache.velocity.runtime.directive.Directive; import org.apache.velocity.runtime.parser.node.Node; +import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.util.ValueStack; @@ -63,7 +64,7 @@ HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); - Container container = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getContainer(); + Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); Modified: struts/struts2/trunk/core/src/site/resources/tags/i18n.html URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/i18n.html?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/core/src/site/resources/tags/i18n.html (original) +++ struts/struts2/trunk/core/src/site/resources/tags/i18n.html Tue Sep 25 03:39:07 2007 @@ -33,7 +33,7 @@ <td align="left" valign="top">String</td> <td align="left" valign="top">false</td> <td align="left" valign="top">String</td> - <td align="left" valign="top">Name of ressource bundle to use (eg foo/bar/customBundle)</td> + <td align="left" valign="top">Name of resource bundle to use (eg foo/bar/customBundle)</td> </tr> </table> <!-- END SNIPPET: tagattributes --> Modified: struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormResetInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormResetInterceptor.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormResetInterceptor.java (original) +++ struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormResetInterceptor.java Tue Sep 25 03:39:07 2007 @@ -26,6 +26,8 @@ import org.apache.struts2.dispatcher.Dispatcher; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.config.Configuration; +import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import com.opensymphony.xwork2.interceptor.ScopedModelDriven; @@ -34,6 +36,13 @@ */ public class ActionFormResetInterceptor extends AbstractInterceptor { + protected Configuration configuration; + + @Inject + public void setConfiguration(Configuration config) { + this.configuration = config; + } + @Override public String intercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); @@ -42,7 +51,7 @@ ScopedModelDriven modelDriven = (ScopedModelDriven) action; Object model = modelDriven.getModel(); if (model != null && model instanceof ActionForm) { - Struts1Factory factory = new Struts1Factory(Dispatcher.getInstance().getConfigurationManager().getConfiguration()); + Struts1Factory factory = new Struts1Factory(configuration); ActionMapping mapping = factory.createActionMapping(invocation.getProxy().getConfig()); HttpServletRequest req = ServletActionContext.getRequest(); ((ActionForm)model).reset(mapping, req); Modified: struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormValidationInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormValidationInterceptor.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormValidationInterceptor.java (original) +++ struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/ActionFormValidationInterceptor.java Tue Sep 25 03:39:07 2007 @@ -48,6 +48,8 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.config.Configuration; +import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import com.opensymphony.xwork2.interceptor.ScopedModelDriven; @@ -69,6 +71,13 @@ */ private final static String RESOURCE_DELIM = ","; + protected Configuration configuration; + + @Inject + public void setConfiguration(Configuration config) { + this.configuration = config; + } + /** * Initializes the validation resources */ @@ -113,7 +122,7 @@ Object model = modelDriven.getModel(); if (model != null) { HttpServletRequest req = ServletActionContext.getRequest(); - Struts1Factory strutsFactory = new Struts1Factory(Dispatcher.getInstance().getConfigurationManager().getConfiguration()); + Struts1Factory strutsFactory = new Struts1Factory(configuration); ActionMapping mapping = strutsFactory.createActionMapping(invocation.getProxy().getConfig()); ModuleConfig moduleConfig = strutsFactory.createModuleConfig(invocation.getProxy().getConfig().getPackageName()); req.setAttribute(Globals.MODULE_KEY, moduleConfig); Modified: struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/Struts1Action.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/Struts1Action.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/Struts1Action.java (original) +++ struts/struts2/trunk/plugins/struts1/src/main/java/org/apache/struts2/s1/Struts1Action.java Tue Sep 25 03:39:07 2007 @@ -37,6 +37,7 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.interceptor.ScopedModelDriven; @@ -63,10 +64,16 @@ private boolean validate; private String scopeKey; private ObjectFactory objectFactory; + private Configuration configuration; @Inject public void setObjectFactory(ObjectFactory fac) { this.objectFactory = fac; + } + + @Inject + public void setConfiguration(Configuration config) { + this.configuration = config; } public String execute() throws Exception { Modified: struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java?rev=579186&r1=579185&r2=579186&view=diff ============================================================================== --- struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java (original) +++ struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java Tue Sep 25 03:39:07 2007 @@ -20,6 +20,7 @@ */ package org.apache.struts2.tiles; +import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.inject.Container; import org.apache.commons.logging.Log; @@ -102,17 +103,14 @@ HttpServletRequest request = (HttpServletRequest) getRequest(); HttpServletResponse response = (HttpServletResponse) getResponse(); - ActionInvocation invocation = - ServletActionContext.getActionContext(request).getActionInvocation(); + ActionContext ctx = ServletActionContext.getActionContext(request); + ActionInvocation invocation = ctx.getActionInvocation(); try { FreemarkerResult result = new FreemarkerResult(); result.setWriter(response.getWriter()); - Container container = Dispatcher.getInstance() - .getConfigurationManager() - .getConfiguration().getContainer(); - + Container container = ctx.getContainer(); container.inject(result); result.doExecute(include, invocation);