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 [2/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...

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java Mon Nov 13 00:30:40 2006
@@ -27,10 +27,14 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.TimeZone;
 
+import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletContext;
@@ -45,14 +49,14 @@
 import org.apache.struts2.RequestUtils;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
-import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ObjectFactory;
 
 /**
  * Master filter for Struts that handles four distinct
@@ -119,7 +123,7 @@
  *
  * @version $Date$ $Id$
  */
-public class FilterDispatcher extends AbstractFilter implements StrutsStatics {
+public class FilterDispatcher implements StrutsStatics, Filter {
 
     private static final Log LOG = LogFactory.getLog(FilterDispatcher.class);
 
@@ -128,15 +132,25 @@
     private SimpleDateFormat df = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss");
     private final Calendar lastModifiedCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
     private final String lastModified = df.format(lastModifiedCal.getTime());
+    
+    private static boolean serveStatic;
+    private static boolean serveStaticBrowserCache;
+    private static String encoding;
+    private static ActionMapper actionMapper;
+    private FilterConfig filterConfig;
+
+    /** Dispatcher instance to be used by subclass. */
+    protected Dispatcher dispatcher;
 
 
     /**
-     * Look for "packages" defined through filter-config's parameters.
+     * Initializes the filter
      *
-     * @param FilterConfig
-     * @throws ServletException
+     * @param filterConfig The filter configuration
      */
-    protected void postInit(FilterConfig filterConfig) throws ServletException {
+    public void init(FilterConfig filterConfig) throws ServletException {
+        dispatcher = createDispatcher(filterConfig);
+        this.filterConfig = filterConfig;
         String param = filterConfig.getInitParameter("packages");
         String packages = "org.apache.struts2.static template org.apache.struts2.interceptor.debugging";
         if (param != null) {
@@ -144,6 +158,119 @@
         }
         this.pathPrefixes = parse(packages);
     }
+    
+
+    /**
+     * Cleans up the dispatcher
+     *
+     * @see javax.servlet.Filter#destroy()
+     */
+    public void destroy() {
+        if (dispatcher == null) {
+            LOG.warn("something is seriously wrong, Dispatcher is not initialized (null) ");
+        } else {
+            dispatcher.cleanup();
+        }
+    }
+    
+    /**
+     * Create a {@link Dispatcher}, this serves as a hook for subclass to overried
+     * such that a custom {@link Dispatcher} could be created.
+     *
+     * @return Dispatcher
+     */
+    protected Dispatcher createDispatcher(FilterConfig filterConfig) {
+        Map<String,String> params = new HashMap<String,String>();
+        for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements(); ) {
+            String name = (String) e.nextElement();
+            String value = filterConfig.getInitParameter(name);
+            params.put(name, value);
+        }
+        return new Dispatcher(filterConfig.getServletContext(), params);
+    }
+
+    @Inject(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)
+    public static void setServeStaticContent(String val) {
+        serveStatic = "true".equals(val);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE)
+    public static void setServeStaticBrowserCache(String val) {
+        serveStaticBrowserCache = "true".equals(val);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public static void setEncoding(String val) {
+        encoding = val;
+    }
+    
+    @Inject
+    public static void setActionMapper(ActionMapper mapper) {
+        actionMapper = mapper;
+    }
+    
+    /**
+     * Servlet 2.3 specifies that the servlet context can be retrieved from the session. Unfortunately, some versions of
+     * WebLogic can only retrieve the servlet context from the filter config. Hence, this method enables subclasses to
+     * retrieve the servlet context from other sources.
+     *
+     * @param session the HTTP session where, in Servlet 2.3, the servlet context can be retrieved
+     * @return the servlet context.
+     */
+    protected ServletContext getServletContext() {
+        return filterConfig.getServletContext();
+    }
+
+    /**
+     * Gets this filter's configuration
+     *
+     * @return The filter config
+     */
+    protected FilterConfig getFilterConfig() {
+        return filterConfig;
+    }
+
+    /**
+     * Helper method that prepare <code>Dispatcher</code>
+     * (by calling <code>Dispatcher.prepare(HttpServletRequest, HttpServletResponse)</code>)
+     * following by wrapping and returning  the wrapping <code>HttpServletRequest</code> [ through
+     * <code>dispatcher.wrapRequest(HttpServletRequest, ServletContext)</code> ]
+     *
+     * @param request
+     * @param response
+     * @return HttpServletRequest
+     * @throws ServletException
+     */
+    protected HttpServletRequest prepareDispatcherAndWrapRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException {
+
+        Dispatcher du = Dispatcher.getInstance();
+
+        // Prepare and wrap the request if the cleanup filter hasn't already, cleanup filter should be
+        // configured first before struts2 dispatcher filter, hence when its cleanup filter's turn,
+        // static instance of Dispatcher should be null.
+        if (du == null) {
+
+            Dispatcher.setInstance(dispatcher);
+
+            // prepare the request no matter what - this ensures that the proper character encoding
+            // is used before invoking the mapper (see WW-9127)
+            dispatcher.prepare(request, response);
+
+            try {
+                // Wrap request first, just in case it is multipart/form-data
+                // parameters might not be accessible through before encoding (ww-1278)
+                request = dispatcher.wrapRequest(request, getServletContext());
+            } catch (IOException e) {
+                String message = "Could not wrap servlet request with MultipartRequestWrapper!";
+                LOG.error(message, e);
+                throw new ServletException(message, e);
+            }
+        }
+        else {
+            dispatcher = du;
+        }
+        return request;
+    }
 
     /**
      * Parses the list of packages
@@ -188,8 +315,7 @@
             ActionMapper mapper = null;
             ActionMapping mapping = null;
             try {
-                mapper = ActionMapperFactory.getMapper();
-                mapping = mapper.getMapping(request, dispatcher.getConfigurationManager());
+                mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager());
             } catch (Exception ex) {
                 LOG.error("error getting ActionMapping", ex);
                 dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
@@ -205,8 +331,7 @@
                     resourcePath = request.getPathInfo();
                 }
 
-                if ("true".equals(Settings.get(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT))
-                    && resourcePath.startsWith("/struts")) {
+                if (serveStatic && resourcePath.startsWith("/struts")) {
                     String name = resourcePath.substring("/struts".length());
                     findStaticResource(name, response);
                 } else {
@@ -247,7 +372,7 @@
                         response.setContentType(contentType);
                     }
 
-                    if ("true".equals(Settings.get(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE))) {
+                    if (serveStaticBrowserCache) {
                         // set heading information for caching static content
                         Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                         response.setHeader("Date",df.format(cal.getTime())+" GMT");
@@ -335,8 +460,7 @@
             resourcePath = packagePrefix + name;
         }
 
-        String enc = (String) Settings.get(StrutsConstants.STRUTS_I18N_ENCODING);
-        resourcePath = URLDecoder.decode(resourcePath, enc);
+        resourcePath = URLDecoder.decode(resourcePath, encoding);
 
         return ClassLoaderUtil.getResourceAsStream(resourcePath, getClass());
     }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java Mon Nov 13 00:30:40 2006
@@ -27,12 +27,12 @@
 import java.util.Map;
 
 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.views.util.UrlHelper;
 
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.inject.Inject;
 
 /**
  * <!-- START SNIPPET: description -->
@@ -135,6 +135,7 @@
     protected String actionName;
     protected String namespace;
     protected String method;
+    protected ActionMapper actionMapper;
 
     private Map<String, String> requestParameters = new HashMap<String, String>();
 
@@ -156,6 +157,11 @@
         this.actionName = actionName;
         this.method = method;
     }
+    
+    @Inject
+    public void setActionMapper(ActionMapper mapper) {
+        this.actionMapper = mapper;
+    }
 
     protected List<String> prohibitedResultParam = Arrays.asList(new String[] {
             DEFAULT_PARAM, "namespace", "method", "encode", "parse", "location",
@@ -193,8 +199,7 @@
             }
         }
 
-        ActionMapper mapper = ActionMapperFactory.getMapper();
-        StringBuffer tmpLocation = new StringBuffer(mapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null)));
+        StringBuffer tmpLocation = new StringBuffer(actionMapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null)));
         UrlHelper.buildParametersString(requestParameters, tmpLocation, "&");
 
         setLocation(tmpLocation.toString());

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java Mon Nov 13 00:30:40 2006
@@ -26,10 +26,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 
 
 /**
@@ -83,6 +84,8 @@
 
     protected boolean prependServletContext = true;
 
+    private ActionMapper actionMapper;
+
     public ServletRedirectResult() {
         super();
     }
@@ -90,6 +93,11 @@
     public ServletRedirectResult(String location) {
         super(location);
     }
+    
+    @Inject
+    public void setActionMapper(ActionMapper mapper) {
+        this.actionMapper = mapper;
+    }
 
     /**
      * Sets whether or not to prepend the servlet context path to the redirected URL.
@@ -115,7 +123,7 @@
 
         if (isPathUrl(finalLocation)) {
             if (!finalLocation.startsWith("/")) {
-                String namespace = ActionMapperFactory.getMapper().getMapping(
+                String namespace = actionMapper.getMapping(
                         request, Dispatcher.getInstance().getConfigurationManager()).getNamespace();
 
                 if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java Mon Nov 13 00:30:40 2006
@@ -34,7 +34,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.views.JspSupportServlet;
 import org.apache.struts2.views.velocity.VelocityManager;
 import org.apache.velocity.Template;
@@ -43,6 +42,7 @@
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 
@@ -87,6 +87,9 @@
     private static final long serialVersionUID = 7268830767762559424L;
 
     private static final Log log = LogFactory.getLog(VelocityResult.class);
+    
+    private String defaultEncoding;
+    private VelocityManager velocityManager;
 
     public VelocityResult() {
         super();
@@ -95,6 +98,16 @@
     public VelocityResult(String location) {
         super(location);
     }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public void setDefaultEncoding(String val) {
+        defaultEncoding = val;
+    }
+    
+    @Inject
+    public void setVelocityManager(VelocityManager mgr) {
+        this.velocityManager = mgr;
+    }
 
     /**
      * Creates a Velocity context from the action, loads a Velocity template and executes the
@@ -114,7 +127,7 @@
         ServletContext servletContext = ServletActionContext.getServletContext();
         Servlet servlet = JspSupportServlet.jspSupportServlet;
 
-        VelocityManager.getInstance().init(servletContext);
+        velocityManager.init(servletContext);
 
         boolean usedJspFactory = false;
         PageContext pageContext = (PageContext) ActionContext.getContext().get(ServletActionContext.PAGE_CONTEXT);
@@ -134,7 +147,6 @@
                 contentType = contentType + ";charset=" + encoding;
             }
 
-            VelocityManager velocityManager = VelocityManager.getInstance();
             Template t = getTemplate(stack, velocityManager.getVelocityEngine(), invocation, finalLocation, encoding);
 
             Context context = createContext(velocityManager, stack, request, response, finalLocation);
@@ -179,7 +191,7 @@
      * @return The encoding associated with this template (defaults to the value of 'struts.i18n.encoding' property)
      */
     protected String getEncoding(String templateLocation) {
-        String encoding = (String) Settings.get(StrutsConstants.STRUTS_I18N_ENCODING);
+        String encoding = defaultEncoding;
         if (encoding == null) {
             encoding = System.getProperty("file.encoding");
         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java Mon Nov 13 00:30:40 2006
@@ -31,10 +31,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.FileManager;
 
 /**
@@ -90,19 +91,39 @@
 
     private static final Log LOG = LogFactory.getLog(CompositeActionMapper.class);
 
-    protected List<IndividualActionMapperEntry> orderedActionMappers;
+    protected Container container;
+    
+    protected List<ActionMapper> actionMappers = new ArrayList<ActionMapper>();
+    
+    @Inject
+    public void setContainer(Container container) {
+        this.container = container;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_MAPPER_COMPOSITE)
+    public void setActionMappers(String list) {
+        if (list != null) {
+            String[] arr = list.split(",");
+            for (String name : arr) {
+                Object obj = container.getInstance(ActionMapper.class, name);
+                if (obj != null) {
+                    actionMappers.add((ActionMapper) obj);
+                }
+            }
+        }
+    }
 
 
     public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
 
-        for (IndividualActionMapperEntry actionMapperEntry: getOrderedActionMapperEntries()) {
-            ActionMapping actionMapping = actionMapperEntry.actionMapper.getMapping(request, configManager);
+        for (ActionMapper actionMapper : actionMappers) {
+            ActionMapping actionMapping = actionMapper.getMapping(request, configManager);
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Using ActionMapper from entry ["+actionMapperEntry.propertyName+"="+actionMapperEntry.propertyValue+"]");
+                LOG.debug("Using ActionMapper "+actionMapper);
             }
             if (actionMapping == null) {
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("ActionMapper from entry ["+actionMapperEntry.propertyName+"="+actionMapperEntry.propertyValue+"] failed to return an ActionMapping (null)");
+                    LOG.debug("ActionMapper "+actionMapper+" failed to return an ActionMapping (null)");
                 }
             }
             else {
@@ -117,14 +138,14 @@
 
     public String getUriFromActionMapping(ActionMapping mapping) {
 
-        for (IndividualActionMapperEntry actionMapperEntry: getOrderedActionMapperEntries()) {
-            String uri = actionMapperEntry.actionMapper.getUriFromActionMapping(mapping);
+        for (ActionMapper actionMapper : actionMappers) {
+            String uri = actionMapper.getUriFromActionMapping(mapping);
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Using ActionMapper from entry ["+actionMapperEntry.propertyName+"="+actionMapperEntry.propertyValue+"]");
+                LOG.debug("Using ActionMapper "+actionMapper);
             }
             if (uri == null) {
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("ActionMapper from entry ["+actionMapperEntry.propertyName+"="+actionMapperEntry.propertyValue+"] failed to return a uri (null)");
+                    LOG.debug("ActionMapper "+actionMapper+" failed to return an ActionMapping (null)");
                 }
             }
             else {
@@ -135,140 +156,5 @@
             LOG.debug("exhausted from ActionMapper that could return a uri");
         }
         return null;
-    }
-
-
-    protected List<IndividualActionMapperEntry> getOrderedActionMapperEntries() {
-        if (this.orderedActionMappers == null || FileManager.isReloadingConfigs()) {
-
-            List<IndividualActionMapperEntry> actionMapperEntriesContainer = new ArrayList<IndividualActionMapperEntry>();
-            Iterator settings = Settings.list();
-            while(settings.hasNext()) {
-                String setting = settings.next().toString();
-                if (setting.startsWith(StrutsConstants.STRUTS_MAPPER_COMPOSITE)) {
-                    try {
-                        int order = Integer.valueOf(setting.substring(StrutsConstants.STRUTS_MAPPER_COMPOSITE.length(), setting.length()));
-                        String propertyValue = Settings.get(setting);
-                        if (propertyValue != null && propertyValue.trim().length() > 0) {
-                            actionMapperEntriesContainer.add(
-                                    new IndividualActionMapperEntry(order, setting, propertyValue));
-                        }
-                        else {
-                            LOG.warn("Ignoring property "+setting+" that contains no value");
-                        }
-                    }
-                    catch(NumberFormatException e) {
-                        LOG.warn("Ignoring malformed property "+setting);
-                    }
-                }
-            }
-
-            Collections.sort(actionMapperEntriesContainer, new Comparator<IndividualActionMapperEntry>() {
-                public int compare(IndividualActionMapperEntry o1, IndividualActionMapperEntry o2) {
-                    return o1.compareTo(o2);
-                }
-            });
-
-
-            ObjectFactory objectFactory = ObjectFactory.getObjectFactory();
-            List<IndividualActionMapperEntry> result = new ArrayList<IndividualActionMapperEntry>();
-            for (IndividualActionMapperEntry entry: actionMapperEntriesContainer) {
-                String actionMapperClassName = entry.propertyValue;
-                try {
-                    // Let us get ClassCastException if it does not implement ActionMapper
-                    ActionMapper actionMapper = (ActionMapper) objectFactory.buildBean(actionMapperClassName, null);
-                    result.add(new IndividualActionMapperEntry(entry.order, entry.propertyName, entry.propertyValue, actionMapper));
-                }
-                catch(Exception e) {
-                    LOG.warn("failed to create action mapper "+actionMapperClassName+", ignoring it", e);
-                }
-            }
-
-            this.orderedActionMappers = result;
-        }
-
-        return this.orderedActionMappers;
-    }
-
-
-    /**
-     * A value object (holder) that holds information regarding {@link ActionMapper} this {@link CompositeActionMapper}
-     * is capable of delegating to.
-     * <p/>
-     * The information stored are :-
-     * <ul>
-     *  <li> order</li>
-     *  <li> propertyValue</li>
-     *  <li> propertyName</li>
-     *  <li> actionMapper</li>
-     * </ul>
-     *
-     * eg. if we have the following entry in struts.properties
-     * <pre>
-     * struts.mapper.composite.1=foo.bar.ActionMapper1
-     * struts.mapper.composite.2=foo.bar.ActionMapper2
-     * struts.mapper.composite.3=foo.bar.ActionMapper3
-     * </pre>
-     *
-     * <table border="1">
-     *  <tr>
-     *      <td>order</td>
-     *      <td>propertyName</td>
-     *      <td>propertyValue</td>
-     *      <td>actionMapper</td>
-     *  </tr>
-     *  <tr>
-     *      <td>1</td>
-     *      <td>struts.mapper.composite.1</td>
-     *      <td>foo.bar.ActionMapper1</td>
-     *      <td>instance of foo.bar.ActionMapper1</td>
-     *  </tr>
-     *  <tr>
-     *      <td>2</td>
-     *      <td>struts.mapper.composite.2</td>
-     *      <td>foo.bar.ActionMapper2</td>
-     *      <td>instance of foo.bar.ActionMapper2</td>
-     *  </tr>
-     *  <tr>
-     *      <td>3</td>
-     *      <td>struts.mapper.composite.3</td>
-     *      <td>foo.bar.ActionMapper3</td>
-     *      <td>instance of foo.bar.ActionMapper3</td>
-     *  </tr>
-     * </table>
-     *
-     * @version $Date$ $Id$
-     */
-    public class IndividualActionMapperEntry implements Comparable<IndividualActionMapperEntry> {
-
-        public Integer order;
-        public String propertyValue;
-        public String propertyName;
-        public ActionMapper actionMapper;
-
-
-        private IndividualActionMapperEntry(Integer order, String propertyName, String propertyValue) {
-            assert(order != null);
-            assert(propertyValue != null);
-            assert(propertyName != null);
-            this.order = order;
-            this.propertyValue = propertyValue;
-            this.propertyName = propertyName;
-        }
-
-        public IndividualActionMapperEntry(Integer order, String propertyName, String propertyValue, ActionMapper actionMapper) {
-            assert(order != null);
-            assert(propertyValue != null);
-            assert(propertyName != null);
-            assert(actionMapper != null);
-            this.order = order;
-            this.propertyValue = propertyValue;
-            this.propertyName = propertyName;
-            this.actionMapper = actionMapper;
-        }
-
-        public int compareTo(IndividualActionMapperEntry o) {
-            return order - o.order;
-        }
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java Mon Nov 13 00:30:40 2006
@@ -20,6 +20,7 @@
  */
 package org.apache.struts2.dispatcher.mapper;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -29,13 +30,13 @@
 
 import org.apache.struts2.RequestUtils;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.ServletRedirectResult;
 import org.apache.struts2.util.PrefixTrie;
 
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.inject.Inject;
 
 /**
  * <!-- START SNIPPET: javadoc -->
@@ -171,18 +172,10 @@
     private boolean allowSlashesInActionNames = false;
 
     private PrefixTrie prefixTrie = null;
+    
+    List extensions = new ArrayList() {{ add("action");}};
 
     public DefaultActionMapper() {
-        if (Settings.isSet(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION)) {
-            allowDynamicMethodCalls = "true".equals(Settings
-                    .get(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION));
-        }
-
-        if (Settings.isSet(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES)) {
-            allowSlashesInActionNames = "true".equals(Settings
-                    .get(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES));
-        }
-
         prefixTrie = new PrefixTrie() {
             {
                 put(METHOD_PREFIX, new ParameterAction() {
@@ -233,6 +226,16 @@
             }
         };
     }
+    
+    @Inject(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION)
+    public void setAllowDynamicMethodCalls(String allow) {
+        allowDynamicMethodCalls = "true".equals(allow);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES)
+    public void setSlashesInActionNames(String allow) {
+        allowSlashesInActionNames = "true".equals(allow);
+    }
 
     /*
      * (non-Javadoc)
@@ -352,7 +355,6 @@
      * @return The action name without its extension
      */
     String dropExtension(String name) {
-        List extensions = getExtensions();
         if (extensions == null) {
             return name;
         }
@@ -370,8 +372,7 @@
     /**
      * Returns null if no extension is specified.
      */
-    static String getDefaultExtension() {
-        List extensions = getExtensions();
+    String getDefaultExtension() {
         if (extensions == null) {
             return null;
         } else {
@@ -379,20 +380,15 @@
         }
     }
 
-    /**
-     * Returns null if no extension is specified.
-     */
-    static List getExtensions() {
-        String extensions = (String) org.apache.struts2.config.Settings
-                .get(StrutsConstants.STRUTS_ACTION_EXTENSION);
-
-        if ("".equals(extensions)) {
-            return null;
+    @Inject(StrutsConstants.STRUTS_ACTION_EXTENSION)
+    public void setExtensions(String extensions) {
+        if (!"".equals(extensions)) {
+            this.extensions = Arrays.asList(extensions.split(","));
         } else {
-            return Arrays.asList(extensions.split(","));
+            this.extensions = null;
         }
     }
-
+    
     /**
      * Gets the uri from the request
      *

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java Mon Nov 13 00:30:40 2006
@@ -38,18 +38,33 @@
 import org.apache.commons.fileupload.disk.DiskFileItem;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.StrutsConstants;
+
+import com.opensymphony.xwork2.inject.Inject;
 
 /**
  * Multipart form data request adapter for Jakarta Commons Fileupload package.
  *
  */
-public class JakartaMultiPartRequest extends MultiPartRequest {
+public class JakartaMultiPartRequest implements MultiPartRequest {
+    
+    static final Log log = LogFactory.getLog(MultiPartRequest.class);
+    
     // maps parameter name -> List of FileItem objects
     private Map<String,List<FileItem>> files = new HashMap<String,List<FileItem>>();
     // maps parameter name -> List of param values
     private Map<String,List<String>> params = new HashMap<String,List<String>>();
     // any errors while processing this request
     private List<String> errors = new ArrayList<String>();
+    
+    private long maxSize;
+    
+    @Inject(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)
+    public void setMaxSize(String maxSize) {
+        this.maxSize = Long.parseLong(maxSize);
+    }
 
     /**
      * Creates a new request wrapper to handle multi-part data using methods adapted from Jason Pell's
@@ -60,10 +75,10 @@
      * @param servletRequest the request containing the multipart
      * @throws java.io.IOException  is thrown if encoding fails.
      */
-    public JakartaMultiPartRequest(HttpServletRequest servletRequest, String saveDir, int maxSize)
+    public void parse(HttpServletRequest servletRequest, String saveDir)
             throws IOException {
         DiskFileItemFactory fac = new DiskFileItemFactory();
-        fac.setSizeThreshold(0);
+        fac.setSizeThreshold((int)maxSize);
         if (saveDir != null) {
             fac.setRepository(new File(saveDir));
         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java Mon Nov 13 00:30:40 2006
@@ -21,6 +21,7 @@
 package org.apache.struts2.dispatcher.multipart;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Enumeration;
 import java.util.List;
 
@@ -34,28 +35,16 @@
  * Abstract wrapper class HTTP requests to handle multi-part data. <p>
  *
  */
-public abstract class MultiPartRequest {
-
-    protected static Log log = LogFactory.getLog(MultiPartRequest.class);
-
-
-    /**
-     * Returns <tt>true</tt> if the request is multipart form data, <tt>false</tt> otherwise.
-     *
-     * @param request the http servlet request.
-     * @return <tt>true</tt> if the request is multipart form data, <tt>false</tt> otherwise.
-     */
-    public static boolean isMultiPart(HttpServletRequest request) {
-        String content_type = request.getContentType();
-        return content_type != null && content_type.indexOf("multipart/form-data") != -1;
-    }
+public interface MultiPartRequest {
 
+    public void parse(HttpServletRequest request, String saveDir) throws IOException;
+    
     /**
      * Returns an enumeration of the parameter names for uploaded files
      *
      * @return an enumeration of the parameter names for uploaded files
      */
-    public abstract Enumeration<String> getFileParameterNames();
+    public Enumeration<String> getFileParameterNames();
 
     /**
      * Returns the content type(s) of the file(s) associated with the specified field name
@@ -66,7 +55,7 @@
      * @return an array of content encoding for the specified input field name or <tt>null</tt> if
      *         no content type was specified.
      */
-    public abstract String[] getContentType(String fieldName);
+    public String[] getContentType(String fieldName);
 
     /**
      * Returns a {@link java.io.File} object for the filename specified or <tt>null</tt> if no files
@@ -75,7 +64,7 @@
      * @param fieldName input field name
      * @return a File[] object for files associated with the specified input field name
      */
-    public abstract File[] getFile(String fieldName);
+    public File[] getFile(String fieldName);
 
     /**
      * Returns a String[] of file names for files associated with the specified input field name
@@ -83,7 +72,7 @@
      * @param fieldName input field name
      * @return a String[] of file names for files associated with the specified input field name
      */
-    public abstract String[] getFileNames(String fieldName);
+    public String[] getFileNames(String fieldName);
 
     /**
      * Returns the file system name(s) of files associated with the given field name or
@@ -92,7 +81,7 @@
      * @param fieldName input field name
      * @return the file system name(s) of files associated with the given field name
      */
-    public abstract String[] getFilesystemName(String fieldName);
+    public String[] getFilesystemName(String fieldName);
 
     /**
      * Returns the specified request parameter.
@@ -100,14 +89,14 @@
      * @param name the name of the parameter to get
      * @return the parameter or <tt>null</tt> if it was not found.
      */
-    public abstract String getParameter(String name);
+    public String getParameter(String name);
 
     /**
      * Returns an enumeration of String parameter names.
      *
      * @return an enumeration of String parameter names.
      */
-    public abstract Enumeration<String> getParameterNames();
+    public Enumeration<String> getParameterNames();
 
     /**
      * Returns a list of all parameter values associated with a parameter name. If there is only
@@ -116,7 +105,7 @@
      * @param name the name of the parameter.
      * @return an array of all values associated with the parameter name.
      */
-    public abstract String[] getParameterValues(String name);
+    public String[] getParameterValues(String name);
 
     /**
      * Returns a list of error messages that may have occurred while processing the request.
@@ -127,5 +116,5 @@
      *
      * @return a list of Strings that represent various errors during parsing
      */
-    public abstract List getErrors();
+    public List getErrors();
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java Mon Nov 13 00:30:40 2006
@@ -21,6 +21,7 @@
 package org.apache.struts2.dispatcher.multipart;
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
@@ -36,7 +37,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.StrutsRequestWrapper;
 import org.apache.struts2.util.ClassLoaderUtils;
 
@@ -72,71 +72,19 @@
      * @param saveDir directory to save the file(s) to
      * @param maxSize maximum file size allowed
      */
-    public MultiPartRequestWrapper(HttpServletRequest request, String saveDir, int maxSize) {
+    public MultiPartRequestWrapper(MultiPartRequest multiPartRequest, HttpServletRequest request, String saveDir) {
         super(request);
-
-        if (request instanceof MultiPartRequest) {
-            multi = (MultiPartRequest) request;
-        } else {
-            String parser = Settings.get(StrutsConstants.STRUTS_MULTIPART_PARSER);
-
-            // If it's not set, use Jakarta
-            if (parser.equals("")) {
-                log.warn("Property struts.multipart.parser not set." +
-                        " Using org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest");
-                parser = "org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest";
-            }
-            // legacy support for old style property values
-            else if (parser.equals("pell")) {
-                parser = "org.apache.struts2.dispatcher.multipart.PellMultiPartRequest";
-            } else if (parser.equals("cos")) {
-                parser = "org.apache.struts2.dispatcher.multipart.CosMultiPartRequest";
-            } else if (parser.equals("jakarta")) {
-                parser = "org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest";
-            }
-
-            try {
-                Class baseClazz = org.apache.struts2.dispatcher.multipart.MultiPartRequest.class;
-
-                Class clazz = ClassLoaderUtils.loadClass(parser, MultiPartRequestWrapper.class);
-
-                // make sure it extends MultiPartRequest
-                if (!baseClazz.isAssignableFrom(clazz)) {
-                    addError("Class '" + parser + "' does not extend MultiPartRequest");
-
-                    return;
-                }
-
-                // get the constructor
-                Constructor ctor = clazz.getDeclaredConstructor(new Class[]{
-                        ClassLoaderUtils.loadClass("javax.servlet.http.HttpServletRequest", MultiPartRequestWrapper.class),
-                        java.lang.String.class, int.class
-                });
-
-                // build the parameter list
-                Object[] parms = new Object[]{
-                        request, saveDir, new Integer(maxSize)
-                };
-
-                // instantiate it
-                multi = (MultiPartRequest) ctor.newInstance(parms);
-                for (Iterator iter = multi.getErrors().iterator(); iter.hasNext();) {
-                    String error = (String) iter.next();
-                    addError(error);
-                }
-            } catch (ClassNotFoundException e) {
-                addError("Class: " + parser + " not found.");
-            } catch (NoSuchMethodException e) {
-                addError("Constructor error for " + parser + ": " + e);
-            } catch (InstantiationException e) {
-                addError("Error instantiating " + parser + ": " + e);
-            } catch (IllegalAccessException e) {
-                addError("Access errror for " + parser + ": " + e);
-            } catch (InvocationTargetException e) {
-                // This is a wrapper for any exceptions thrown by the constructor called from newInstance
-                addError(e.getTargetException().toString());
+        
+        multi = multiPartRequest;
+        try {
+            multi.parse(request, saveDir);
+            for (Iterator iter = multi.getErrors().iterator(); iter.hasNext();) {
+                String error = (String) iter.next();
+                addError(error);
             }
-        }
+        } catch (IOException e) {
+            addError("Cannot parse request: "+e.toString());
+        } 
     }
 
     /**

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java Mon Nov 13 00:30:40 2006
@@ -27,15 +27,16 @@
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.DefaultActionProxy;
+import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.Configuration;
 
 public class StrutsActionProxy extends DefaultActionProxy {
 
     private static final long serialVersionUID = -2434901249671934080L;
 
-    public StrutsActionProxy(Configuration cfg, String namespace, String actionName, Map extraContext,
+    public StrutsActionProxy(ObjectFactory objectFactory, Configuration cfg, String namespace, String actionName, Map extraContext,
                              boolean executeResult, boolean cleanupContext) throws Exception {
-        super(cfg, namespace, actionName, extraContext, executeResult, cleanupContext);
+        super(objectFactory, cfg, namespace, actionName, extraContext, executeResult, cleanupContext);
     }
 
     public String execute() throws Exception {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java Mon Nov 13 00:30:40 2006
@@ -32,11 +32,11 @@
 
     public ActionProxy createActionProxy(Configuration config, String namespace, String actionName, Map extraContext)
             throws Exception {
-        return new StrutsActionProxy(config, namespace, actionName, extraContext, true, true);
+        return new StrutsActionProxy(objectFactory, config, namespace, actionName, extraContext, true, true);
     }
 
     public ActionProxy createActionProxy(Configuration config, String namespace, String actionName, Map extraContext,
             boolean executeResult, boolean cleanupContext) throws Exception {
-        return new StrutsActionProxy(config, namespace, actionName, extraContext, executeResult, cleanupContext);
+        return new StrutsActionProxy(objectFactory, config, namespace, actionName, extraContext, executeResult, cleanupContext);
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java Mon Nov 13 00:30:40 2006
@@ -23,9 +23,12 @@
 import org.apache.struts2.dispatcher.Dispatcher;
 
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
 
+import org.apache.struts2.StrutsConstants;
+
 /**
  * <!-- START SNIPPET: description -->
  *
@@ -69,6 +72,7 @@
 public class ProfilingActivationInterceptor extends AbstractInterceptor {
 
     private String profilingKey = "profiling";
+    private boolean devMode;
 
     /**
      * @return the profilingKey
@@ -83,10 +87,15 @@
     public void setProfilingKey(String profilingKey) {
         this.profilingKey = profilingKey;
     }
+    
+    @Inject(StrutsConstants.STRUTS_DEVMODE)
+    public void setDevMode(String mode) {
+        this.devMode = "true".equals(mode);
+    }
 
     @Override
     public String intercept(ActionInvocation invocation) throws Exception {
-        if (Dispatcher.getInstance().isDevMode()) {
+        if (devMode) {
             Object val = invocation.getInvocationContext().getParameters().get(profilingKey);
             if (val != null) {
                 String sval = (val instanceof String ? (String)val : ((String[])val)[0]);

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java Mon Nov 13 00:30:40 2006
@@ -41,9 +41,11 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.views.freemarker.FreemarkerResult;
+import org.apache.struts2.StrutsConstants;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.Interceptor;
 import com.opensymphony.xwork2.interceptor.PreResultListener;
 import com.opensymphony.xwork2.util.ValueStack;
@@ -101,7 +103,13 @@
     private final static String EXPRESSION_PARAM = "expression";
 
     private boolean enableXmlWithConsole = false;
+    
+    private boolean devMode;
 
+    @Inject(StrutsConstants.STRUTS_DEVMODE)
+    public void setDevMode(String mode) {
+        this.devMode = "true".equals(mode);
+    }
 
     /**
      * Unused.
@@ -124,8 +132,6 @@
      */
     public String intercept(ActionInvocation inv) throws Exception {
 
-        Boolean devMode = (Boolean) ActionContext.getContext().get(
-                ActionContext.DEV_MODE);
         boolean cont = true;
         if (devMode) {
             final ActionContext ctx = ActionContext.getContext();

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java Mon Nov 13 00:30:40 2006
@@ -21,6 +21,7 @@
 package org.apache.struts2.portlet.dispatcher;
 
 import java.io.IOException;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -41,7 +42,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.ApplicationMap;
 import org.apache.struts2.dispatcher.Dispatcher;
 import org.apache.struts2.dispatcher.RequestMap;
@@ -54,7 +54,6 @@
 import org.apache.struts2.portlet.context.PortletActionContext;
 import org.apache.struts2.portlet.context.ServletContextHolderListener;
 import org.apache.struts2.util.AttributeMap;
-import org.apache.struts2.util.ObjectFactoryInitializable;
 
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.FileManager;
@@ -64,6 +63,7 @@
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
 
 /**
@@ -177,9 +177,20 @@
     public void init(PortletConfig cfg) throws PortletException {
         super.init(cfg);
         LOG.debug("Initializing portlet " + getPortletName());
+        
+        Map<String,String> params = new HashMap<String,String>();
+        for (Enumeration e = cfg.getInitParameterNames(); e.hasMoreElements(); ) {
+            String name = (String) e.nextElement();
+            String value = cfg.getInitParameter(name);
+            params.put(name, value);
+        }
+        
+        Dispatcher.setPortletSupportActive(true);
+        dispatcherUtils = new Dispatcher(ServletContextHolderListener.getServletContext(), params);
+        
         // For testability
         if (factory == null) {
-            factory = ActionProxyFactory.getFactory();
+            factory = dispatcherUtils.getConfigurationManager().getConfiguration().getContainer().getInstance(ActionProxyFactory.class);
         }
         portletNamespace = cfg.getInitParameter("portletNamespace");
         LOG.debug("PortletNamespace: " + portletNamespace);
@@ -205,48 +216,11 @@
         LocalizedTextUtil
                 .addDefaultResourceBundle("org/apache/struts2/struts-messages");
 
+        Container container = dispatcherUtils.getContainer();
         //check for configuration reloading
-        if ("true".equalsIgnoreCase(Settings
-                .get(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) {
+        if ("true".equalsIgnoreCase(container.getInstance(String.class, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) {
             FileManager.setReloadingConfigs(true);
         }
-
-        if ("true".equalsIgnoreCase(Settings.get(StrutsConstants.STRUTS_DEVMODE))) {
-            Settings.set(StrutsConstants.STRUTS_I18N_RELOAD, "true");
-            Settings.set(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
-        }
-
-        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")) {
-                // 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.plexus.PlexusObjectFactory";
-            }
-
-            try {
-                Class clazz = ClassLoaderUtil.loadClass(className,
-                        Jsr168Dispatcher.class);
-                ObjectFactory objectFactory = (ObjectFactory) clazz
-                        .newInstance();
-                if (objectFactory instanceof ObjectFactoryInitializable) {
-                    ((ObjectFactoryInitializable) objectFactory)
-                            .init(ServletContextHolderListener
-                                    .getServletContext());
-                }
-                ObjectFactory.setObjectFactory(objectFactory);
-            } catch (Exception e) {
-                LOG.error("Could not load ObjectFactory named " + className
-                        + ". Using default ObjectFactory.", e);
-            }
-        }
-        Dispatcher.setPortletSupportActive(true);
-        dispatcherUtils = new Dispatcher(ServletContextHolderListener.getServletContext());
     }
 
     /**
@@ -363,16 +337,16 @@
         extraContext.put(ActionContext.SESSION, sessionMap);
         extraContext.put(ActionContext.APPLICATION, applicationMap);
 
+        String defaultLocale = dispatcherUtils.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
         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(StrutsStatics.STRUTS_PORTLET_CONTEXT, getPortletContext());
-        extraContext.put(ActionContext.DEV_MODE, Boolean.valueOf(Settings.get(StrutsConstants.STRUTS_DEVMODE)));
         extraContext.put(REQUEST, request);
         extraContext.put(RESPONSE, response);
         extraContext.put(PORTLET_CONFIG, portletConfig);

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java Mon Nov 13 00:30:40 2006
@@ -38,7 +38,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.StrutsResultSupport;
 import org.apache.struts2.portlet.PortletActionConstants;
 import org.apache.struts2.portlet.context.PortletActionContext;
@@ -50,6 +49,7 @@
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**
@@ -96,7 +96,10 @@
 
     private static final Log log = LogFactory
             .getLog(PortletVelocityResult.class);
-
+    
+    private String defaultEncoding;
+    private VelocityManager velocityManager;
+    
     public PortletVelocityResult() {
         super();
     }
@@ -104,6 +107,16 @@
     public PortletVelocityResult(String location) {
         super(location);
     }
+    
+    @Inject
+    public void setVelocityManager(VelocityManager mgr) {
+        this.velocityManager = mgr;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public void setDefaultEncoding(String encoding) {
+        this.defaultEncoding = encoding;
+    }
 
     /* (non-Javadoc)
      * @see org.apache.struts2.dispatcher.StrutsResultSupport#doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation)
@@ -157,7 +170,7 @@
                 .getServletContext();
         Servlet servlet = JspSupportServlet.jspSupportServlet;
 
-        VelocityManager.getInstance().init(servletContext);
+        velocityManager.init(servletContext);
 
         boolean usedJspFactory = false;
         PageContext pageContext = (PageContext) ActionContext.getContext().get(
@@ -180,7 +193,6 @@
                 contentType = contentType + ";charset=" + encoding;
             }
 
-            VelocityManager velocityManager = VelocityManager.getInstance();
             Template t = getTemplate(stack,
                     velocityManager.getVelocityEngine(), invocation,
                     finalLocation, encoding);
@@ -232,8 +244,7 @@
      *         of 'struts.i18n.encoding' property)
      */
     protected String getEncoding(String templateLocation) {
-        String encoding = (String) Settings
-                .get(StrutsConstants.STRUTS_I18N_ENCODING);
+        String encoding = defaultEncoding;
         if (encoding == null) {
             encoding = System.getProperty("file.encoding");
         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java Mon Nov 13 00:30:40 2006
@@ -25,12 +25,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
-import org.apache.struts2.util.ObjectFactoryInitializable;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.spring.SpringObjectFactory;
 
 
@@ -42,13 +41,24 @@
  * <code>org.springframework.web.context.ContextLoaderListener</code> defined in <code>web.xml</code>.
  *
  */
-public class StrutsSpringObjectFactory extends SpringObjectFactory implements ObjectFactoryInitializable {
+public class StrutsSpringObjectFactory extends SpringObjectFactory {
     private static final Log log = LogFactory.getLog(StrutsSpringObjectFactory.class);
-
-    /* (non-Javadoc)
-     * @see org.apache.struts2.util.ObjectFactoryInitializable#init(javax.servlet.ServletContext)
-     */
-    public void init(ServletContext servletContext) {
+    
+    private String autoWire;
+    private boolean useClassCache = true;
+    
+    @Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE,required=false)
+    public void setAutoWire(String val) {
+        autoWire = val;
+    }
+    
+    @Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE,required=false)
+    public void setUseClassCache(String val) {
+        useClassCache = "true".equals(val);
+    }
+    
+    @Inject
+    public void setServletContext(ServletContext servletContext) {
         log.info("Initializing Struts-Spring integration...");
 
         ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
@@ -67,7 +77,6 @@
 
         this.setApplicationContext(appContext);
 
-        String autoWire = Settings.get(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE);
         int type = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME;   // default
         if ("name".equals(autoWire)) {
             type = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME;
@@ -80,7 +89,6 @@
         }
         this.setAutowireStrategy(type);
 
-        boolean useClassCache = "true".equals(Settings.get(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE));
         this.setUseClassCache(useClassCache);
 
         log.info("... initialized Struts-Spring integration successfully");

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/VelocityStrutsUtil.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/VelocityStrutsUtil.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/VelocityStrutsUtil.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/VelocityStrutsUtil.java Mon Nov 13 00:30:40 2006
@@ -27,6 +27,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts2.views.velocity.VelocityManager;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.ParseErrorException;
@@ -42,15 +43,17 @@
 public class VelocityStrutsUtil extends StrutsUtil {
 
     private Context ctx;
+    private VelocityEngine velocityEngine;
 
-    public VelocityStrutsUtil(Context ctx, ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
+    public VelocityStrutsUtil(VelocityEngine engine, Context ctx, ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
         super(stack, request, response);
         this.ctx = ctx;
+        this.velocityEngine = engine;
     }
 
     public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException {
         CharArrayWriter writer = new CharArrayWriter();
-        VelocityManager.getInstance().getVelocityEngine().evaluate(ctx, writer, "Error parsing " + expression, expression);
+        velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression);
 
         return writer.toString();
     }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java Mon Nov 13 00:30:40 2006
@@ -40,6 +40,7 @@
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.DefaultActionInvocation;
 import com.opensymphony.xwork2.DefaultActionProxy;
+import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.ValidationAwareSupport;
 import com.opensymphony.xwork2.config.Configuration;
@@ -90,7 +91,8 @@
 
         try {
             Configuration cfg = du.getConfigurationManager().getConfiguration();
-            ValidatorActionProxy proxy = new ValidatorActionProxy(cfg, namespace, action, ctx);
+            ObjectFactory of = cfg.getContainer().getInstance(ObjectFactory.class);
+            ValidatorActionProxy proxy = new ValidatorActionProxy(of, cfg, namespace, action, ctx);
             proxy.execute();
             Object a = proxy.getAction();
 
@@ -114,8 +116,8 @@
     public static class ValidatorActionInvocation extends DefaultActionInvocation {
         private static final long serialVersionUID = -7645433725470191275L;
 
-        protected ValidatorActionInvocation(ActionProxy proxy, Map extraContext) throws Exception {
-            super(proxy, extraContext, true);
+        protected ValidatorActionInvocation(ObjectFactory objectFactory, ActionProxy proxy, Map extraContext) throws Exception {
+            super(objectFactory, proxy, extraContext, true);
         }
 
         protected String invokeAction(Object action, ActionConfig actionConfig) throws Exception {
@@ -126,12 +128,12 @@
     public static class ValidatorActionProxy extends DefaultActionProxy {
         private static final long serialVersionUID = 5754781916414047963L;
 
-        protected ValidatorActionProxy(Configuration config, String namespace, String actionName, Map extraContext) throws Exception {
-            super(config, namespace, actionName, extraContext, false, true);
+        protected ValidatorActionProxy(ObjectFactory objectFactory, Configuration config, String namespace, String actionName, Map extraContext) throws Exception {
+            super(objectFactory, config, namespace, actionName, extraContext, false, true);
         }
 
         protected void prepare() throws Exception {
-            invocation = new ValidatorActionInvocation(this, extraContext);
+            invocation = new ValidatorActionInvocation(objectFactory, this, extraContext);
         }
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java Mon Nov 13 00:30:40 2006
@@ -35,11 +35,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.views.JspSupportServlet;
 import org.apache.struts2.views.freemarker.tags.StrutsModels;
 import org.apache.struts2.views.util.ContextUtil;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.FileManager;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.ObjectFactory;
@@ -114,40 +114,19 @@
     public static final String KEY_SESSION_MODEL = "Session";
     public static final String KEY_JSP_TAGLIBS = "JspTaglibs";
     public static final String KEY_REQUEST_PARAMETER_MODEL = "Parameters";
-    private static FreemarkerManager instance = null;
-
-
-    /**
-     * To allow for custom configuration of freemarker, sublcass this class "ConfigManager" and
-     * set the Struts configuration property
-     * <b>struts.freemarker.configmanager.classname</b> to the fully qualified classname.
-     * <p/>
-     * This allows you to override the protected methods in the ConfigMangaer
-     * to programatically create your own Configuration instance
-     */
-    public final static synchronized FreemarkerManager getInstance() {
-        if (instance == null) {
-            String classname = FreemarkerManager.class.getName();
-
-            if (Settings.isSet(StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME)) {
-                classname = Settings.get(StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME).trim();
-            }
-
-            try {
-                log.info("Instantiating Freemarker ConfigManager!, " + classname);
-                // singleton instances shouldn't be built accessing request or session-specific context data
-                instance = (FreemarkerManager) ObjectFactory.getObjectFactory().buildBean(classname, null);
-            } catch (Exception e) {
-                log.fatal("Fatal exception occurred while trying to instantiate a Freemarker ConfigManager instance, " + classname, e);
-            }
-        }
-
-        // if the instance creation failed, make sure there is a default instance
-        if (instance == null) {
-            instance = new FreemarkerManager();
-        }
-
-        return instance;
+    
+    private String encoding;
+    private boolean altMapWrapper;
+    
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_FREEMARKER_WRAPPER_ALT_MAP)
+    public void setWrapperAltMap(String val) {
+        altMapWrapper = "true".equals(val);
     }
 
     public final synchronized freemarker.template.Configuration getConfiguration(ServletContext servletContext) throws TemplateException {
@@ -240,7 +219,7 @@
     }
 
     protected BeansWrapper getObjectWrapper() {
-        return new StrutsBeanWrapper();
+        return new StrutsBeanWrapper(altMapWrapper);
     }
 
     /**
@@ -306,8 +285,8 @@
 
         configuration.setObjectWrapper(getObjectWrapper());
 
-        if (Settings.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) {
-            configuration.setDefaultEncoding(Settings.get(StrutsConstants.STRUTS_I18N_ENCODING));
+        if (encoding != null) {
+            configuration.setDefaultEncoding(encoding);
         }
 
         loadSettings(servletContext, configuration);

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java Mon Nov 13 00:30:40 2006
@@ -35,6 +35,7 @@
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.LocaleProvider;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 import freemarker.template.Configuration;
@@ -99,6 +100,7 @@
     protected ActionInvocation invocation;
     protected Configuration configuration;
     protected ObjectWrapper wrapper;
+    protected FreemarkerManager freemarkerManager;
 
     /*
      * Struts results are constructed for each result execution
@@ -115,6 +117,11 @@
     public FreemarkerResult(String location) {
         super(location);
     }
+    
+    @Inject
+    public void setFreemarkerManager(FreemarkerManager mgr) {
+        this.freemarkerManager = mgr;
+    }
 
     public void setContentType(String aContentType) {
         pContentType = aContentType;
@@ -176,7 +183,7 @@
      * </b>
      */
     protected Configuration getConfiguration() throws TemplateException {
-        return FreemarkerManager.getInstance().getConfiguration(ServletActionContext.getServletContext());
+        return freemarkerManager.getConfiguration(ServletActionContext.getServletContext());
     }
 
     /**
@@ -226,7 +233,7 @@
 
         Object action = null;
         if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException
-        return FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper);
+        return freemarkerManager.buildTemplateModel(stack, action, servletContext, request, response, wrapper);
     }
 
     /**

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java Mon Nov 13 00:30:40 2006
@@ -38,6 +38,7 @@
 import org.apache.struts2.views.util.ResourceUtil;
 
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 import freemarker.template.Configuration;
@@ -58,6 +59,7 @@
     protected Configuration configuration;
 
     protected ObjectWrapper wrapper;
+    protected FreemarkerManager freemarkerManager;
 
     /*
      * Struts results are constructed for each result execeution
@@ -75,6 +77,11 @@
     public PortletFreemarkerResult(String location) {
         super(location);
     }
+    
+    @Inject
+    public void setFreemarkerManager(FreemarkerManager mgr) {
+        this.freemarkerManager = mgr;
+    }
 
     public void setContentType(String aContentType) {
         pContentType = aContentType;
@@ -177,7 +184,7 @@
      * from the ConfigurationManager instance. </b>
      */
     protected Configuration getConfiguration() throws TemplateException {
-        return FreemarkerManager.getInstance().getConfiguration(
+        return freemarkerManager.getConfiguration(
                 ServletActionContext.getServletContext());
     }
 
@@ -224,7 +231,7 @@
         HttpServletResponse response = ServletActionContext.getResponse();
         ValueStack stack = ServletActionContext.getContext()
                 .getValueStack();
-        return FreemarkerManager.getInstance().buildTemplateModel(stack,
+        return freemarkerManager.buildTemplateModel(stack,
                 invocation.getAction(), servletContext, request, response,
                 wrapper);
     }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java Mon Nov 13 00:30:40 2006
@@ -23,6 +23,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.struts2.StrutsConstants;
+
 import freemarker.core.CollectionAndSequence;
 import freemarker.ext.beans.BeansWrapper;
 import freemarker.ext.beans.MapModel;
@@ -51,8 +53,11 @@
  * <!-- END SNIPPET: javadoc -->
  */
 public class StrutsBeanWrapper extends BeansWrapper {
-    private static final boolean altMapWrapper
-            = "true".equals(org.apache.struts2.config.Settings.get("struts.freemarker.wrapper.altMap"));
+    private boolean altMapWrapper;
+    
+    StrutsBeanWrapper(boolean altMapWrapper) {
+        this.altMapWrapper = altMapWrapper;
+    }
 
     public TemplateModel wrap(Object object) throws TemplateModelException {
         if (object instanceof TemplateBooleanModel) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/ActionModel.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/ActionModel.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/ActionModel.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/tags/ActionModel.java Mon Nov 13 00:30:40 2006
@@ -25,7 +25,11 @@
 
 import org.apache.struts2.components.ActionComponent;
 import org.apache.struts2.components.Component;
+import org.apache.struts2.dispatcher.Dispatcher;
 
+import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**

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?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- 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 Mon Nov 13 00:30:40 2006
@@ -31,8 +31,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.components.ActionComponent;
 import org.apache.struts2.components.Component;
+import org.apache.struts2.dispatcher.Dispatcher;
 
+import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.ValueStack;
 
 import freemarker.template.SimpleNumber;
@@ -55,6 +58,8 @@
 
     public Writer getWriter(Writer writer, Map params) throws TemplateModelException, IOException {
         Component bean = getBean();
+        Container container = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getContainer();
+        container.inject(bean);
         Map basicParams = convertParams(params);
         bean.copyParams(basicParams);
         bean.addAllParameters(getComplexParams(params));

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java Mon Nov 13 00:30:40 2006
@@ -25,7 +25,11 @@
 import javax.servlet.jsp.JspException;
 
 import org.apache.struts2.components.Component;
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
 
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**
@@ -43,6 +47,9 @@
 
     public int doStartTag() throws JspException {
         component = getBean(getStack(), (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
+        Container container = Dispatcher.getInstance().getContainer();
+        container.inject(component);
+        
         populateParams();
         boolean evalBody = component.start(pageContext.getOut());
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java Mon Nov 13 00:30:40 2006
@@ -33,7 +33,6 @@
 import org.apache.struts2.dispatcher.RequestMap;
 import org.apache.struts2.dispatcher.SessionMap;
 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.AttributeMap;
 
@@ -81,12 +80,11 @@
         return stack;
     }
 
-    public static String buildNamespace(ValueStack stack, HttpServletRequest request) {
+    public static String buildNamespace(ActionMapper mapper, ValueStack stack, HttpServletRequest request) {
         ActionContext context = new ActionContext(stack.getContext());
         ActionInvocation invocation = context.getActionInvocation();
 
         if (invocation == null) {
-            ActionMapper mapper = ActionMapperFactory.getMapper();
             ActionMapping mapping = mapper.getMapping(request,
                     Dispatcher.getInstance().getConfigurationManager());
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/FormTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/FormTag.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/FormTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/FormTag.java Mon Nov 13 00:30:40 2006
@@ -25,7 +25,9 @@
 
 import org.apache.struts2.components.Component;
 import org.apache.struts2.components.Form;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java Mon Nov 13 00:30:40 2006
@@ -27,12 +27,12 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.util.StrutsUtil;
 import org.apache.struts2.views.jsp.ui.OgnlTool;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 /**
@@ -50,6 +50,13 @@
     public static final String OGNL = "ognl";
     public static final String STRUTS = "struts";
     public static final String ACTION = "action";
+    
+    public static boolean altSyntax;
+    
+    @Inject(StrutsConstants.STRUTS_TAG_ALTSYNTAX)
+    public static void setAltSyntax(String val) {
+        altSyntax = "true".equals(val);
+    }
 
     public static Map getStandardContext(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         HashMap map = new HashMap();
@@ -79,7 +86,6 @@
         // We didn't make altSyntax static cause, if so, struts.configuration.xml.reload will not work
         // plus the Configuration implementation should cache the properties, which the framework's
         // configuration implementation does
-        boolean altSyntax = "true".equals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX));
         return altSyntax ||(
                 (context.containsKey("useAltSyntax") &&
                         context.get("useAltSyntax") != null &&

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java Mon Nov 13 00:30:40 2006
@@ -36,9 +36,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.XWorkContinuationConfig;
@@ -62,6 +62,25 @@
     private static final int DEFAULT_HTTPS_PORT = 443;
 
     private static final String AMP = "&amp;";
+    
+    private static int httpPort = DEFAULT_HTTP_PORT;
+    private static int httpsPort = DEFAULT_HTTPS_PORT;
+    private static String customEncoding;
+    
+    @Inject(StrutsConstants.STRUTS_URL_HTTP_PORT)
+    public static void setHttpPort(String val) {
+        httpPort = Integer.parseInt(val);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_URL_HTTPS_PORT)
+    public static void setHttpsPort(String val) {
+        httpsPort = Integer.parseInt(val);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
+    public static void setCustomEncoding(String val) {
+        customEncoding = val;
+    }
 
     public static String buildUrl(String action, HttpServletRequest request, HttpServletResponse response, Map params) {
         return buildUrl(action, request, response, params, null, true, true);
@@ -76,20 +95,6 @@
 
         boolean changedScheme = false;
 
-        int httpPort = DEFAULT_HTTP_PORT;
-
-        try {
-            httpPort = Integer.parseInt((String) Settings.get(StrutsConstants.STRUTS_URL_HTTP_PORT));
-        } catch (Exception ex) {
-        }
-
-        int httpsPort = DEFAULT_HTTPS_PORT;
-
-        try {
-            httpsPort = Integer.parseInt((String) Settings.get(StrutsConstants.STRUTS_URL_HTTPS_PORT));
-        } catch (Exception ex) {
-        }
-
         // only append scheme if it is different to the current scheme *OR*
         // if we explicity want it to be appended by having forceAddSchemeHostAndPort = true
         if (forceAddSchemeHostAndPort) {
@@ -276,8 +281,8 @@
 
     private static String getEncodingFromConfiguration() {
         final String encoding;
-        if (Settings.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) {
-            encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING);
+        if (customEncoding != null) {
+            encoding = customEncoding;
         } else {
             encoding = "UTF-8";
         }