You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mr...@apache.org on 2006/11/13 09:30:46 UTC

svn commit: r474191 [1/4] - in /struts/struts2/trunk: apps/showcase/src/main/resources/ apps/showcase/src/main/webapp/WEB-INF/ core/src/main/java/org/apache/struts2/ core/src/main/java/org/apache/struts2/components/ core/src/main/java/org/apache/struts...

Author: mrdon
Date: Mon Nov 13 00:30:40 2006
New Revision: 474191

URL: http://svn.apache.org/viewvc?view=rev&rev=474191
Log:
Redesigning the Struts configuration to use the XWork DI container and its new configuration scheme.
The DI container will allow us better wire the framework together while allowing self-defining plugins
to extend/replace any component.  This change also gets rid of the need for struts.properties, allowing 
settings/constants to be defined in the XML.  In fact, even the XML isn't required when using the new 
zero configuration "actionPackages" filter init param.

These changes should be fully backwards compatible for most applications.

WW-1498 WW-1421 WW-1402

Added:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
    struts/struts2/trunk/plugins/pell-multipart/src/main/resources/
    struts/struts2/trunk/plugins/pell-multipart/src/main/resources/struts-plugin.xml
    struts/struts2/trunk/plugins/plexus/src/main/resources/
    struts/struts2/trunk/plugins/plexus/src/main/resources/struts-plugin.xml
    struts/struts2/trunk/plugins/sitemesh/src/main/resources/
    struts/struts2/trunk/plugins/sitemesh/src/main/resources/struts-plugin.xml
Removed:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/AbstractFilter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/lifecycle/
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryInitializable.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryLifecycle.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ResolverSetupServletContextListener.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityServlet.java
Modified:
    struts/struts2/trunk/apps/showcase/src/main/resources/struts.properties
    struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Component.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Include.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/Settings.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/VelocityStrutsUtil.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/ActionModel.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/jsp/ComponentTagSupport.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/FormTag.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java
    struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties
    struts/struts2/trunk/core/src/main/resources/struts-2.0.dtd
    struts/struts2/trunk/core/src/main/resources/struts-default.xml
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletActionRedirectResultTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapperTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseIfTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IfTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TooltipTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/util/ContextUtilTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java
    struts/struts2/trunk/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java
    struts/struts2/trunk/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
    struts/struts2/trunk/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java
    struts/struts2/trunk/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java
    struts/struts2/trunk/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java
    struts/struts2/trunk/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java
    struts/struts2/trunk/plugins/sitegraph/src/test/java/org/apache/struts2/sitegraph/SiteGraphTest.java
    struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerPageFilter.java
    struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java
    struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/VelocityPageFilter.java
    struts/struts2/trunk/plugins/struts1/src/test/java/org/apache/struts2/s1/Struts1FactoryTest.java
    struts/struts2/trunk/plugins/struts1/src/test/resources/org/apache/struts2/s1/test-struts-factory.xml

Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts.properties
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts.properties?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/resources/struts.properties (original)
+++ struts/struts2/trunk/apps/showcase/src/main/resources/struts.properties Mon Nov 13 00:30:40 2006
@@ -9,5 +9,3 @@
 struts.freemarker.manager.classname=customFreemarkerManager
 struts.serve.static=true
 struts.serve.static.browserCache=false
-
-struts.configuration.files=struts-default.xml,struts-plugin.xml,struts.xml,org.apache.struts2.showcase.person

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml Mon Nov 13 00:30:40 2006
@@ -19,6 +19,10 @@
     <filter>
         <filter-name>struts</filter-name>
         <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+        <init-param>
+        	<param-name>actionPackages</param-name>
+        	<param-value>org.apache.struts2.showcase.person</param-value>
+        </init-param>
     </filter>
 
     <filter>

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java Mon Nov 13 00:30:40 2006
@@ -133,12 +133,15 @@
     /** Allows one to disable dynamic method invocation from the URL */
     public static final String STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION = "struts.enable.DynamicMethodInvocation";
 
-    /** A list of configuration files automatically loaded by Struts */
-    public static final String STRUTS_CONFIGURATION_FILES = "struts.configuration.files";
-
     /** Whether slashes in action names are allowed or not */
     public static final String STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES = "struts.enable.SlashesInActionNames";
 
     /** Prefix used by {@link CompositeActionMapper} to identified its containing {@link ActionMapper} class. */
     public static final String STRUTS_MAPPER_COMPOSITE = "struts.mapper.composite.";
+
+    public static final String STRUTS_ACTIONPROXYFACTORY = "struts.actionProxyFactory";
+
+    public static final String STRUTS_TEMPLATE_ENGINES = "struts.templateEngines";
+
+    public static final String STRUTS_FREEMARKER_WRAPPER_ALT_MAP = "struts.freemarker.wrapper.altMap";
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java Mon Nov 13 00:30:40 2006
@@ -20,7 +20,9 @@
  */
 package org.apache.struts2;
 
-import org.apache.struts2.config.Settings;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.struts2.config.StrutsXmlConfigurationProvider;
 import org.apache.struts2.dispatcher.Dispatcher;
 import org.springframework.mock.web.MockServletContext;
@@ -41,23 +43,26 @@
      */
     protected void setUp() throws Exception {
         super.setUp();
-        Settings.reset();
         LocalizedTextUtil.clearDefaultResourceBundles();
-        Dispatcher du = new Dispatcher(new MockServletContext());
-        Dispatcher.setInstance(du);
-        configurationManager = new ConfigurationManager();
-        configurationManager.addConfigurationProvider(
-                new StrutsXmlConfigurationProvider("struts-default.xml", false));
-        configurationManager.addConfigurationProvider(
-                new StrutsXmlConfigurationProvider("struts-plugin.xml", false));
-        configurationManager.addConfigurationProvider(
-                new StrutsXmlConfigurationProvider("struts.xml", false));
-        du.setConfigurationManager(configurationManager);
+        initDispatcher(null);
 
     }
+    
+    protected Dispatcher initDispatcher(Map<String,String> params) {
+        if (params == null) {
+            params = new HashMap<String,String>();
+        }
+        Dispatcher du = new Dispatcher(new MockServletContext(), params);
+        Dispatcher.setInstance(du);
+        configurationManager = du.getConfigurationManager();
+        configuration = configurationManager.getConfiguration();
+        container = configuration.getContainer();
+        return du;
+    }
 
     protected void tearDown() throws Exception {
         super.tearDown();
+        Dispatcher.setInstance(null);
     }
 
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java Mon Nov 13 00:30:40 2006
@@ -42,6 +42,7 @@
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 
@@ -119,6 +120,8 @@
     protected HttpServletResponse res;
     protected HttpServletRequest req;
 
