Commits

Anonymous committed f5cb869

XW-615 Fix generics in all codebase
XWork Java5 enhancements
o added generics where possible
o use parameterizes Collection classes where possible
o converted for to for-each loops
o optimized imports
o updated tests
o aligned parameter types with Struts2
o fixed some minor bugs

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1833e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits b521baa

Comments (0)

Files changed (351)

File showcase/src/java/com/opensymphony/xwork2/showcase/interceptorExample/xwork-interceptor-example.xml

 			<result type="printToConsole">InterceptorExample - Action3 - Result</result>
 		</action>
 		
-		<action name="interceptorExampleAction4" class="com.opensymphony.xwork.showcase.interceptorExample.Action4">
+		<action name="interceptorExampleAction4" class="com.opensymphony.xwork2.showcase.interceptorExample.Action4">
 			<interceptor-ref name="myInterceptorStack">
 				<param name="interceptor1.param">new paramValue1</param>
 			</interceptor-ref>

File src/java/com/opensymphony/xwork2/ActionChainResult.java

 */
 package com.opensymphony.xwork2;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
+import java.util.*;
+
 
 /**
 * <!-- START SNIPPET: description -->
      * Get the XWork chain history.
      * The stack is a list of <code>namespace/action!method</code> keys.
      */
-    public static LinkedList getChainHistory() {
-        LinkedList chainHistory = (LinkedList) ActionContext.getContext().get(CHAIN_HISTORY);
+    public static LinkedList<String> getChainHistory() {
+        LinkedList<String> chainHistory = (LinkedList<String>) ActionContext.getContext().get(CHAIN_HISTORY);
         //  Add if not exists
         if (chainHistory == null) {
-            chainHistory = new LinkedList();
+            chainHistory = new LinkedList<String>();
             ActionContext.getContext().put(CHAIN_HISTORY, chainHistory);
         }
 
         }
         addToHistory(finalNamespace, finalActionName, finalMethodName);
 
-        HashMap extraContext = new HashMap();
+        HashMap<String, Object> extraContext = new HashMap<String, Object>();
         extraContext.put(ActionContext.VALUE_STACK, ActionContext.getContext().getValueStack());
         extraContext.put(ActionContext.PARAMETERS, ActionContext.getContext().getParameters());
         extraContext.put(CHAIN_HISTORY, ActionChainResult.getChainHistory());
         proxy.execute();
     }
 
-    public boolean equals(Object o) {
+    @Override public boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 
         return true;
     }
 