+    protected ActionProxyFactory actionProxyFactory;
+    protected Configuration configuration;
     protected ActionProxy proxy;
     protected String name;
     protected String namespace;
@@ -131,6 +134,26 @@
         this.req = req;
         this.res = res;
     }
+    
+    /**
+     * @param actionProxyFactory the actionProxyFactory to set
+     */
+    @Inject
+    public void setActionProxyFactory(ActionProxyFactory actionProxyFactory) {
+        this.actionProxyFactory = actionProxyFactory;
+    }
+
+
+
+    /**
+     * @param configuration the configuration to set
+     */
+    @Inject
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
+    }
+
+
 
     public boolean end(Writer writer, String body) {
         boolean end = super.end(writer, "", false);
@@ -226,7 +249,7 @@
         String namespace;
 
         if (this.namespace == null) {
-            namespace = TagUtils.buildNamespace(getStack(), req);
+            namespace = TagUtils.buildNamespace(actionMapper, getStack(), req);
         } else {
             namespace = findString(this.namespace);
         }
@@ -235,8 +258,8 @@
         ValueStack stack = getStack();
         // execute at this point, after params have been set
         try {
-            Configuration config = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
-            proxy = ActionProxyFactory.getFactory().createActionProxy(config, namespace, actionName, createExtraContext(), executeResult, true);
+            
+            proxy = actionProxyFactory.createActionProxy(configuration, namespace, actionName, createExtraContext(), executeResult, true);
             if (null != methodName) {
                 proxy.setMethod(methodName);
             }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Component.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Component.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Component.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Component.java Mon Nov 13 00:30:40 2006
@@ -33,13 +33,16 @@
 
 import org.apache.struts2.StrutsException;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
-import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.util.FastByteArrayOutputStream;
 import org.apache.struts2.views.jsp.TagUtils;
 import org.apache.struts2.views.util.ContextUtil;
 import org.apache.struts2.views.util.UrlHelper;
 
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.TextParseUtil;
 
@@ -55,6 +58,7 @@
     protected ValueStack stack;
     protected Map parameters;
     protected String id;
+    protected ActionMapper actionMapper;
 
     /**
      * Constructor.
@@ -78,7 +82,12 @@
 
         return name.substring(dot + 1).toLowerCase();
     }
-
+    
+    @Inject
+    public void setActionMapper(ActionMapper mapper) {
+        this.actionMapper = mapper;
+    }
+    
     /**
      * Get's the OGNL value stack assoicated with this component.
      * @return the OGNL value stack assoicated with this component.
@@ -335,8 +344,7 @@
         String finalAction = findString(action);
         String finalNamespace = determineNamespace(namespace, getStack(), req);
         ActionMapping mapping = new ActionMapping(finalAction, finalNamespace, method, parameters);
-        ActionMapper mapper = ActionMapperFactory.getMapper();
-        String uri = mapper.getUriFromActionMapping(mapping);
+        String uri = actionMapper.getUriFromActionMapping(mapping);
         return UrlHelper.buildUrl(uri, req, res, parameters, scheme, includeContext, encodeResult);
     }
 
@@ -351,7 +359,7 @@
         String result;
 
         if (namespace == null) {
-            result = TagUtils.buildNamespace(stack, req);
+            result = TagUtils.buildNamespace(actionMapper, stack, req);
         } else {
             result = findString(namespace);
         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java Mon Nov 13 00:30:40 2006
@@ -31,9 +31,8 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.Dispatcher;
-import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.portlet.context.PortletActionContext;
 import org.apache.struts2.portlet.util.PortletUrlHelper;
@@ -46,6 +45,7 @@
 import com.opensymphony.xwork2.config.RuntimeConfiguration;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.MethodFilterInterceptorUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.validator.ActionValidatorManagerFactory;
@@ -110,6 +110,9 @@
     protected String portletMode;
     protected String windowState;
     protected String acceptcharset;
+    
+    protected boolean enableDynamicMethodInvocation = true;
+    protected Configuration configuration;
 
     public Form(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
         super(stack, request, response);
@@ -126,6 +129,16 @@
     protected String getDefaultTemplate() {
         return TEMPLATE;
     }
+    
+    @Inject(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION)
+    public void setEnableDynamicMethodInvocation(String enable) {
+        enableDynamicMethodInvocation = "true".equals(enable);
+    }
+    
+    @Inject
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
+    }
 
 
     /*
@@ -233,10 +246,8 @@
 
         String actionMethod = "";
         // FIXME: our implementation is flawed - the only concept of ! should be in DefaultActionMapper
-        boolean allowDynamicMethodCalls = "true".equals(Settings.get(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION));
-
         // handle "name!method" convention.
-        if (allowDynamicMethodCalls) {
+        if (enableDynamicMethodInvocation) {
             if (action.indexOf("!") != -1) {
                 int endIdx = action.lastIndexOf("!");
                 actionMethod = action.substring(endIdx + 1, action.length());
@@ -244,13 +255,12 @@
             }
         }
 
-        Configuration config = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
-        final ActionConfig actionConfig = config.getRuntimeConfiguration().getActionConfig(namespace, action);
+        final ActionConfig actionConfig = configuration.getRuntimeConfiguration().getActionConfig(namespace, action);
         String actionName = action;
         if (actionConfig != null) {
 
             ActionMapping mapping = new ActionMapping(action, namespace, actionMethod, parameters);
-            String result = UrlHelper.buildUrl(ActionMapperFactory.getMapper().getUriFromActionMapping(mapping), request, response, null);
+            String result = UrlHelper.buildUrl(actionMapper.getUriFromActionMapping(mapping), request, response, null);
             addParameter("action", result);
 
             // let's try to get the actual action class and name
@@ -317,7 +327,7 @@
 
             addParameter("performValidation", Boolean.FALSE);
 
-            RuntimeConfiguration runtimeConfiguration = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration();
+            RuntimeConfiguration runtimeConfiguration = configuration.getRuntimeConfiguration();
             ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
 
             if (actionConfig != null) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java Mon Nov 13 00:30:40 2006
@@ -24,8 +24,8 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**
@@ -82,6 +82,7 @@
 
     private String calendarcss = "calendar-blue.css";
     private boolean debug;
+    private String encoding;
 
     public Head(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
         super(stack, request, response);
@@ -90,6 +91,11 @@
     protected String getDefaultTemplate() {
         return TEMPLATE;
     }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
 
     public void evaluateParams() {
         super.evaluateParams();
@@ -105,7 +111,7 @@
             }
         }
 
-        addParameter("encoding", Settings.get(StrutsConstants.STRUTS_I18N_ENCODING));
+        addParameter("encoding", encoding);
         addParameter("debug", Boolean.valueOf(debug).toString());
     }
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Include.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Include.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Include.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Include.java Mon Nov 13 00:30:40 2006
@@ -44,9 +44,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.RequestUtils;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.util.FastByteArrayOutputStream;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**
@@ -103,12 +103,18 @@
     protected String value;
     private HttpServletRequest req;
     private HttpServletResponse res;
+    private static String defaultEncoding;
 
     public Include(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         super(stack);
         this.req = req;
         this.res = res;
     }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public static void setDefaultEncoding(String encoding) {
+        defaultEncoding = encoding;
+    }
 
     public boolean end(Writer writer, String body) {
         String page = findString(value, "value", "You must specify the URL to include. Example: /foo.jsp");
@@ -275,7 +281,7 @@
     private static String getEncoding() {
         if (encodingDefined) {
             try {
-                encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING);
+                encoding = defaultEncoding;
             } catch (IllegalArgumentException e) {
                 encoding = System.getProperty("file.encoding");
                 encodingDefined = false;

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java Mon Nov 13 00:30:40 2006
@@ -36,10 +36,10 @@
 import org.apache.struts2.components.template.TemplateEngine;
 import org.apache.struts2.components.template.TemplateEngineManager;
 import org.apache.struts2.components.template.TemplateRenderingContext;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.views.util.ContextUtil;
 
 import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**
@@ -447,7 +447,25 @@
     // javascript tooltip attribute
     protected String tooltip;
     protected String tooltipConfig;
-
+    
+    protected String defaultTemplateDir;
+    protected String defaultUITheme;
+    protected TemplateEngineManager templateEngineManager;
+
+    @Inject(StrutsConstants.STRUTS_UI_TEMPLATEDIR)
+    public void setDefaultTemplateDir(String dir) {
+        this.defaultTemplateDir = dir;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_UI_THEME)
+    public void setDefaultUITheme(String theme) {
+        this.defaultUITheme = theme;
+    }
+    
+    @Inject
+    public void setTemplateEngineManager(TemplateEngineManager mgr) {
+        this.templateEngineManager = mgr;
+    }
 
     public boolean end(Writer writer, String body) {
         evaluateParams();
@@ -489,7 +507,7 @@
     }
 
     protected void mergeTemplate(Writer writer, Template template) throws Exception {
-        final TemplateEngine engine = TemplateEngineManager.getTemplateEngine(template, templateSuffix);
+        final TemplateEngine engine = templateEngineManager.getTemplateEngine(template, templateSuffix);
         if (engine == null) {
             throw new ConfigurationException("Unable to find a TemplateEngine for template " + template);
         }
@@ -517,7 +535,7 @@
 
         // Default template set
         if ((templateDir == null) || (templateDir.equals(""))) {
-            templateDir = Settings.get(StrutsConstants.STRUTS_UI_TEMPLATEDIR);
+            templateDir = defaultTemplateDir;
         }
 
         // Defaults to 'template'
@@ -550,7 +568,7 @@
 
         // Default theme set
         if ((theme == null) || (theme.equals(""))) {
-            theme = Settings.get(StrutsConstants.STRUTS_UI_THEME);
+            theme = defaultUITheme;
         }
 
         return theme;

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java Mon Nov 13 00:30:40 2006
@@ -34,13 +34,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsException;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.Dispatcher;
 import org.apache.struts2.portlet.context.PortletActionContext;
 import org.apache.struts2.portlet.util.PortletUrlHelper;
 import org.apache.struts2.views.util.UrlHelper;
 
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.XWorkContinuationConfig;
 
@@ -140,12 +140,18 @@
     protected String windowState;
     protected String portletUrlType;
     protected String anchor;
+    protected String urlIncludeParams;
 
     public URL(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         super(stack);
         this.req = req;
         this.res = res;
     }
+    
+    @Inject(StrutsConstants.STRUTS_URL_INCLUDEPARAMS)
+    public void setUrlIncludeParams(String urlIncludeParams) {
+        this.urlIncludeParams = urlIncludeParams;
+    }
 
     public boolean start(Writer writer) {
         boolean result = super.start(writer);
@@ -158,10 +164,7 @@
         // this at start so body params can override any of these they wish.
         try {
             // ww-1266
-            String includeParams =
-                    Settings.isSet(StrutsConstants.STRUTS_URL_INCLUDEPARAMS) ?
-                    Settings.get(StrutsConstants.STRUTS_URL_INCLUDEPARAMS).toLowerCase() : GET;
-
+            String includeParams = (urlIncludeParams != null ? urlIncludeParams.toLowerCase() : GET);
 
             if (this.includeParams != null) {
                 includeParams = findString(this.includeParams);

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java Mon Nov 13 00:30:40 2006
@@ -35,6 +35,7 @@
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.views.freemarker.FreemarkerManager;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
@@ -48,6 +49,7 @@
  */
 public class FreemarkerTemplateEngine extends BaseTemplateEngine {
     static Class bodyContent = null;
+    private FreemarkerManager freemarkerManager;
 
     static {
         try {
@@ -63,6 +65,11 @@
 
     private static final Log LOG = LogFactory.getLog(FreemarkerTemplateEngine.class);
 
+    @Inject
+    public void setFreemarkerManager(FreemarkerManager mgr) {
+        this.freemarkerManager = mgr;
+    }
+    
     public void renderTemplate(TemplateRenderingContext templateContext) throws Exception {
         // get the various items required from the stack
         ValueStack stack = templateContext.getStack();
@@ -72,7 +79,6 @@
         HttpServletResponse res = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE);
 
         // prepare freemarker
-        FreemarkerManager freemarkerManager = FreemarkerManager.getInstance();
         Configuration config = freemarkerManager.getConfiguration(servletContext);
 
         // get the list of templates we can use

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java Mon Nov 13 00:30:40 2006
@@ -23,7 +23,11 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.struts2.config.Settings;
+import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.dispatcher.Dispatcher;
+
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
 
 /**
  * The TemplateEngineManager will return a template engine for the template
@@ -31,19 +35,38 @@
 public class TemplateEngineManager {
     public static final String DEFAULT_TEMPLATE_TYPE_CONFIG_KEY = "struts.ui.templateSuffix";
 
-    private static final TemplateEngineManager MANAGER = new TemplateEngineManager();
-
     /** The default template extenstion is <code>ftl</code>. */
     public static final String DEFAULT_TEMPLATE_TYPE = "ftl";
 
     Map templateEngines = new HashMap();
-
-    private TemplateEngineManager() {
-        templateEngines.put("ftl", new FreemarkerTemplateEngine());
-        templateEngines.put("vm", new VelocityTemplateEngine());
-        templateEngines.put("jsp", new JspTemplateEngine());
+    Container container;
+    String defaultTemplateType;
+    
+    @Inject(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY)
+    public void setDefaultTemplateType(String type) {
+        this.defaultTemplateType = type;
     }
-
+    
+    @Inject
+    public void setContainer(Container container) {
+        this.container = container;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_TEMPLATE_ENGINES)
+    public void setTemplateEngines(String engines) {
+        if (engines != null) {
+            String[] list = engines.split(",");
+            for (String name : list) {
+                TemplateEngine eng = container.getInstance(TemplateEngine.class, name);
+                if (eng != null) {
+                    templateEngines.put(name, eng);
+                } else {
+                    throw new IllegalArgumentException("Invalid template engine name: "+name);
+                }
+            }
+        }
+    }
+    
     /**
      * Registers the given template engine.
      * <p/>
@@ -51,8 +74,8 @@
      * @param templateExtension  filename extension (eg. .jsp, .ftl, .vm).
      * @param templateEngine     the engine.
      */
-    public static void registerTemplateEngine(String templateExtension, TemplateEngine templateEngine) {
-        MANAGER.templateEngines.put(templateExtension, templateEngine);
+    public void registerTemplateEngine(String templateExtension, TemplateEngine templateEngine) {
+        templateEngines.put(templateExtension, templateEngine);
     }
 
     /**
@@ -65,17 +88,20 @@
      * @param templateTypeOverride Overrides the default template type
      * @return the engine.
      */
-    public static TemplateEngine getTemplateEngine(Template template, String templateTypeOverride) {
+    public TemplateEngine getTemplateEngine(Template template, String templateTypeOverride) {
         String templateType = DEFAULT_TEMPLATE_TYPE;
         String templateName = template.toString();
         if (templateName.indexOf(".") > 0) {
             templateType = templateName.substring(templateName.indexOf(".") + 1);
         } else if (templateTypeOverride !=null && templateTypeOverride.length() > 0) {
             templateType = templateTypeOverride;
-        } else if (Settings.isSet(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY)) {
-            templateType = (String) Settings.get(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY);
+        } else {
+            String type = defaultTemplateType;
+            if (type != null) {
+                templateType = type;
+            }
         }
-        return (TemplateEngine) MANAGER.templateEngines.get(templateType);
+        return (TemplateEngine) templateEngines.get(templateType);
     }
 
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java Mon Nov 13 00:30:40 2006
@@ -37,11 +37,20 @@
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 
+import com.opensymphony.xwork2.inject.Inject;
+
 /**
  * Velocity based template engine.
  */
 public class VelocityTemplateEngine extends BaseTemplateEngine {
     private static final Log LOG = LogFactory.getLog(VelocityTemplateEngine.class);
+    
+    private VelocityManager velocityManager;
+    
+    @Inject
+    public void setVelocityManager(VelocityManager mgr) {
+        this.velocityManager = mgr;
+    }
 
     public void renderTemplate(TemplateRenderingContext templateContext) throws Exception {
         // get the various items required from the stack
@@ -51,7 +60,6 @@
         HttpServletResponse res = (HttpServletResponse) actionContext.get(ServletActionContext.HTTP_RESPONSE);
 
         // prepare velocity
-        VelocityManager velocityManager = VelocityManager.getInstance();
         velocityManager.init(servletContext);
         VelocityEngine velocityEngine = velocityManager.getVelocityEngine();
 

Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java?view=auto&rev=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java (added)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java Mon Nov 13 00:30:40 2006
@@ -0,0 +1,128 @@
+/*
+ * $Id:  $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.config;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
+import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
+import org.apache.struts2.views.freemarker.FreemarkerManager;
+import org.apache.struts2.views.velocity.VelocityManager;
+
+import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Context;
+import com.opensymphony.xwork2.inject.Factory;
+import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.inject.Scope;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.util.ObjectTypeDeterminer;
+import com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory;
+
+public class BeanSelectionProvider implements ConfigurationProvider {
+    public static final String DEFAULT_BEAN_NAME = "struts";
+    private static final Log LOG = LogFactory.getLog(BeanSelectionProvider.class);
+    
+    public void destroy() {
+        // NO-OP
+    }
+
+    public void loadPackages() throws ConfigurationException {
+        // NO-OP
+    }
+    
+    public void init(Configuration configuration) throws ConfigurationException {
+        // NO-OP
+        
+    }
+
+    public boolean needsReload() {
+        return false;
+    }
+
+    public void register(ContainerBuilder builder, Properties props) {
+        alias(ObjectFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY, builder, props);
+        alias(ActionProxyFactory.class, StrutsConstants.STRUTS_ACTIONPROXYFACTORY, builder, props);
+        alias(ObjectTypeDeterminer.class, StrutsConstants.STRUTS_OBJECTTYPEDETERMINER, builder, props);
+        alias(ActionMapper.class, StrutsConstants.STRUTS_MAPPER_CLASS, builder, props);
+        alias(MultiPartRequest.class, StrutsConstants.STRUTS_MULTIPART_PARSER, builder, props, Scope.DEFAULT);
+        alias(FreemarkerManager.class, StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME, builder, props);
+        alias(VelocityManager.class, StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, builder, props);
+        
+        if ("true".equalsIgnoreCase(props.getProperty(StrutsConstants.STRUTS_DEVMODE))) {
+            props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, "true");
+            props.setProperty(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
+        }
+    }
+    
+    void alias(Class type, String key, ContainerBuilder builder, Properties props) {
+        alias(type, key, builder, props, Scope.SINGLETON);
+    }
+    
+    void alias(Class type, String key, ContainerBuilder builder, Properties props, Scope scope) {
+        if (!builder.contains(type)) {
+            String foundName = props.getProperty(key, DEFAULT_BEAN_NAME);
+            if (builder.contains(type, foundName)) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.info("Choosing bean ("+foundName+") for "+type);
+                }
+                builder.alias(type, foundName, Container.DEFAULT_NAME);
+            } else {
+                try {
+                    Class cls = ClassLoaderUtil.loadClass(foundName, this.getClass());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.info("Choosing bean ("+cls+") for "+type);
+                    }
+                    builder.factory(type, cls, scope);
+                } catch (ClassNotFoundException ex) {
+                    // Perhaps a spring bean id, so we'll delegate to the object factory at runtime
+                    if (LOG.isDebugEnabled()) {
+                        LOG.info("Choosing bean ("+foundName+") for "+type+" to be loaded from the ObjectFactory");
+                    }
+                    builder.factory(type, new ObjectFactoryDelegateFactory(foundName), scope);
+                }
+            }
+        } else {
+            LOG.warn("Unable to alias bean type "+type+", default mapping already assigned.");
+        }
+    }
+    
+    class ObjectFactoryDelegateFactory implements Factory {
+        String name;
+        ObjectFactoryDelegateFactory(String name) {
+            this.name = name;
+        }
+        
+        public Object create(Context context) throws Exception {
+            ObjectFactory objFactory = context.getContainer().getInstance(ObjectFactory.class);
+            return objFactory.buildBean(name, null, false);
+        }
+    }
+}

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java Mon Nov 13 00:30:40 2006
@@ -26,6 +26,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -40,6 +41,7 @@
 import com.opensymphony.xwork2.config.entities.PackageConfig;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
 import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.ResolverUtil;
 import com.opensymphony.xwork2.util.TextUtils;
@@ -237,9 +239,12 @@
     public void destroy() {
 
     }
+    
+    public void init(Configuration config) {
+        this.configuration = config;
+    }
 
-    public void init(Configuration configuration) throws ConfigurationException {
-        this.configuration = configuration;
+    public void loadPackages() throws ConfigurationException {
         loadedPackageConfigs.clear();
         loadPackages(packages);
         initialized = true;
@@ -352,5 +357,9 @@
             params.put(defaultParam, location);
             return new ResultConfig((String) key, resultClass.getName(), params);
         }
+    }
+
+    public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
+        // Nothing
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java Mon Nov 13 00:30:40 2006
@@ -31,7 +31,7 @@
  * and call the method until successful.
  *
  */
-public class DelegatingSettings extends Settings {
+class DelegatingSettings extends Settings {
 
     Settings[] configList;
 

Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java?view=auto&rev=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java (added)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java Mon Nov 13 00:30:40 2006
@@ -0,0 +1,84 @@
+/*
+ * $Id:  $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.config;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
+
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Context;
+import com.opensymphony.xwork2.inject.Factory;
+import com.opensymphony.xwork2.util.LocalizedTextUtil;
+
+public class LegacyPropertiesConfigurationProvider implements ConfigurationProvider {
+
+    public void destroy() {
+        Settings.reset();
+    }
+
+    public void init(Configuration configuration)
+        throws ConfigurationException {
+        Settings.reset();
+    }
+    
+    public void loadPackages()
+            throws ConfigurationException {
+    }
+
+    public boolean needsReload() {
+        return false;
+    }
+
+    public void register(ContainerBuilder builder, Properties props)
+            throws ConfigurationException {
+        
+        final Settings settings = Settings.getInstance();
+        
+        for (Iterator i = settings.list(); i.hasNext(); ) {
+            String name = (String) i.next();
+            props.put(name, settings.get(name));
+            if (StrutsConstants.STRUTS_DEVMODE.equals(name)) {
+                props.put("devMode", settings.get(name));
+            }
+        }
+        
+        // Set default locale
+        final Locale locale = settings.getLocale();
+        builder.factory(Locale.class, new Factory() {
+            public Object create(Context context) throws Exception {
+                return locale;
+            }
+        });
+    }
+}

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java Mon Nov 13 00:30:40 2006
@@ -25,15 +25,18 @@
 import java.util.Iterator;
 import java.util.Properties;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsException;
 
 
 /**
  * A class to handle settings via a properties file.
  */
-public class PropertiesSettings extends Settings {
+class PropertiesSettings extends Settings {
 
     Properties settings;
+    static Log LOG = LogFactory.getLog(PropertiesSettings.class);
 
 
     /**
@@ -49,7 +52,8 @@
         URL settingsUrl = Thread.currentThread().getContextClassLoader().getResource(name + ".properties");
 
         if (settingsUrl == null) {
-            throw new IllegalStateException(name + ".properties missing");
+            LOG.debug(name + ".properties missing");
+            return;
         }
 
         // Load settings

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/Settings.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/Settings.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/Settings.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/Settings.java Mon Nov 13 00:30:40 2006
@@ -51,7 +51,7 @@
  * <li>{@link #listImpl()}</li>
  * <li>{@link #isSetImpl(String)}</li></ul>
  */
-public class Settings {
+class Settings {
 
     static Settings settingsImpl;
     static Settings defaultImpl;

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java Mon Nov 13 00:30:40 2006
@@ -29,13 +29,22 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.ServletContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Context;
+import com.opensymphony.xwork2.inject.Factory;
 
 /**
  * Override Xwork class so we can use an arbitrary config file
@@ -46,6 +55,7 @@
     private File baseDir = null;
     private String filename;
     private String reloadKey;
+    private Object servletContext;
 
     /**
      * Constructs the configuration provider
@@ -53,7 +63,7 @@
      * @param errorIfMissing If we should throw an exception if the file can't be found
      */
     public StrutsXmlConfigurationProvider(boolean errorIfMissing) {
-        this("struts.xml", errorIfMissing);
+        this("struts.xml", errorIfMissing, null);
     }
 
     /**
@@ -62,8 +72,9 @@
      * @param filename The filename to look for
      * @param errorIfMissing If we should throw an exception if the file can't be found
      */
-    public StrutsXmlConfigurationProvider(String filename, boolean errorIfMissing) {
+    public StrutsXmlConfigurationProvider(String filename, boolean errorIfMissing, ServletContext ctx) {
         super(filename, errorIfMissing);
+        this.servletContext = ctx;
         this.filename = filename;
         reloadKey = "configurationReload-"+filename;
         Map<String,String> dtdMappings = new HashMap<String,String>(getDtdMappings());
@@ -74,17 +85,31 @@
             this.baseDir = file.getParentFile();
         }
     }
-
-
+    
+    /* (non-Javadoc)
+     * @see com.opensymphony.xwork2.config.providers.XmlConfigurationProvider#register(com.opensymphony.xwork2.inject.ContainerBuilder, java.util.Properties)
+     */
+    @Override
+    public void register(ContainerBuilder containerBuilder, Properties props) throws ConfigurationException {
+        if (servletContext != null && !containerBuilder.contains(ServletContext.class)) {
+            containerBuilder.factory(ServletContext.class, new Factory() {
+                public Object create(Context context) throws Exception {
+                    return servletContext;
+                }
+                
+            });
+        }
+        super.register(containerBuilder, props);
+    }
 
     /* (non-Javadoc)
      * @see com.opensymphony.xwork2.config.providers.XmlConfigurationProvider#init(com.opensymphony.xwork2.config.Configuration)
      */
     @Override
-    public void init(Configuration configuration) {
+    public void loadPackages() {
         ActionContext ctx = ActionContext.getContext();
         ctx.put(reloadKey, Boolean.TRUE);
-        super.init(configuration);
+        super.loadPackages();
     }
 
     /**
@@ -143,6 +168,10 @@
         }
         return false;
 
+    }
+    
+    public String toString() {
+        return ("Struts XML configuration provider ("+filename+")");
     }
 
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java Mon Nov 13 00:30:40 2006
@@ -22,6 +22,7 @@
 
 import java.io.IOException;
 
+import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
@@ -64,22 +65,12 @@
  *
  * @version $Date$ $Id$
  */
-public class ActionContextCleanUp extends AbstractFilter {
+public class ActionContextCleanUp implements Filter {
 
     private static final Log LOG = LogFactory.getLog(ActionContextCleanUp.class);
 
     private static final String COUNTER = "__cleanup_recursion_counter";
 
-    protected FilterConfig filterConfig;
-
-
-    /**
-     * Empty implementation.
-     */
-    protected void postInit(FilterConfig filterConfig) throws ServletException {
-        // does nothing.
-    }
-
     /**
      * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
      */
@@ -92,8 +83,6 @@
         try {
             UtilTimerStack.push(timerKey);
 
-            request = prepareDispatcherAndWrapRequest(request, response);
-
             try {
                 Integer count = (Integer)request.getAttribute(COUNTER);
                 if (count == null) {
@@ -143,5 +132,11 @@
         if (LOG.isDebugEnabled()) {
             LOG.debug("clean up ");
         }
+    }
+
+    public void destroy() {
+    }
+
+    public void init(FilterConfig arg0) throws ServletException {
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Mon Nov 13 00:30:40 2006
@@ -26,9 +26,13 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -40,8 +44,9 @@
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.config.BeanSelectionProvider;
 import org.apache.struts2.config.ClasspathConfigurationProvider;
-import org.apache.struts2.config.Settings;
+import org.apache.struts2.config.LegacyPropertiesConfigurationProvider;
 import org.apache.struts2.config.StrutsXmlConfigurationProvider;
 import org.apache.struts2.config.ClasspathConfigurationProvider.ClasspathPageLocator;
 import org.apache.struts2.config.ClasspathConfigurationProvider.PageLocator;
@@ -51,8 +56,8 @@
 import org.apache.struts2.impl.StrutsActionProxyFactory;
 import org.apache.struts2.impl.StrutsObjectFactory;
 import org.apache.struts2.util.AttributeMap;
+import org.apache.struts2.util.ClassLoaderUtils;
 import org.apache.struts2.util.ObjectFactoryDestroyable;
-import org.apache.struts2.util.ObjectFactoryInitializable;
 import org.apache.struts2.views.freemarker.FreemarkerManager;
 
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
@@ -62,9 +67,14 @@
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.Result;
+import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.ObjectTypeDeterminer;
 import com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory;
@@ -87,12 +97,6 @@
  */
 public class Dispatcher {
 
-    // Set Struts-specific factories.
-    static {
-        ObjectFactory.setObjectFactory(new StrutsObjectFactory());
-        ActionProxyFactory.setFactory(new StrutsActionProxyFactory());
-    }
-
     private static final Log LOG = LogFactory.getLog(Dispatcher.class);
 
     private static ThreadLocal<Dispatcher> instance = new ThreadLocal<Dispatcher>();
@@ -101,7 +105,12 @@
 
     private ConfigurationManager configurationManager;
     private static boolean portletSupportActive;
-    private boolean devMode = false;
+    private static boolean devMode;
+    private static String defaultEncoding;
+    private static String defaultLocale;
+    private static String multipartMaxSize;
+    private static String multipartSaveDir;
+    private static final String DEFAULT_CONFIGURATION_PATHS = "struts-default.xml,struts-plugin.xml,struts.xml"; 
 
     // used to get WebLogic to play nice
     private boolean paramsWorkaroundEnabled = false;
@@ -147,8 +156,33 @@
      *
      * @param servletContext The servlet context
      */
-    public Dispatcher(ServletContext servletContext) {
-        init(servletContext);
+    public Dispatcher(ServletContext servletContext, Map initParams) {
+        init(servletContext, initParams);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_DEVMODE)
+    public static void setDevMode(String mode) {
+        devMode = "true".equals(mode);
+    }
+    
+    @Inject(value=StrutsConstants.STRUTS_LOCALE, required=false)
+    public static void setDefaultLocale(String val) {
+        defaultLocale = val;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public static void setDefaultEncoding(String val) {
+        defaultEncoding = val;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)
+    public static void setMultipartMaxSize(String val) {
+        multipartMaxSize = val;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_MULTIPART_SAVEDIR)
+    public static void setMultipartSaveDir(String val) {
+        multipartSaveDir = val;
     }
 
     /**
@@ -183,69 +217,96 @@
      *
      * @param servletContext The servlet context
      */
-    private void init(final ServletContext servletContext) {
-        boolean reloadi18n = Boolean.valueOf((String) Settings.get(StrutsConstants.STRUTS_I18N_RELOAD)).booleanValue();
-        LocalizedTextUtil.setReloadBundles(reloadi18n);
-
-        if (Settings.isSet(StrutsConstants.STRUTS_OBJECTFACTORY)) {
-            String className = (String) Settings.get(StrutsConstants.STRUTS_OBJECTFACTORY);
-            if (className.equals("spring")) {
-                // note: this class name needs to be in string form so we don't put hard
-                //       dependencies on spring, since it isn't technically required.
-                className = "org.apache.struts2.spring.StrutsSpringObjectFactory";
-            } else if (className.equals("plexus")) {
-                className = "org.apache.struts2.plexus.PlexusObjectFactory";
-                LOG.warn("The 'plexus' shorthand for the Plexus ObjectFactory is deprecated.  Please "
-                        +"use the full class name: "+className);
-            }
-
-            try {
-                Class clazz = ClassLoaderUtil.loadClass(className, Dispatcher.class);
-                ObjectFactory objectFactory = (ObjectFactory) clazz.newInstance();
-                if (servletContext != null) {
-                    if (objectFactory instanceof ObjectFactoryInitializable) {
-                        ((ObjectFactoryInitializable) objectFactory).init(servletContext);
+    private void init(final ServletContext servletContext, final Map<String,String> initParams) {
+        
+        
+        configurationManager = new ConfigurationManager(BeanSelectionProvider.DEFAULT_BEAN_NAME);
+        
+        configurationManager.addConfigurationProvider(new LegacyPropertiesConfigurationProvider());
+        // Load traditional xml configuration
+        String configPaths = initParams.get("config");
+        if (configPaths == null) {
+            configPaths = DEFAULT_CONFIGURATION_PATHS;
+        }
+        if (configPaths != null) {
+            String[] files = configPaths.split("\\s*[,]\\s*");
+            for (String file : files) {
+                if (file.endsWith(".xml")) {
+                    if ("xwork.xml".equals(file)) {
+                        configurationManager.addConfigurationProvider(new XmlConfigurationProvider(file, false));
+                    } else {
+                        configurationManager.addConfigurationProvider(new StrutsXmlConfigurationProvider(file, false, servletContext));
                     }
+                } else {
+                    throw new IllegalArgumentException("Invalid configuration file name");
                 }
-                ObjectFactory.setObjectFactory(objectFactory);
-            } catch (Exception e) {
-                LOG.error("Could not load ObjectFactory named " + className + ". Using default ObjectFactory.", e);
             }
         }
-
-        if (Settings.isSet(StrutsConstants.STRUTS_OBJECTTYPEDETERMINER)) {
-            String className = (String) Settings.get(StrutsConstants.STRUTS_OBJECTTYPEDETERMINER);
-            if (className.equals("tiger")) {
-                // note: this class name needs to be in string form so we don't put hard
-                //       dependencies on xwork-tiger, since it isn't technically required.
-                className = "com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer";
-            }
-            else if (className.equals("notiger")) {
-                className = "com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer";
+        
+        // Load configuration from a scan of the classloader
+        String packages = initParams.get("actionPackages");
+        if (packages != null) {
+            String[] names = packages.split("\\s*[,]\\s*");
+            // Initialize the classloader scanner with the configured packages
+            if (names.length > 0) {
+                ClasspathConfigurationProvider provider = new ClasspathConfigurationProvider(names);
+                provider.setPageLocator(new ServletContextPageLocator(servletContext));
+                configurationManager.addConfigurationProvider(provider);
             }
-
-            try {
-                Class clazz = ClassLoaderUtil.loadClass(className, Dispatcher.class);
-                ObjectTypeDeterminer objectTypeDeterminer = (ObjectTypeDeterminer) clazz.newInstance();
-                ObjectTypeDeterminerFactory.setInstance(objectTypeDeterminer);
-            } catch (Exception e) {
-                LOG.error("Could not load ObjectTypeDeterminer named " + className + ". Using default DefaultObjectTypeDeterminer.", e);
+            configurationManager.addConfigurationProvider(new BeanSelectionProvider());
+        }
+        
+        String configProvs = initParams.get("configProviders");
+        if (configProvs != null) {
+            String[] classes = configProvs.split("\\s*[,]\\s*");
+            for (String cname : classes) {
+                try {
+                    Class cls = ClassLoaderUtils.loadClass(cname, this.getClass());
+                    ConfigurationProvider prov = (ConfigurationProvider)cls.newInstance();
+                    configurationManager.addConfigurationProvider(prov);
+                } catch (InstantiationException e) {
+                    throw new ConfigurationException("Unable to instantiate provider: "+cname, e);
+                } catch (IllegalAccessException e) {
+                    throw new ConfigurationException("Unable to access provider: "+cname, e);
+                } catch (ClassNotFoundException e) {
+                    throw new ConfigurationException("Unable to locate provider class: "+cname, e);
+                }
             }
         }
+        
+        // Load filter init params as constants
+        configurationManager.addConfigurationProvider(new ConfigurationProvider() {
+            public void destroy() {}
+            public void init(Configuration configuration) throws ConfigurationException {}
+            public void loadPackages() throws ConfigurationException {}
+            public boolean needsReload() { return false; }
+
+            public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
+                props.putAll(initParams);
+            }
+        });
+        
+        configurationManager.addConfigurationProvider(new BeanSelectionProvider());
+        // Preload the configuration
+        Configuration config = configurationManager.getConfiguration();
+        Container container = config.getContainer();
+        
+        
+        boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD)).booleanValue();
+        LocalizedTextUtil.setReloadBundles(reloadi18n);
 
-        if ("true".equals(Settings.get(StrutsConstants.STRUTS_DEVMODE))) {
-            devMode = true;
-            Settings.set(StrutsConstants.STRUTS_I18N_RELOAD, "true");
-            Settings.set(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
-        }
+        ObjectTypeDeterminer objectTypeDeterminer = container.getInstance(ObjectTypeDeterminer.class);
+        ObjectTypeDeterminerFactory.setInstance(objectTypeDeterminer);
+
+//        devMode = "true".equals(container.getInstance(String.class, StrutsConstants.STRUTS_DEVMODE));
+//      Settings.set(StrutsConstants.STRUTS_I18N_RELOAD, "true");
+//      Settings.set(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
 
         //check for configuration reloading
-        if ("true".equalsIgnoreCase(Settings.get(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) {
-            FileManager.setReloadingConfigs(true);
-        }
+        FileManager.setReloadingConfigs("true".equals(container.getInstance(String.class, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD)));
 
-        if (Settings.isSet(StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE)) {
-            String pkg = Settings.get(StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE);
+        String pkg = container.getInstance(String.class, StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE);
+        if (pkg != null) {
             ObjectFactory.setContinuationPackage(pkg);
         }
 
@@ -254,39 +315,9 @@
                 && servletContext.getServerInfo().indexOf("WebLogic") >= 0) {
             LOG.info("WebLogic server detected. Enabling Struts parameter access work-around.");
             paramsWorkaroundEnabled = true;
-        } else if (Settings.isSet(StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)) {
-            paramsWorkaroundEnabled = "true".equals(Settings.get(StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND));
         } else {
-            LOG.debug("Parameter access work-around disabled.");
-        }
-
-        configurationManager = new ConfigurationManager();
-        String configFiles = null;
-        if (Settings.isSet(StrutsConstants.STRUTS_CONFIGURATION_FILES)) {
-            configFiles = Settings.get(StrutsConstants.STRUTS_CONFIGURATION_FILES);
-        }
-        if (configFiles != null) {
-            List<String> packages = new ArrayList<String>();
-            String[] files = configFiles.split("\\s*[,]\\s*");
-            for (String file : files) {
-                if (file.endsWith(".xml")) {
-                    if ("xwork.xml".equals(file)) {
-                        configurationManager.addConfigurationProvider(new XmlConfigurationProvider(file, false));
-                    } else {
-                        configurationManager.addConfigurationProvider(new StrutsXmlConfigurationProvider(file, false));
-                    }
-                } else {
-                    packages.add(file);
-                }
-            }
-
-            // Initialize the classloader scanner with the configured paths
-            if (packages.size() > 0) {
-                ClasspathConfigurationProvider provider = new ClasspathConfigurationProvider((String[])packages.toArray(new String[]{}));
-                provider.setPageLocator(new ServletContextPageLocator(servletContext));
-                configurationManager.addConfigurationProvider(provider);
-            }
-        }
+            paramsWorkaroundEnabled = "true".equals(container.getInstance(String.class, StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND));
+        } 
 
         synchronized(Dispatcher.class) {
             if (dispatcherListeners.size() > 0) {
@@ -337,8 +368,9 @@
                 extraContext.put(XWorkContinuationConfig.CONTINUE_KEY, id);
             }
 
-            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(
-                    configurationManager.getConfiguration(), namespace, name, extraContext, true, false);
+            Configuration config = configurationManager.getConfiguration();
+            ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
+                    config, namespace, name, extraContext, true, false);
             proxy.setMethod(method);
             request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());
 
@@ -428,14 +460,14 @@
         extraContext.put(ActionContext.APPLICATION, applicationMap);
 
         Locale locale = null;
-        if (Settings.isSet(StrutsConstants.STRUTS_LOCALE)) {
-            locale = LocalizedTextUtil.localeFromString(Settings.get(StrutsConstants.STRUTS_LOCALE), request.getLocale());
+        if (defaultLocale != null) {
+            locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
         } else {
             locale = request.getLocale();
         }
 
         extraContext.put(ActionContext.LOCALE, locale);
-        extraContext.put(ActionContext.DEV_MODE, Boolean.valueOf(devMode));
+        //extraContext.put(ActionContext.DEV_MODE, Boolean.valueOf(devMode));
 
         extraContext.put(StrutsStatics.HTTP_REQUEST, request);
         extraContext.put(StrutsStatics.HTTP_RESPONSE, response);
@@ -461,7 +493,7 @@
     private static int getMaxSize() {
         Integer maxSize = new Integer(Integer.MAX_VALUE);
         try {
-            String maxSizeStr = Settings.get(StrutsConstants.STRUTS_MULTIPART_MAXSIZE);
+            String maxSizeStr = multipartMaxSize;
 
             if (maxSizeStr != null) {
                 try {
@@ -489,7 +521,7 @@
      * @return the path to save uploaded files to
      */
     private String getSaveDir(ServletContext servletContext) {
-        String saveDir = Settings.get(StrutsConstants.STRUTS_MULTIPART_SAVEDIR).trim();
+        String saveDir = multipartSaveDir.trim();
 
         if (saveDir.equals("")) {
             File tempdir = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
@@ -521,13 +553,13 @@
      */
     public void prepare(HttpServletRequest request, HttpServletResponse response) {
         String encoding = null;
-        if (Settings.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) {
-            encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING);
+        if (defaultEncoding != null) {
+            encoding = defaultEncoding;
         }
 
         Locale locale = null;
-        if (Settings.isSet(StrutsConstants.STRUTS_LOCALE)) {
-            locale = LocalizedTextUtil.localeFromString(Settings.get(StrutsConstants.STRUTS_LOCALE), request.getLocale());
+        if (defaultLocale != null) {
+            locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
         }
 
         if (encoding != null) {
@@ -563,8 +595,10 @@
             return request;
         }
 
-        if (MultiPartRequest.isMultiPart(request)) {
-            request = new MultiPartRequestWrapper(request, getSaveDir(servletContext), getMaxSize());
+        String content_type = request.getContentType();
+        if (content_type != null && content_type.indexOf("multipart/form-data") != -1) {
+            MultiPartRequest multi = getContainer().getInstance(MultiPartRequest.class);
+            request = new MultiPartRequestWrapper(multi, request, getSaveDir(servletContext));
         } else {
             request = new StrutsRequestWrapper(request);
         }
@@ -586,7 +620,9 @@
             response.setContentType("text/html");
 
             try {
-                freemarker.template.Configuration config = FreemarkerManager.getInstance().getConfiguration(ctx);
+                FreemarkerManager mgr = getContainer().getInstance(FreemarkerManager.class);
+                
+                freemarker.template.Configuration config = mgr.getConfiguration(ctx);
                 Template template = config.getTemplate("/org/apache/struts2/dispatcher/error.ftl");
 
                 List<Throwable> chain = new ArrayList<Throwable>();
@@ -700,18 +736,7 @@
         this.configurationManager = mgr;
     }
 
-    /**
-     * @return the devMode
-     */
-    public boolean isDevMode() {
-        return devMode;
-    }
-
-    /**
-     * @param devMode the devMode to set
-     */
-    public void setDevMode(boolean devMode) {
-        this.devMode = devMode;
+    public Container getContainer() {
+        return getConfigurationManager().getConfiguration().getContainer();
     }
-
 }