-    public int hashCode() {
+    @Override public int hashCode() {
         int result;
         result = (actionName != null ? actionName.hashCode() : 0);
         result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
     }
 
     private boolean isInChainHistory(String namespace, String actionName, String methodName) {
-        LinkedList chainHistory = ActionChainResult.getChainHistory();
+        LinkedList<? extends String> chainHistory = ActionChainResult.getChainHistory();
 
         if (chainHistory == null) {
             return false;
         } else {
             //  Actions to skip
-            Set skipActionsList = new HashSet();
+            Set<String> skipActionsList = new HashSet<String>();
             if (skipActions != null && skipActions.length() > 0) {
                 ValueStack stack = ActionContext.getContext().getValueStack();
                 String finalSkipActions = TextParseUtil.translateVariables(this.skipActions, stack);
     }
 
     private void addToHistory(String namespace, String actionName, String methodName) {
-        LinkedList chainHistory = ActionChainResult.getChainHistory();
+        List<String> chainHistory = ActionChainResult.getChainHistory();
         chainHistory.add(makeKey(namespace, actionName, methodName));
     }
 

File src/java/com/opensymphony/xwork2/ActionContext.java

 
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
 
 import java.io.Serializable;
 import java.util.HashMap;
     /**
      * Constant for the container
      */
-    public static final String CONTAINER = "com.opensymphony.xwork.ActionContext.container";
+    public static final String CONTAINER = "com.opensymphony.xwork2.ActionContext.container";
     
-    Map context;
+    Map<String, Object> context;
 
 
     /**
      *
      * @param context a context map.
      */
-    public ActionContext(Map context) {
+    public ActionContext(Map<String, Object> context) {
         this.context = context;
     }
 
      *
      * @param application the action's application context.
      */
-    public void setApplication(Map application) {
+    public void setApplication(Map<String, Object> application) {
         put(APPLICATION, application);
     }
 
      *
      * @return a Map of ServletContext or generic application level Map
      */
-    public Map getApplication() {
-        return (Map) get(APPLICATION);
+    public Map<String, Object> getApplication() {
+        return (Map<String, Object>) get(APPLICATION);
     }
 
     /**
      * @return the ActionContext for the current thread, is never <tt>null</tt>.
      */
     public static ActionContext getContext() {
-        ActionContext context = (ActionContext) actionContext.get();
+        return (ActionContext) actionContext.get();
 
         // Don't do lazy context creation, as it requires container; the creation of which may 
         // precede the context creation
         //    setContext(context);
         //}
 
-        return context;
     }
 
     /**
      *
      * @param contextMap the context map.
      */
-    public void setContextMap(Map contextMap) {
+    public void setContextMap(Map<String, Object> contextMap) {
         getContext().context = contextMap;
     }
 
      *
      * @return the context map.
      */
-    public Map getContextMap() {
+    public Map<String, Object> getContextMap() {
         return context;
     }
 
      *
      * @param conversionErrors a Map of errors which occurred when executing the action.
      */
-    public void setConversionErrors(Map conversionErrors) {
+    public void setConversionErrors(Map<String, Object> conversionErrors) {
         put(CONVERSION_ERRORS, conversionErrors);
     }
 
      * @return the map of conversion errors which occurred when executing the action or an empty map if
      *         there were no errors.
      */
-    public Map getConversionErrors() {
-        Map errors = (Map) get(CONVERSION_ERRORS);
+    public Map<String, Object> getConversionErrors() {
+        Map<String, Object> errors = (Map) get(CONVERSION_ERRORS);
 
         if (errors == null) {
-            errors = new HashMap();
+            errors = new HashMap<String, Object>();
             setConversionErrors(errors);
         }
 
      *
      * @param parameters the parameters for the current action.
      */
-    public void setParameters(Map parameters) {
+    public void setParameters(Map<String, Object> parameters) {
         put(PARAMETERS, parameters);
     }
 
      * @return a Map of HttpServletRequest parameters or a multipart map when in a servlet environment, or a
      *         generic Map of parameters otherwise.
      */
-    public Map getParameters() {
-        return (Map) get(PARAMETERS);
+    public Map<String, Object> getParameters() {
+        return (Map<String, Object>) get(PARAMETERS);
     }
 
     /**
      *
      * @param session  the session values.
      */
-    public void setSession(Map session) {
+    public void setSession(Map<String, Object> session) {
         put(SESSION, session);
     }
 
      *
      * @return the Map of HttpSession values when in a servlet environment or a generic session map otherwise.
      */
-    public Map getSession() {
-        return (Map) get(SESSION);
+    public Map<String, Object> getSession() {
+        return (Map<String, Object>) get(SESSION);
     }
 
     /**
      * @param key the key used to find the value.
      * @return the value that was found using the key or <tt>null</tt> if the key was not found.
      */
-    public Object get(Object key) {
+    public Object get(String key) {
         return context.get(key);
     }
 
      * @param key   the key of the value.
      * @param value the value to be stored.
      */
-    public void put(Object key, Object value) {
+    public void put(String key, Object value) {
         context.put(key, value);
     }
 }

File src/java/com/opensymphony/xwork2/ActionInvocation.java

 import com.opensymphony.xwork2.util.ValueStack;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
 
 
 /**

File src/java/com/opensymphony/xwork2/ActionProxyFactory.java

 
 import java.util.Map;
 
-import com.opensymphony.xwork2.config.Configuration;
-
 
 /**
  * The {@link ActionProxyFactory} is used to create {@link ActionProxy}s to be executed.
      * @return ActionProxy  the created action proxy
      * @deprecated Since 2.1.1, use {@link #createActionProxy(String,String,String,Map) instead}
      */
-    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext);
+    @Deprecated public ActionProxy createActionProxy(String namespace, String actionName, Map<String, Object> extraContext);
 
     /**
      * Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
      * @return ActionProxy  the created action proxy
      * @since 2.1.1
      */
-    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map extraContext);
+    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext);
 
     /**
      * Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
      * @return ActionProxy  the created action proxy
      * @deprecated Since 2.1.1, use {@link #createActionProxy(String,String,String,Map,boolean,boolean)} instead
      */
-    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext);
+    @Deprecated public ActionProxy createActionProxy(String namespace, String actionName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext);
 
     /**
      * Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
      * @return ActionProxy  the created action proxy
      * @since 2.1.1
      */
-    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map extraContext, boolean executeResult, boolean cleanupContext);
+    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext);
 
 
      /**

File src/java/com/opensymphony/xwork2/ActionSupport.java

  */
 package com.opensymphony.xwork2;
 
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
+import java.io.Serializable;
+import java.util.*;
+
 
 /**
  * Provides a default implementation for the most common actions.
     private final ValidationAwareSupport validationAware = new ValidationAwareSupport();
 
 
-    public void setActionErrors(Collection errorMessages) {
+    public void setActionErrors(Collection<String> errorMessages) {
         validationAware.setActionErrors(errorMessages);
     }
 
-    public Collection getActionErrors() {
+    public Collection<String> getActionErrors() {
         return validationAware.getActionErrors();
     }
 
-    public void setActionMessages(Collection messages) {
+    public void setActionMessages(Collection<String> messages) {
         validationAware.setActionMessages(messages);
     }
 
-    public Collection getActionMessages() {
+    public Collection<String> getActionMessages() {
         return validationAware.getActionMessages();
     }
 
     /**
      * @deprecated Use {@link #getActionErrors()}.
      */
-    public Collection getErrorMessages() {
+    @Deprecated public Collection<String> getErrorMessages() {
         return getActionErrors();
     }
 
     /**
      * @deprecated Use {@link #getFieldErrors()}.
      */
-    public Map getErrors() {
+    @Deprecated public Map<String, List<String>> getErrors() {
         return getFieldErrors();
     }
 
-    public void setFieldErrors(Map errorMap) {
+    public void setFieldErrors(Map<String, List<String>> errorMap) {
         validationAware.setFieldErrors(errorMap);
     }
 
-    public Map getFieldErrors() {
+    public Map<String, List<String>> getFieldErrors() {
         return validationAware.getFieldErrors();
     }
 
         return textProvider.getText(aTextName, defaultValue, obj);
     }
 
-    public String getText(String aTextName, List args) {
+    public String getText(String aTextName, List<Object> args) {
         return textProvider.getText(aTextName, args);
     }
 
         return textProvider.getText(key, args);
     }
 
-    public String getText(String aTextName, String defaultValue, List args) {
+    public String getText(String aTextName, String defaultValue, List<Object> args) {
         return textProvider.getText(aTextName, defaultValue, args);
     }
 
         return textProvider.getText(key, defaultValue, args);
     }
 
-    public String getText(String key, String defaultValue, List args, ValueStack stack) {
+    public String getText(String key, String defaultValue, List<Object> args, ValueStack stack) {
         return textProvider.getText(key, defaultValue, args, stack);
     }
 
     public void validate() {
     }
 
-    public Object clone() throws CloneNotSupportedException {
+    @Override public Object clone() throws CloneNotSupportedException {
         return super.clone();
     }
 

File src/java/com/opensymphony/xwork2/CompositeTextProvider.java

+package com.opensymphony.xwork2;
+
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.*;
+
+
+/**
+ * This is a composite {@link TextProvider} that takes in an array or {@link java.util.List} of {@link TextProvider}s, it will
+ * consult each of them in order to get a composite result. To know how each method behaves, please refer to the
+ * javadoc for each methods.
+ *
+ * @author tmjee
+ * @version $Date$ $Id$
+ */
+public class CompositeTextProvider implements TextProvider {
+
+    private static final Log LOG = LogFactory.getLog(CompositeTextProvider.class);
+
+    private List<TextProvider> textProviders = new ArrayList<TextProvider>();
+
+    /**
+     * Instantiates a {@link CompositeTextProvider} with some predefined <code>textProviders</code>.
+     *
+     * @param textProviders
+     */
+    public CompositeTextProvider(List<TextProvider> textProviders) {
+        this.textProviders.addAll(textProviders);
+    }
+
+    /**
+     * Instantiates a {@link CompositeTextProvider} with some predefined <code>textProviders</code>.
+     *
+     * @param textProviders
+     */
+    public CompositeTextProvider(TextProvider[] textProviders) {
+        this(Arrays.asList(textProviders));
+    }
+
+    /**
+     * @param key The key to lookup in ressource bundles.
+     * @return <tt>true</tt>, if the requested key is found in one of the ressource bundles.
+     * @see {@link com.opensymphony.xwork2.TextProvider#hasKey(String)}
+     *      It will consult each individual {@link TextProvider}s and return true if either one of the
+     *      {@link TextProvider} has such a <code>key></code> else false.
+     */
+    public boolean hasKey(String key) {
+        // if there's a key in either text providers we are ok, else try the next text provider
+        for (TextProvider tp : textProviders) {
+            if (tp.hasKey(key)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>
+     *
+     * @param key The key to lookup in ressource bundles.
+     * @return The i18n text for the requested key.
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String)}
+     */
+    public String getText(String key) {
+        return getText(key, key, Collections.emptyList());
+    }
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code> before returning <code>defaultValue</code> if every else fails.
+     *
+     * @param key
+     * @param defaultValue
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String)}
+     */
+    public String getText(String key, String defaultValue) {
+        return getText(key, defaultValue, Collections.emptyList());
+    }
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>, before returining <code>defaultValue</code>
+     * if every else fails.
+     *
+     * @param key
+     * @param defaultValue
+     * @param obj
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String, String)}
+     */
+    public String getText(String key, String defaultValue, final String obj) {
+        return getText(key, defaultValue, new ArrayList<Object>() {
+            {
+                add(obj);
+            }
+
+
+        });
+    }
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>.
+     *
+     * @param key
+     * @param args
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, java.util.List)}
+     */
+    public String getText(String key, List<Object> args) {
+        return getText(key, key, args);
+    }
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>.
+     *
+     * @param key
+     * @param args
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String[])}
+     */
+    public String getText(String key, String[] args) {
+        return getText(key, key, args);
+    }
+
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>, before returining <code>defaultValue</code>
+     *
+     * @param key
+     * @param defaultValue
+     * @param args
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText#getText(String, String, java.util.List)}
+     */
+    public String getText(String key, String defaultValue, List<Object> args) {
+        // if there's one text provider that gives us a msg not the same as defaultValue
+        // for this key, we are ok, else try the next
+        // text provider
+        for (TextProvider textProvider : textProviders) {
+            String msg = textProvider.getText(key, defaultValue, args);
+            if (msg != null && (!msg.equals(defaultValue))) {
+                return msg;
+            }
+        }
+        return defaultValue;
+    }
+
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>, before returining <code>defaultValue</code>.
+     *
+     * @param key
+     * @param defaultValue
+     * @param args
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String, String[])}
+     */
+    public String getText(String key, String defaultValue, String[] args) {
+        // if there's one text provider that gives us a msg not the same as defaultValue
+        // for this key, we are ok, else try the next
+        // text provider
+        for (TextProvider textProvider : textProviders) {
+            String msg = textProvider.getText(key, defaultValue, args);
+            if (msg != null && (!msg.equals(defaultValue))) {
+                return msg;
+            }
+        }
+        return defaultValue;
+    }
+
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>, before returining <code>defaultValue</code>
+     *
+     * @param key
+     * @param defaultValue
+     * @param args
+     * @param stack
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String, java.util.List, com.opensymphony.xwork2.util.OgnlValueStack)}
+     */
+    public String getText(String key, String defaultValue, List<Object> args, ValueStack stack) {
+        // if there's one text provider that gives us a msg not the same as defaultValue
+        // for this key, we are ok, else try the next
+        // text provider
+        for (TextProvider textProvider : textProviders) {
+            String msg = textProvider.getText(key, defaultValue, args, stack);
+            if (msg != null && (!msg.equals(defaultValue))) {
+                return msg;
+            }
+        }
+        return defaultValue;
+    }
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first valid message for this
+     * <code>key</code>, before returining <code>defaultValue</code>
+     *
+     * @param key
+     * @param defaultValue
+     * @param args
+     * @param stack
+     * @return
+     * @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String, String[], com.opensymphony.xwork2.util.ValueStack)}
+     */
+    public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
+        // if there's one text provider that gives us a msg not the same as defaultValue
+        // for this key, we are ok, else try the next
+        // text provider
+        for (TextProvider textProvider : textProviders) {
+            String msg = textProvider.getText(key, defaultValue, args, stack);
+            if (msg != null && (!msg.equals(defaultValue))) {
+                return msg;
+            }
+        }
+        return defaultValue;
+    }
+
+
+    /**
+     * It will consult each {@link TextProvider}s and return the first non-null {@link ResourceBundle}.
+     *
+     * @param bundleName
+     * @return
+     * @see {@link TextProvider#getTexts(String)}
+     */
+    public ResourceBundle getTexts(String bundleName) {
+        // if there's one text provider that gives us a non-null resource bunlde for this bundleName, we are ok, else try the next
+        // text provider
+        for (TextProvider textProvider : textProviders) {
+            ResourceBundle bundle = textProvider.getTexts(bundleName);
+            if (bundle != null) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * It will consult each {@link com.opensymphony.xwork2.TextProvider}s and return the first non-null {@link ResourceBundle}.
+     *
+     * @return
+     * @see {@link TextProvider#getTexts()}
+     */
+    public ResourceBundle getTexts() {
+        // if there's one text provider that gives us a non-null resource bundle, we are ok, else try the next
+        // text provider
+        for (TextProvider textProvider : textProviders) {
+            ResourceBundle bundle = textProvider.getTexts();
+            if (bundle != null) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+}
+
+

File src/java/com/opensymphony/xwork2/DefaultActionInvocation.java

  */
 package com.opensymphony.xwork2;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 
 /**
  * The Default ActionInvocation implementation
 
     protected Object action;
     protected ActionProxy proxy;
-    protected List preResultListeners;
-    protected Map extraContext;
+    protected List<PreResultListener> preResultListeners;
+    protected Map<String, Object> extraContext;
     protected ActionContext invocationContext;
-    protected Iterator interceptors;
+    protected Iterator<InterceptorMapping> interceptors;
     protected ValueStack stack;
     protected Result result;
     protected Result explicitResult;
     protected Container container;
     protected UnknownHandler unknownHandler;
 
-    public DefaultActionInvocation(final Map extraContext, final boolean pushAction) {
+    public DefaultActionInvocation(final Map<String, Object> extraContext, final boolean pushAction) {
         DefaultActionInvocation.this.extraContext = extraContext;
         DefaultActionInvocation.this.pushAction = pushAction;
     }
      */
     public void addPreResultListener(PreResultListener listener) {
         if (preResultListeners == null) {
-            preResultListeners = new ArrayList(1);
+            preResultListeners = new ArrayList<PreResultListener>(1);
         }
 
         preResultListeners.add(listener);
             return ret;
         }
         ActionConfig config = proxy.getConfig();
-        Map results = config.getResults();
+        Map<String, ResultConfig> results = config.getResults();
 
         ResultConfig resultConfig = null;
 
         synchronized (config) {
             try {
-                resultConfig = (ResultConfig) results.get(resultCode);
+                resultConfig = results.get(resultCode);
             } catch (NullPointerException e) {
+                // swallow
             }
             if (resultConfig == null) {
                 // If no result is found for the given resultCode, try to get a wildcard '*' match.
-                resultConfig = (ResultConfig) results.get("*");
+                resultConfig = results.get("*");
             }
         }
 
         if (resultConfig != null) {
             try {
-                Result result = objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
-                return result;
+                return objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
             } catch (Exception e) {
                 LOG.error("There was an exception while instantiating the result of type " + resultConfig.getClassName(), e);
                 throw new XWorkException(e, resultConfig);
             // return above and flow through again
             if (!executed) {
                 if (preResultListeners != null) {
-                    for (Iterator iterator = preResultListeners.iterator();
-                         iterator.hasNext();) {
-                        PreResultListener listener = (PreResultListener) iterator.next();
+                    for (Object preResultListener : preResultListeners) {
+                        PreResultListener listener = (PreResultListener) preResultListener;
 
                         String _profileKey = "preResultListener: ";
                         try {
         return invokeAction(getAction(), proxy.getConfig());
     }
 
-    protected void createAction(Map contextMap) {
+    protected void createAction(Map<String, Object> contextMap) {
         // load action
         String timerKey = "actionCreate: " + proxy.getActionName();
         try {
         }
     }
 
-    protected Map createContextMap() {
-        Map contextMap;
+    protected Map<String, Object> createContextMap() {
+        Map<String, Object> contextMap;
 
         if ((extraContext != null) && (extraContext.containsKey(ActionContext.VALUE_STACK))) {
             // In case the ValueStack was passed in
 
     public void init(ActionProxy proxy) {
         this.proxy = proxy;
-        Map contextMap = createContextMap();
+        Map<String, Object> contextMap = createContextMap();
 
         // Setting this so that other classes, like object factories, can use the ActionProxy and other
         // contextual information to operate
         invocationContext.setName(proxy.getActionName());
 
         // get a new List so we don't get problems with the iterator if someone changes the list
-        List interceptorList = new ArrayList(proxy.getConfig().getInterceptors());
+        List<InterceptorMapping> interceptorList = new ArrayList<InterceptorMapping>(proxy.getConfig().getInterceptors());
         interceptors = interceptorList.iterator();
     }
 

File src/java/com/opensymphony/xwork2/DefaultActionProxy.java

  */
 package com.opensymphony.xwork2;
 
-import java.io.Serializable;
-import java.util.Locale;
-import java.util.Map;
-
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
 
+import java.io.Serializable;
+import java.util.Locale;
+
 
 /**
  * The Default ActionProxy implementation

File src/java/com/opensymphony/xwork2/DefaultActionProxyFactory.java

  */
 package com.opensymphony.xwork2;
 
-import java.util.Map;
-
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
 
+import java.util.Map;
+
 
 /**
  * Default factory for {@link com.opensymphony.xwork2.ActionProxyFactory}.
         this.container = container;
     }
     
-    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext) {
+    public ActionProxy createActionProxy(String namespace, String actionName, Map<String, Object> extraContext) {
         return createActionProxy(namespace, actionName, null, extraContext, true, true);
     }
 
-    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map extraContext) {
+    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext) {
         return createActionProxy(namespace, actionName, methodName, extraContext, true, true);
     }
 
-    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) {
+    public ActionProxy createActionProxy(String namespace, String actionName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) {
         return createActionProxy(namespace, actionName, null, extraContext, executeResult, cleanupContext);
     }
 
-    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map extraContext, boolean executeResult, boolean cleanupContext) {
+    public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) {
         
         ActionInvocation inv = new DefaultActionInvocation(extraContext, true);
         container.inject(inv);

File src/java/com/opensymphony/xwork2/DefaultTextProvider.java

 import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 
-import java.io.ObjectStreamException;
 import java.io.Serializable;
-import java.util.List;
-import java.util.ResourceBundle;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.text.MessageFormat;
+import java.util.List;
+import java.util.ResourceBundle;
 
 /**
  * DefaultTextProvider gets texts from only the default resource bundles associated with the
         return text;
     }
 
-    public String getText(String key, List args) {
+    public String getText(String key, List<Object> args) {
         Object[] params;
         if (args != null) {
             params = args.toArray();
         return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale(), params);
     }
 
-    public String getText(String key, String defaultValue, List args) {
+    public String getText(String key, String defaultValue, List<Object> args) {
         String text = getText(key, args);
         if (text == null) {
             MessageFormat format = new MessageFormat(defaultValue);
 
 
     public String getText(String key, String defaultValue, String obj) {
-        List args = new ArrayList(1);
+        List<Object> args = new ArrayList<Object>(1);
         args.add(obj);
         return getText(key, defaultValue, args);
     }
 
-    public String getText(String key, String defaultValue, List args, ValueStack stack) {
+    public String getText(String key, String defaultValue, List<Object> args, ValueStack stack) {
         //we're not using the value stack here
         return getText(key, defaultValue, args);
     }
 
     public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
         //we're not using the value stack here
-        return getText(key, defaultValue, Arrays.asList(args));
+        List<Object> values = new ArrayList<Object>(Arrays.asList(args));
+        return getText(key, defaultValue, values);
     }
 
     public ResourceBundle getTexts(String bundleName) {

File src/java/com/opensymphony/xwork2/MockActionInvocation.java

  * @author plightbo
  * @deprecated Please use @see com.opensymphony.xwork2.mock.MockActionInvocation instead
  */
-public class MockActionInvocation extends com.opensymphony.xwork2.mock.MockActionInvocation {
+@Deprecated public class MockActionInvocation extends com.opensymphony.xwork2.mock.MockActionInvocation {
 }

File src/java/com/opensymphony/xwork2/ObjectFactory.java

  */
 package com.opensymphony.xwork2;
 
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorConfig;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
-import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
-import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
 import com.opensymphony.xwork2.util.reflection.ReflectionException;
+import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
+import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
 import com.opensymphony.xwork2.validator.Validator;
 
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
 
 /**
  * ObjectFactory is responsible for building the core framework objects. Users may register their 
     /**
      * @deprecated Since 2.1
      */
-    public static ObjectFactory getObjectFactory() {
+    @Deprecated public static ObjectFactory getObjectFactory() {
         return ActionContext.getContext().getContainer().getInstance(ObjectFactory.class);
     }
 
      * @return instance of the action class to handle a web request
      * @throws Exception
      */
-    public Object buildAction(String actionName, String namespace, ActionConfig config, Map extraContext) throws Exception {
+    public Object buildAction(String actionName, String namespace, ActionConfig config, Map<String, Object> extraContext) throws Exception {
         return buildBean(config.getClassName(), extraContext);
     }
 
      * @param clazz the type of Object to build
      * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
      */
-    public Object buildBean(Class clazz, Map extraContext) throws Exception {
+    public Object buildBean(Class clazz, Map<String, Object> extraContext) throws Exception {
         return clazz.newInstance();
     }
 
      * @param className the type of Object to build
      * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
      */
-    public Object buildBean(String className, Map extraContext) throws Exception {
+    public Object buildBean(String className, Map<String, Object> extraContext) throws Exception {
         return buildBean(className, extraContext, true);
     }
     
      * @param className the type of Object to build
      * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
      */
-    public Object buildBean(String className, Map extraContext, boolean injectInternal) throws Exception {
+    public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception {
         Class clazz = getClassInstance(className);
         Object obj = buildBean(clazz, extraContext);
         if (injectInternal) {
      * @param interceptorRefParams a Map of params provided in the Interceptor reference in the
      *                             Action mapping or InterceptorStack definition
      */
-    public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams) throws ConfigurationException {
+    public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map<String, String> interceptorRefParams) throws ConfigurationException {
         String interceptorClassName = interceptorConfig.getClassName();
-        Map thisInterceptorClassParams = interceptorConfig.getParams();
-        Map params = (thisInterceptorClassParams == null) ? new HashMap() : new HashMap(thisInterceptorClassParams);
+        Map<String, String> thisInterceptorClassParams = interceptorConfig.getParams();
+        Map<String, String> params = (thisInterceptorClassParams == null) ? new HashMap<String, String>() : new HashMap<String, String>(thisInterceptorClassParams);
         params.putAll(interceptorRefParams);
 
         String message;
      * @param resultConfig the ResultConfig found for the action with the result code returned
      * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
      */
-    public Result buildResult(ResultConfig resultConfig, Map extraContext) throws Exception {
+    public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception {
         String resultClassName = resultConfig.getClassName();
         Result result = null;
 
      * @param params    property name -> value Map to set onto the Validator instance
      * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
      */
-    public Validator buildValidator(String className, Map params, Map extraContext) throws Exception {
+    public Validator buildValidator(String className, Map<String, String> params, Map<String, Object> extraContext) throws Exception {
         Validator validator = (Validator) buildBean(className, null);
         reflectionProvider.setProperties(params, validator);
 

File src/java/com/opensymphony/xwork2/TestNGXWorkTestCase.java

  */
 package com.opensymphony.xwork2;
 
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.impl.MockConfiguration;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
 
 /**
  * Base test class for TestNG unit tests.  Provides common XWork variables

File src/java/com/opensymphony/xwork2/TextProvider.java

 /**
  * Provides access to {@link ResourceBundle}s and their underlying text messages.
  * Implementing classes can delegate {@link TextProviderSupport}. Messages will be
- * searched in multiple resource bundles, starting with the one associated with
+ * searched in multiple resource bundles, startinag with the one associated with
  * this particular class (action in most cases), continuing to try the message
  * bundle associated with each superclass as well. It will stop once a bundle is
  * found that contains the given text. This gives a cascading style that allow
      * @param args a list args to be used in a {@link java.text.MessageFormat} message
      * @return the message as found in the resource bundle, or null if none is found.
      */
-    String getText(String key, List args);
+    String getText(String key, List<Object> args);
 
     /**
      * Gets a message based on a key using the supplied args, as defined in
      * @param args         a list args to be used in a {@link java.text.MessageFormat} message
      * @return the message as found in the resource bundle, or defaultValue if none is found
      */
-    String getText(String key, String defaultValue, List args);
+    String getText(String key, String defaultValue, List<Object> args);
 
     /**
      * Gets a message based on a key using the supplied args, as defined in
      * @param stack        the value stack to use for finding the text
      * @return the message as found in the resource bundle, or defaultValue if none is found
      */
-    String getText(String key, String defaultValue, List args, ValueStack stack);
+    String getText(String key, String defaultValue, List<Object> args, ValueStack stack);
 
     /**
      * Gets a message based on a key using the supplied args, as defined in

File src/java/com/opensymphony/xwork2/TextProviderSupport.java

      * class.
      */
     public boolean hasKey(String key) {
-    	String message = null;
+    	String message;
     	if (clazz != null) {
             message =  LocalizedTextUtil.findText(clazz, key, getLocale(), null, new Object[0] );
         } else {
      * @return value of named text
      */
     public String getText(String key) {
-        return getText(key, key, Collections.EMPTY_LIST);
+        return getText(key, key, Collections.emptyList());
     }
 
     /**
      * @return value of named text
      */
     public String getText(String key, String defaultValue) {
-        return getText(key, defaultValue, Collections.EMPTY_LIST);
+        return getText(key, defaultValue, Collections.emptyList());
     }
 
     /**
      * @return value of named text
      */
     public String getText(String key, String defaultValue, String arg) {
-        List args = new ArrayList();
+        List<Object> args = new ArrayList<Object>();
         args.add(arg);
         return getText(key, defaultValue, args);
     }
      * @param args      a List of args to be used in a MessageFormat message
      * @return value of named text
      */
-    public String getText(String key, List args) {
+    public String getText(String key, List<Object> args) {
         return getText(key, key, args);
     }
 
      * @param args         a List of args to be used in a MessageFormat message
      * @return value of named text
      */
-    public String getText(String key, String defaultValue, List args) {
-        Object[] argsArray = ((args != null && !args.equals(Collections.EMPTY_LIST)) ? args.toArray() : null);
+    public String getText(String key, String defaultValue, List<Object> args) {
+        Object[] argsArray = ((args != null && !args.equals(Collections.emptyList())) ? args.toArray() : null);
         if (clazz != null) {
             return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, argsArray);
         } else {
      * @param stack        the value stack to use for finding the text
      * @return the message as found in the resource bundle, or defaultValue if none is found
      */
-    public String getText(String key, String defaultValue, List args, ValueStack stack) {
+    public String getText(String key, String defaultValue, List<Object> args, ValueStack stack) {
         Object[] argsArray = ((args != null) ? args.toArray() : null);
-        Locale locale = null;
+        Locale locale;
         if (stack == null){
         	locale = getLocale();
         }else{
      * @return the message as found in the resource bundle, or defaultValue if none is found
      */
     public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
-        Locale locale = null;
+        Locale locale;
         if (stack == null){
         	locale = getLocale();
         }else{

File src/java/com/opensymphony/xwork2/ValidationAware.java

 package com.opensymphony.xwork2;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 
 /**
      *
      * @param errorMessages Collection of String error messages
      */
-    void setActionErrors(Collection errorMessages);
+    void setActionErrors(Collection<String> errorMessages);
 
     /**
      * Get the Collection of Action-level error messages for this action. Error messages should not
      *
      * @return Collection of String error messages
      */
-    Collection getActionErrors();
+    Collection<String> getActionErrors();
 
     /**
      * Set the Collection of Action-level String messages (not errors).
      *
      * @param messages Collection of String messages (not errors).
      */
-    void setActionMessages(Collection messages);
+    void setActionMessages(Collection<String> messages);
 
     /**
      * Get the Collection of Action-level messages for this action. Messages should not be added
      *
      * @return Collection of String messages
      */
-    Collection getActionMessages();
+    Collection<String> getActionMessages();
 
     /**
      * Set the field error map of fieldname (String) to Collection of String error messages.
      *
      * @param errorMap field error map
      */
-    void setFieldErrors(Map errorMap);
+    void setFieldErrors(Map<String, List<String>> errorMap);
 
     /**
      * Get the field specific errors associated with this action. Error messages should not be added
      *
      * @return Map with errors mapped from fieldname (String) to Collection of String error messages
      */
-    Map getFieldErrors();
+    Map<String, List<String>> getFieldErrors();
 
     /**
      * Add an Action-level error message to this Action.

File src/java/com/opensymphony/xwork2/ValidationAwareSupport.java

  */
 public class ValidationAwareSupport implements ValidationAware, Serializable {
 
-    private Collection actionErrors;
-    private Collection actionMessages;
-    private Map fieldErrors;
+    private Collection<String> actionErrors;
+    private Collection<String> actionMessages;
+    private Map<String, List<String>> fieldErrors;
 
 
-    public synchronized void setActionErrors(Collection errorMessages) {
+    public synchronized void setActionErrors(Collection<String> errorMessages) {
         this.actionErrors = errorMessages;
     }
 
-    public synchronized Collection getActionErrors() {
-        return new ArrayList(internalGetActionErrors());
+    public synchronized Collection<String> getActionErrors() {
+        return new ArrayList<String>(internalGetActionErrors());
     }
 
-    public synchronized void setActionMessages(Collection messages) {
+    public synchronized void setActionMessages(Collection<String> messages) {
         this.actionMessages = messages;
     }
 
-    public synchronized Collection getActionMessages() {
-        return new ArrayList(internalGetActionMessages());
+    public synchronized Collection<String> getActionMessages() {
+        return new ArrayList<String>(internalGetActionMessages());
     }
 
-    public synchronized void setFieldErrors(Map errorMap) {
+    public synchronized void setFieldErrors(Map<String, List<String>> errorMap) {
         this.fieldErrors = errorMap;
     }
 
-    public synchronized Map getFieldErrors() {
-        return new LinkedHashMap(internalGetFieldErrors());
+    public synchronized Map<String, List<String>> getFieldErrors() {
+        return new LinkedHashMap<String, List<String>>(internalGetFieldErrors());
     }
 
     public synchronized void addActionError(String anErrorMessage) {
     }
 
     public synchronized void addFieldError(String fieldName, String errorMessage) {
-        final Map errors = internalGetFieldErrors();
-        List thisFieldErrors = (List) errors.get(fieldName);
+        final Map<String, List<String>> errors = internalGetFieldErrors();
+        List<String> thisFieldErrors = errors.get(fieldName);
 
         if (thisFieldErrors == null) {
-            thisFieldErrors = new ArrayList();
+            thisFieldErrors = new ArrayList<String>();
             errors.put(fieldName, thisFieldErrors);
         }
 
         return (fieldErrors != null) && !fieldErrors.isEmpty();
     }