Commits

Anonymous committed c363635

XW-161 : Adding an ObjectFactory which builds the framework objects such as Interceptors, Results, Actions, Validators, and general JavaBeans...

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/v1_0_1branch@190e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (28)

 name=xwork
-version=1.0
+version=1.0.1-dev

src/java/com/opensymphony/xwork/ActionProxyFactory.java

      * as part of creating an ActionProxy. Client code should not need to call the createActionInvocation methods.
      * @param actionProxy
      * @param extraContext
-     * @param pushAction tells whether the Action should be pushed onto the ValueStack 
+     * @param pushAction tells whether the Action should be pushed onto the ValueStack
      * @return
      * @throws Exception
      */

src/java/com/opensymphony/xwork/ActionSupport.java

 import org.apache.commons.logging.LogFactory;
 
 import java.io.Serializable;
+
 import java.util.*;
 
 
         return getActionErrors();
     }
 
+    /**
+     * @deprecated Use {@link #getFieldErrors()}.
+     */
+    public Map getErrors() {
+        return getFieldErrors();
+    }
+
     public void setFieldErrors(Map errorMap) {
         validationAware.setFieldErrors(errorMap);
     }
         return validationAware.getFieldErrors();
     }
 
-    /**
-     * @deprecated Use {@link #getFieldErrors()}.
-     */
-    public Map getErrors() {
-        return getFieldErrors();
-    }
-
     public Locale getLocale() {
         return (ActionContext.getContext() != null) ? ActionContext.getContext().getLocale() : null;
     }

src/java/com/opensymphony/xwork/DefaultActionInvocation.java

 import com.opensymphony.xwork.interceptor.PreResultListener;
 import com.opensymphony.xwork.util.OgnlUtil;
 import com.opensymphony.xwork.util.OgnlValueStack;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
         Result newResult = null;
 
         if (resultConfig != null) {
-            Class resultClass = resultConfig.getClazz();
-
-            if (resultClass != null) {
-                try {
-                    newResult = (Result) resultClass.newInstance();
-                } catch (Exception e) {
-                    LOG.error("There was an exception while instantiating the result of type " + resultClass, e);
-                    throw e;
-                }
-
-                OgnlUtil.setProperties(resultConfig.getParams(), newResult, ActionContext.getContext().getContextMap());
+            try {
+                newResult = ObjectFactory.getObjectFactory().buildResult(resultConfig);
+            } catch (Exception e) {
+                LOG.error("There was an exception while instantiating the result of type " + resultConfig.getClazz(), e);
+                throw e;
             }
         }
 
         if (!executed) {
             if (preResultListeners != null) {
                 for (Iterator iterator = preResultListeners.iterator();
-                     iterator.hasNext();) {
+                        iterator.hasNext();) {
                     PreResultListener listener = (PreResultListener) iterator.next();
                     listener.beforeResult(this, resultCode);
                 }
 
     protected void createAction() {
         // load action
-        Class actionClass = proxy.getConfig().getClazz();
-
         try {
-            action = (Action) actionClass.newInstance();
+            action = ObjectFactory.getObjectFactory().buildAction(proxy.getConfig());
         } catch (InstantiationException e) {
             throw new XworkException("Unable to intantiate Action!", e);
         } catch (IllegalAccessException e) {
             throw new XworkException("Illegal access to constructor, is it public?", e);
         } catch (ClassCastException e) {
-            throw new XworkException("Action class " + actionClass.getClass().getName() + "does not implement " + Action.class.getName(), e);
+            throw new XworkException("Action class " + proxy.getConfig().getClazz().getName() + " does not implement " + Action.class.getName(), e);
         } catch (Exception e) {
             String gripe = "";
 

src/java/com/opensymphony/xwork/ObjectFactory.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.config.ConfigurationException;
+import com.opensymphony.xwork.config.entities.ActionConfig;
+import com.opensymphony.xwork.config.entities.InterceptorConfig;
+import com.opensymphony.xwork.config.entities.ResultConfig;
+import com.opensymphony.xwork.config.providers.InterceptorBuilder;
+import com.opensymphony.xwork.interceptor.Interceptor;
+import com.opensymphony.xwork.util.OgnlUtil;
+import com.opensymphony.xwork.validator.Validator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * ObjectFactory is responsible for building the core framework objects. Users may register their own implementation of
+ * the ObjectFactory to control instantiation of these Objects.
+ *
+ * @author Jason Carreira
+ * Date: Feb 26, 2004 9:02:57 PM
+ */
+public class ObjectFactory {
+    //~ Static fields/initializers /////////////////////////////////////////////
+
+    private static ObjectFactory FACTORY = new ObjectFactory();
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    protected ObjectFactory() {
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public static void setObjectFactory(ObjectFactory factory) {
+        FACTORY = factory;
+    }
+
+    public static ObjectFactory getObjectFactory() {
+        return FACTORY;
+    }
+
+    /**
+     * Build an Action of the given type
+     * @param config
+     */
+    public Action buildAction(ActionConfig config) throws Exception {
+        return (Action) config.getClazz().newInstance();
+    }
+
+    /**
+     * Build a generic Java object of the given type.
+     * @param clazz the type of Object to build
+     */
+    public Object buildBean(Class clazz) throws Exception {
+        return clazz.newInstance();
+    }
+
+    /**
+     * Builds an Interceptor from the InterceptorConfig and the Map of parameters from the interceptor reference.
+     * Implementations of this method should ensure that the Interceptor is parameterized with both the parameters from
+     * the Interceptor config and the interceptor ref Map (the interceptor ref params take precedence), and that the
+     * Interceptor.init() method is called on the Interceptor instance before it is returned.
+     *
+     * @param interceptorConfig the InterceptorConfig from the configuration
+     * @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 {
+        Interceptor interceptor = null;
+        Class interceptorClass = interceptorConfig.getClazz();
+        String message;
+        Map thisInterceptorClassParams = interceptorConfig.getParams();
+        Map params = (thisInterceptorClassParams == null) ? new HashMap() : new HashMap(thisInterceptorClassParams);
+        params.putAll(interceptorRefParams);
+
+        try {
+            interceptor = (Interceptor) interceptorClass.newInstance();
+            OgnlUtil.setProperties(params, interceptor);
+            interceptor.init();
+
+            return interceptor;
+        } catch (InstantiationException e) {
+            message = "Unable to instantiate an instance of Interceptor class [" + interceptorClass.getName() + "].";
+        } catch (IllegalAccessException e) {
+            message = "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + interceptorClass.getName() + "].";
+        } catch (ClassCastException e) {
+            message = "Class [" + interceptorClass.getName() + "] does not implement com.opensymphony.xwork.interceptor.Interceptor";
+        } catch (Exception e) {
+            throw new ConfigurationException("Caught Exception while registering Interceptor class " + interceptorClass.getName(), e);
+        }
+
+        throw new ConfigurationException(message);
+    }
+
+    /**
+     * Build a Result using the type in the ResultConfig and set the parameters in the ResultConfig.
+     *
+     * @param resultConfig
+     */
+    public Result buildResult(ResultConfig resultConfig) throws Exception {
+        Class resultClass = resultConfig.getClazz();
+        Result result = null;
+
+        if (resultClass != null) {
+            result = (Result) resultClass.newInstance();
+            OgnlUtil.setProperties(resultConfig.getParams(), result, ActionContext.getContext().getContextMap());
+        }
+
+        return result;
+    }
+
+    /**
+     * Build a Validator of the given type and set the parameters on it
+     * @param clazz the type of Validator to build
+     * @param params property name -> value Map to set onto the Validator instance
+     */
+    public Validator buildValidator(Class clazz, Map params) throws Exception {
+        Validator validator = (Validator) clazz.newInstance();
+        OgnlUtil.setProperties(params, validator);
+
+        return validator;
+    }
+}

src/java/com/opensymphony/xwork/TextProviderSupport.java

 
 import com.opensymphony.xwork.util.LocalizedTextUtil;
 
+import java.io.Serializable;
+
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
-import java.io.Serializable;
 
 
 /**
      * @return     value of named text
      */
     public String getText(String aTextName, String defaultValue, List args) {
-        Object[] argsArray = (args != null ? args.toArray() : null);
+        Object[] argsArray = ((args != null) ? args.toArray() : null);
+
         if (clazz != null) {
-            return LocalizedTextUtil.findText(clazz, aTextName, getLocale(),
-                    defaultValue, argsArray);
+            return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), defaultValue, argsArray);
         } else {
-            return LocalizedTextUtil.findText(bundle, aTextName, getLocale(),
-                    defaultValue, argsArray);
+            return LocalizedTextUtil.findText(bundle, aTextName, getLocale(), defaultValue, argsArray);
         }
     }
 

src/java/com/opensymphony/xwork/ValidationAware.java

     //~ Methods ////////////////////////////////////////////////////////////////
 
     /**
-     * Set the Collection of Action level String error messages
-     * @param errorMessages
-     */
+ * Set the Collection of Action level String error messages
+ * @param errorMessages
+ */
     void setActionErrors(Collection errorMessages);
 
     /**
-    * Get the Collection of Action level error messages for this action. Error messages should not be added directly
-    * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
-    *
-    * @return Collection of String error messages
-    */
+* Get the Collection of Action level error messages for this action. Error messages should not be added directly
+* here, as implementations are free to return a new Collection or an Unmodifiable Collection.
+*
+* @return Collection of String error messages
+*/
     Collection getActionErrors();
 
     /**
-     *  Set the field error map of fieldname (String) to Collection of String error messages
-     * @param errorMap
-     */
+ *  Set the field error map of fieldname (String) to Collection of String error messages
+ * @param errorMap
+ */
     void setFieldErrors(Map errorMap);
 
     /**
-    * Get the field specific errors associated with this action. Error messages should not be added directly
-    * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
-    *
-    * @return Map with errors mapped from fieldname (String) to Collection of String error messages
-    */
+* Get the field specific errors associated with this action. Error messages should not be added directly
+* here, as implementations are free to return a new Collection or an Unmodifiable Collection.
+*
+* @return Map with errors mapped from fieldname (String) to Collection of String error messages
+*/
     Map getFieldErrors();
 
     /**
-    * Add an Action level error message to this Action
-    *
-    * @param   anErrorMessage
-    */
+* Add an Action level error message to this Action
+*
+* @param   anErrorMessage
+*/
     void addActionError(String anErrorMessage);
 
     /**
-    * Add an error message for a given field
-    *
-    * @param   fieldName  name of field
-    * @param   errorMessage  the error message
-    */
+* Add an error message for a given field
+*
+* @param   fieldName  name of field
+* @param   errorMessage  the error message
+*/
     void addFieldError(String fieldName, String errorMessage);
 
     /**
-    * Check whether there are any Action level error messages
-    *
-    * @return true if any Action level error messages have been registered
-    */
+* Check whether there are any Action level error messages
+*
+* @return true if any Action level error messages have been registered
+*/
     boolean hasActionErrors();
 
     /**
-     * @return (hasActionErrors() || hasFieldErrors())
-     */
+ * @return (hasActionErrors() || hasFieldErrors())
+ */
     boolean hasErrors();
 
     /**
-    * Check whether there are any field errors associated with this action.
-    *
-    * @return     whether there are any field errors
-    */
+* Check whether there are any field errors associated with this action.
+*
+* @return     whether there are any field errors
+*/
     boolean hasFieldErrors();
 }

src/java/com/opensymphony/xwork/config/entities/ActionConfig.java

 import com.opensymphony.xwork.interceptor.Interceptor;
 
 import java.io.Serializable;
+
 import java.lang.reflect.Method;
+
 import java.util.*;
 
 
         if (methodName != null) {
             method = clazz.getMethod(methodName, new Class[0]);
         } else // return default execute() method if method name is not specified
-        {
+         {
             method = clazz.getMethod("execute", new Class[0]);
         }
 

src/java/com/opensymphony/xwork/config/providers/InterceptorBuilder.java

  */
 package com.opensymphony.xwork.config.providers;
 
+import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.config.ConfigurationException;
 import com.opensymphony.xwork.config.entities.InterceptorConfig;
 import com.opensymphony.xwork.config.entities.InterceptorStackConfig;
 import com.opensymphony.xwork.config.entities.PackageConfig;
-import com.opensymphony.xwork.interceptor.Interceptor;
-import com.opensymphony.xwork.util.OgnlUtil;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
     /**
-    * Builds an Interceptor instance for the given class name and parameterizes it. The interceptor will have its init()
-    * method called before returning.
-    * @param interceptorClass the Interceptor class to create an instance of
-    * @param params the params to set on the interceptor instance
-    * @return an instance of the Interceptor class or null if there is a problem loading the Interceptor class
-    * @throws com.opensymphony.xwork.config.ConfigurationException
-    */
-    public static Interceptor buildInterceptor(Class interceptorClass, Map params) throws ConfigurationException {
-        String message;
-
-        try {
-            Interceptor interceptor = (Interceptor) interceptorClass.newInstance();
-            OgnlUtil.setProperties(params, interceptor);
-            interceptor.init();
-
-            return interceptor;
-        } catch (InstantiationException e) {
-            message = "Unable to instantiate an instance of Interceptor class [" + interceptorClass.getName() + "].";
-        } catch (IllegalAccessException e) {
-            message = "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + interceptorClass.getName() + "].";
-        } catch (ClassCastException e) {
-            message = "Class [" + interceptorClass.getName() + "] does not implement com.opensymphony.xwork.interceptor.Interceptor";
-        } catch (Exception e) {
-            throw new ConfigurationException("Caught Exception while registering Interceptor class " + interceptorClass.getName(), e);
-        }
-
-        throw new ConfigurationException(message);
-    }
-
-    /**
-    * Builds a list of interceptors referenced by the refName in the supplied PackageConfig.
-    * @param packageConfig
-    * @param refName
-    * @param refParams
-    * @return
-    * @throws ConfigurationException
-    */
+     * Builds a list of interceptors referenced by the refName in the supplied PackageConfig.
+     *
+     * @param packageConfig
+     * @param refName
+     * @param refParams
+     * @return
+     * @throws ConfigurationException
+     */
     public static List constructInterceptorReference(PackageConfig packageConfig, String refName, Map refParams) throws ConfigurationException {
         Object referencedConfig = packageConfig.getAllInterceptorConfigs().get(refName);
         List result = new ArrayList();
             LOG.error("Unable to find interceptor class referenced by ref-name " + refName);
         } else {
             if (referencedConfig instanceof InterceptorConfig) {
-                InterceptorConfig interceptorConfig = (InterceptorConfig) referencedConfig;
-                Map thisInterceptorClassParams = interceptorConfig.getParams();
-                Map params = (thisInterceptorClassParams == null) ? new HashMap() : new HashMap(thisInterceptorClassParams);
-                params.putAll(refParams);
-                result.add(buildInterceptor(interceptorConfig.getClazz(), params));
+                result.add(ObjectFactory.getObjectFactory().buildInterceptor((InterceptorConfig) referencedConfig, refParams));
             } else if (referencedConfig instanceof InterceptorStackConfig) {
                 InterceptorStackConfig stackConfig = (InterceptorStackConfig) referencedConfig;
 

src/java/com/opensymphony/xwork/config/providers/XmlConfigurationProvider.java

 
         List interceptorList = buildInterceptorList(actionElement, packageContext);
 
-		List externalrefs = buildExternalRefs(actionElement, packageContext);
+        List externalrefs = buildExternalRefs(actionElement, packageContext);
 
         ActionConfig actionConfig = new ActionConfig(methodName, clazz, actionParams, results, interceptorList, externalrefs, packageContext.getName());
         packageContext.addActionConfig(name, actionConfig);
 
-        if (LOG.isDebugEnabled())
-            LOG.debug("Loaded " + (TextUtils.stringSet(packageContext.getNamespace()) ? packageContext.getNamespace() + "/" : "")
-                    + name + " in '" + packageContext.getName() + "' package:" + actionConfig);
-
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Loaded " + (TextUtils.stringSet(packageContext.getNamespace()) ? (packageContext.getNamespace() + "/") : "") + name + " in '" + packageContext.getName() + "' package:" + actionConfig);
+        }
     }
 
     /**
     protected void addPackage(Element packageElement) throws ConfigurationException {
         PackageConfig newPackage = buildPackageContext(packageElement);
 
-        if (LOG.isDebugEnabled())
+        if (LOG.isDebugEnabled()) {
             LOG.debug("Loaded " + newPackage);
+        }
 
         // add result types (and default result) to this package
         addResultTypes(newPackage, packageElement);
         }
     }
 
+    protected List buildExternalRefs(Element element, PackageConfig context) throws ConfigurationException {
+        List refs = new ArrayList();
+        NodeList externalRefList = element.getElementsByTagName("external-ref");
+
+        String refName = null;
+        String refValue = null;
+        String requiredTemp = null;
+        boolean required;
+
+        for (int i = 0; i < externalRefList.getLength(); i++) {
+            Element refElement = (Element) externalRefList.item(i);
+
+            if (refElement.getParentNode().equals(element)) {
+                refName = refElement.getAttribute("name");
+
+                //If the external ref is not declared explicitly, we can introspect the
+                //reference type using it's name and try resolving the reference using it's class type
+                if (refElement.getChildNodes().getLength() > 0) {
+                    refValue = refElement.getChildNodes().item(0).getNodeValue();
+                }
+
+                requiredTemp = refElement.getAttribute("required");
+
+                if ((requiredTemp == null) || "".equals(requiredTemp)) {
+                    required = true;
+                } else {
+                    required = Boolean.valueOf(requiredTemp).booleanValue();
+                }
+
+                refs.add(new ExternalReference(refName, refValue, required));
+            }
+        }
+
+        return refs;
+    }
+
     protected List buildInterceptorList(Element element, PackageConfig context) throws ConfigurationException {
         List interceptorList = new ArrayList();
         NodeList interceptorRefList = element.getElementsByTagName("interceptor-ref");
         return interceptorList;
     }
 
-	protected List buildExternalRefs(Element element, PackageConfig context) throws ConfigurationException {
-		List refs = new ArrayList();
-		NodeList externalRefList = element.getElementsByTagName("external-ref");
-
-		String refName = null;
-		String refValue = null;
-		String requiredTemp = null;
-		boolean required;
-		for (int i = 0; i < externalRefList.getLength(); i++) {
-			Element refElement = (Element) externalRefList.item(i);
-
-			if (refElement.getParentNode().equals(element)) {
-				refName = refElement.getAttribute("name");
-
-				//If the external ref is not declared explicitly, we can introspect the
-				//reference type using it's name and try resolving the reference using it's class type
-				if(refElement.getChildNodes().getLength() > 0)
-				{
-				    refValue = refElement.getChildNodes().item(0).getNodeValue();
-				}
-				requiredTemp = refElement.getAttribute("required");
-				if(requiredTemp == null || "".equals(requiredTemp)) {
-					required = true;
-				} else {
-					required = Boolean.valueOf(requiredTemp).booleanValue();
-				}
-				refs.add(new ExternalReference(refName, refValue, required));
-			}
-		}
-
-		return refs;
-	}
-
     /**
     * This method builds a package context by looking for the parents of this new package.
     *
         String namespace = TextUtils.noNull(packageElement.getAttribute("namespace"));
 
         //RM* Load the ExternalReferenceResolver if one has been set
-		ExternalReferenceResolver erResolver = null;
+        ExternalReferenceResolver erResolver = null;
 
         String externalReferenceResolver = TextUtils.noNull(packageElement.getAttribute("externalReferenceResolver"));
 
-		if(!("".equals(externalReferenceResolver)))
-		{
-	        try {
-				Class erResolverClazz = ClassLoaderUtil.loadClass(externalReferenceResolver, ExternalReferenceResolver.class);
-
-			    erResolver = (ExternalReferenceResolver) erResolverClazz.newInstance();
-
-	        } catch (ClassNotFoundException e) {
-	        	//TODO this should be localized
-	        	String msg = "Could not find External Reference Resolver: " + externalReferenceResolver + ". " + e.getMessage();
-				LOG.error(msg);
-				throw new ConfigurationException(msg, e);
-			} catch (Exception e)
-			{
-				//TODO this should be localized
-				String msg = "Could not create External Reference Resolver: " + externalReferenceResolver + ". " + e.getMessage();
-				LOG.error(msg);
-				throw new ConfigurationException(msg, e);
-			}
-		}
-
-		if (!TextUtils.stringSet(TextUtils.noNull(parent))) { // no parents
+        if (!("".equals(externalReferenceResolver))) {
+            try {
+                Class erResolverClazz = ClassLoaderUtil.loadClass(externalReferenceResolver, ExternalReferenceResolver.class);
+
+                erResolver = (ExternalReferenceResolver) erResolverClazz.newInstance();
+            } catch (ClassNotFoundException e) {
+                //TODO this should be localized
+                String msg = "Could not find External Reference Resolver: " + externalReferenceResolver + ". " + e.getMessage();
+                LOG.error(msg);
+                throw new ConfigurationException(msg, e);
+            } catch (Exception e) {
+                //TODO this should be localized
+                String msg = "Could not create External Reference Resolver: " + externalReferenceResolver + ". " + e.getMessage();
+                LOG.error(msg);
+                throw new ConfigurationException(msg, e);
+            }
+        }
+
+        if (!TextUtils.stringSet(TextUtils.noNull(parent))) { // no parents
 
             return new PackageConfig(name, namespace, isAbstract, erResolver);
         } else { // has parents, let's look it up
     //    }
     private void loadConfigurationFile(String fileName, DocumentBuilder db) {
         if (!includedFileNames.contains(fileName)) {
-            if (LOG.isDebugEnabled())
+            if (LOG.isDebugEnabled()) {
                 LOG.debug("Loading xwork configuration from: " + fileName);
+            }
+
             includedFileNames.add(fileName);
 
             Document doc = null;
                 }
             }
 
-            if (LOG.isDebugEnabled())
+            if (LOG.isDebugEnabled()) {
                 LOG.debug("Loaded xwork configuration from: " + fileName);
+            }
         }
     }
 

src/java/com/opensymphony/xwork/interceptor/AbstractLifecycleInterceptor.java

     //~ Methods ////////////////////////////////////////////////////////////////
 
     /**
-     * This callback method will be called after the Action execution and before the Result execution.
-     * @param invocation
-     * @param resultCode
-     */
+ * This callback method will be called after the Action execution and before the Result execution.
+ * @param invocation
+ * @param resultCode
+ */
     public void beforeResult(ActionInvocation invocation, String resultCode) {
     }
 
     /**
-     * Called to let an interceptor clean up any resources it has allocated.
-     */
+ * Called to let an interceptor clean up any resources it has allocated.
+ */
     public void destroy() {
     }
 
     /**
-     * Called after an Interceptor is created, but before any requests are processed using the intercept() methodName. This
-     * gives the Interceptor a chance to initialize any needed resources.
-     */
+ * Called after an Interceptor is created, but before any requests are processed using the intercept() methodName. This
+ * gives the Interceptor a chance to initialize any needed resources.
+ */
     public void init() {
     }
 
     /**
-     * Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the
-     * request by the DefaultActionInvocation or to short-circuit the processing and just return a String return code.
-     *
-     * @param invocation
-     * @return
-     * @throws Exception
-     */
+ * Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the
+ * request by the DefaultActionInvocation or to short-circuit the processing and just return a String return code.
+ *
+ * @param invocation
+ * @return
+ * @throws Exception
+ */
     public String intercept(ActionInvocation invocation) throws Exception {
         invocation.addPreResultListener(this);
 
     }
 
     /**
-     * Called after the Action and Result have been executed.
-     * @throws Exception
-     */
+ * Called after the Action and Result have been executed.
+ * @throws Exception
+ */
     protected void after() throws Exception {
     }
 
     /**
-     * Called before the rest of the ActionInvocation is forwarded to.
-     * @throws Exception
-     */
+ * Called before the rest of the ActionInvocation is forwarded to.
+ * @throws Exception
+ */
     protected void before() throws Exception {
     }
 
     /**
-     * Called if an Exception is caught while executing the before(), the rest of the ActionInvocation, including the
-     * Action and Result execution, or the after() call. The default implementation just rethrows the Exception. Subclasses
-     * can choose to either throw an Exception or do some processing.
-     * @param e the Exception caught
-     * @throws Exception
-     */
+ * Called if an Exception is caught while executing the before(), the rest of the ActionInvocation, including the
+ * Action and Result execution, or the after() call. The default implementation just rethrows the Exception. Subclasses
+ * can choose to either throw an Exception or do some processing.
+ * @param e the Exception caught
+ * @throws Exception
+ */
     protected void handleException(Exception e) throws Exception {
         throw e;
     }

src/java/com/opensymphony/xwork/interceptor/component/DefaultComponentManager.java

  */
 package com.opensymphony.xwork.interceptor.component;
 
+import com.opensymphony.xwork.ObjectFactory;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
                     Object newResource = newDcm.resourceInstances.get(depResource);
 
                     if (newResource == null) {
-                        newResource = depResource.newInstance();
+                        newResource = ObjectFactory.getObjectFactory().buildBean(depResource);
                     }
 
                     Class enabler = loadResource(newResource, newDcm);

src/java/com/opensymphony/xwork/util/CompoundRootAccessor.java

         Boolean reportError = (Boolean) context.get(OgnlValueStack.REPORT_ERRORS_ON_NO_PROP);
 
         final String msg = "No object in the CompoundRoot has a property named '" + name + "'.";
+
         if ((reportError != null) && (reportError.booleanValue())) {
             log.error(msg);
             throw new RuntimeException(msg);

src/java/com/opensymphony/xwork/util/InstantiatingNullHandler.java

  */
 package com.opensymphony.xwork.util;
 
+import com.opensymphony.util.FileManager;
+
+import com.opensymphony.xwork.ObjectFactory;
+
 import ognl.*;
 
-import java.lang.reflect.Method;
-import java.util.*;
 import java.io.InputStream;
 
-import com.opensymphony.util.FileManager;
+import java.lang.reflect.Method;
+
+import java.util.*;
 
 
 /**
  * @version $Revision$
  */
 public class InstantiatingNullHandler implements NullHandler {
-    //~ Instance fields ////////////////////////////////////////////////////////
+    //~ Static fields/initializers /////////////////////////////////////////////
 
-    private Map clazzMap = new HashMap();
     public static final String CREATE_NULL_OBJECTS = "xwork.NullHandler.createNullObjects";
 
+    //~ Instance fields ////////////////////////////////////////////////////////
+
     HashMap mappings = new HashMap();
     HashSet noMapping = new HashSet();
+    private Map clazzMap = new HashMap();
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
      */
     public Object nullPropertyValue(Map context, Object target, Object property) {
         Boolean create = (Boolean) context.get(CREATE_NULL_OBJECTS);
-        boolean c = (create == null ? false : create.booleanValue());
+        boolean c = ((create == null) ? false : create.booleanValue());
+
         if (!c) {
             return null;
         }
         }
 
         Method method = null;
+
         if (target instanceof CompoundRoot) {
             // sometimes the null object may be at the root, so we need to check all of them
             CompoundRoot root = (CompoundRoot) target;
+
             for (Iterator iterator = root.iterator(); iterator.hasNext();) {
                 Object o = iterator.next();
                 Map methodMap = getMethodMap(o);
 
                 if (method != null) {
                     target = o;
+
                     break;
                 }
             }
         try {
             Class clazz = method.getParameterTypes()[0];
             Object param = createObject(context, clazz, target, property.toString());
-            method.invoke(target, new Object[]{param});
+            method.invoke(target, new Object[] {param});
 
             return param;
         } catch (Exception e) {
         return null;
     }
 
-    private Object createObject(Map context, Class clazz, Object target, String property) throws InstantiationException, IllegalAccessException {
-        if (clazz == Collection.class || clazz == List.class) {
-            Class collectionType = getCollectionType(target.getClass(), property);
-            if (collectionType == null) {
-                return null;
-            }
-            return new XWorkList(collectionType);
-        } else if (clazz == Map.class) {
-            Class collectionType = getCollectionType(target.getClass(), property);
-            if (collectionType == null) {
-                return null;
-            }            
-            return new XWorkMap(collectionType);
-        }
-
-        return clazz.newInstance();
-    }
-
-
-    private Map buildConverterMapping(Class clazz) throws Exception {
-        Map mapping = new HashMap();
-
-        String resource = XWorkConverter.buildConverterFilename(clazz);
-        InputStream is = FileManager.loadFile(resource, clazz);
-
-        if (is != null) {
-            Properties props = new Properties();
-            props.load(is);
-            mapping.putAll(props);
-
-            for (Iterator iterator = mapping.entrySet().iterator();
-                    iterator.hasNext();) {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String propName = (String) entry.getKey();
-                String className = (String) entry.getValue();
-                if (propName.startsWith("Collection_")) {
-                    entry.setValue(Class.forName(className));
-                }
-            }
-
-            mappings.put(clazz, mapping);
-        } else {
-            noMapping.add(clazz);
-        }
-
-        return mapping;
-    }
-
     private Class getCollectionType(Class clazz, String property) {
         Class propClass = null;
+
         if (!noMapping.contains(clazz)) {
             try {
                 Map mapping = (Map) mappings.get(clazz);
         return propClass;
     }
 
-    private Map conditionalReload(Class clazz, Map oldValues) throws Exception {
-        Map mapping = oldValues;
-
-        if (FileManager.isReloadingConfigs()) {
-            if (FileManager.fileNeedsReloading(XWorkConverter.buildConverterFilename(clazz))) {
-                mapping = buildConverterMapping(clazz);
-            }
-        }
-
-        return mapping;
-    }
-
-
     /**
      * Attempt to find the setter associated with the provided instance and propertyName.  If we do find it, place that
      * Method into the methodMap keyed by property name
             return methodMap;
         }
     }
+
+    private Map buildConverterMapping(Class clazz) throws Exception {
+        Map mapping = new HashMap();
+
+        String resource = XWorkConverter.buildConverterFilename(clazz);
+        InputStream is = FileManager.loadFile(resource, clazz);
+
+        if (is != null) {
+            Properties props = new Properties();
+            props.load(is);
+            mapping.putAll(props);
+
+            for (Iterator iterator = mapping.entrySet().iterator();
+                    iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                String propName = (String) entry.getKey();
+                String className = (String) entry.getValue();
+
+                if (propName.startsWith("Collection_")) {
+                    entry.setValue(Class.forName(className));
+                }
+            }
+
+            mappings.put(clazz, mapping);
+        } else {
+            noMapping.add(clazz);
+        }
+
+        return mapping;
+    }
+
+    private Map conditionalReload(Class clazz, Map oldValues) throws Exception {
+        Map mapping = oldValues;
+
+        if (FileManager.isReloadingConfigs()) {
+            if (FileManager.fileNeedsReloading(XWorkConverter.buildConverterFilename(clazz))) {
+                mapping = buildConverterMapping(clazz);
+            }
+        }
+
+        return mapping;
+    }
+
+    private Object createObject(Map context, Class clazz, Object target, String property) throws Exception {
+        if ((clazz == Collection.class) || (clazz == List.class)) {
+            Class collectionType = getCollectionType(target.getClass(), property);
+
+            if (collectionType == null) {
+                return null;
+            }
+
+            return new XWorkList(collectionType);
+        } else if (clazz == Map.class) {
+            Class collectionType = getCollectionType(target.getClass(), property);
+
+            if (collectionType == null) {
+                return null;
+            }
+
+            return new XWorkMap(collectionType);
+        }
+
+        return ObjectFactory.getObjectFactory().buildBean(clazz);
+    }
 }

src/java/com/opensymphony/xwork/util/LocalizedTextUtil.java

 package com.opensymphony.xwork.util;
 
 import com.opensymphony.xwork.ActionContext;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.text.MessageFormat;
+
 import java.util.*;
 
 

src/java/com/opensymphony/xwork/util/XWorkConverter.java

 import com.opensymphony.util.FileManager;
 
 import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ObjectFactory;
 
 import ognl.*;
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
     HashMap defaultMappings = new HashMap();
-    HashSet unknownMappings = new HashSet();
     HashMap mappings = new HashMap();
     HashSet noMapping = new HashSet();
+    HashSet unknownMappings = new HashSet();
     TypeConverter defaultTypeConverter = new XWorkBasicConverter();
 
     //~ Constructors ///////////////////////////////////////////////////////////
         return instance;
     }
 
+    public static String buildConverterFilename(Class clazz) {
+        String className = clazz.getName();
+        String resource = className.replace('.', '/') + "-conversion.properties";
+
+        return resource;
+    }
+
     public static void resetInstance() {
         instance = null;
     }
             Class clazz = null;
 
             clazz = target.getClass();
+
             Object[] classProp = null;
 
             // this is to handle weird issues with setValue with a different type
         }
     }
 
-    private Object[] getClassProperty(Map context) {
-        Object[] classProp = null;
-        OgnlContext ognlContext = (OgnlContext) context;
-        Evaluation eval = ognlContext.getCurrentEvaluation();
-
-        if (eval == null) {
-            eval = ognlContext.getLastEvaluation();
-        }
-
-        if ((eval != null) && (eval.getLastChild() != null)) {
-            classProp = new Object[2];
-
-            // since we changed what the source was (tricked Ognl essentially)
-            if ((eval.getLastChild().getLastChild() != null) && (eval.getLastChild().getLastChild().getSource() != null) && (eval.getLastChild().getLastChild().getSource().getClass() != CompoundRoot.class)) {
-                classProp[0] = eval.getLastChild().getLastChild().getSource().getClass();
-            } else {
-                classProp[0] = eval.getLastChild().getSource().getClass();
-            }
-
-            // ugly hack getting the property, but it works
-            String property = eval.getNode().jjtGetChild(eval.getNode().jjtGetNumChildren() - 1).toString();
-
-            if (property.startsWith("\"") && property.endsWith("\"")) {
-                property = property.substring(1, property.length() - 1);
-            }
-
-            classProp[1] = property;
-        }
-
-        return classProp;
-    }
-
     public TypeConverter lookup(String className) {
         if (unknownMappings.contains(className)) {
             return null;
         return lookup(clazz.getName());
     }
 
-    protected synchronized void registerConverter(String className, TypeConverter converter) {
-        defaultMappings.put(className, converter);
-    }
-
-    protected synchronized void registerConverterNotFound(String className) {
-        unknownMappings.add(className);
-    }
-
     protected void handleConversionException(Map context, String property, Object value, Object object) {
         if ((context.get(REPORT_CONVERSION_ERRORS) == Boolean.TRUE)) {
             String realProperty = property;
         }
     }
 
+    protected synchronized void registerConverter(String className, TypeConverter converter) {
+        defaultMappings.put(className, converter);
+    }
+
+    protected synchronized void registerConverterNotFound(String className) {
+        unknownMappings.add(className);
+    }
+
+    private Object[] getClassProperty(Map context) {
+        Object[] classProp = null;
+        OgnlContext ognlContext = (OgnlContext) context;
+        Evaluation eval = ognlContext.getCurrentEvaluation();
+
+        if (eval == null) {
+            eval = ognlContext.getLastEvaluation();
+        }
+
+        if ((eval != null) && (eval.getLastChild() != null)) {
+            classProp = new Object[2];
+
+            // since we changed what the source was (tricked Ognl essentially)
+            if ((eval.getLastChild().getLastChild() != null) && (eval.getLastChild().getLastChild().getSource() != null) && (eval.getLastChild().getLastChild().getSource().getClass() != CompoundRoot.class)) {
+                classProp[0] = eval.getLastChild().getLastChild().getSource().getClass();
+            } else {
+                classProp[0] = eval.getLastChild().getSource().getClass();
+            }
+
+            // ugly hack getting the property, but it works
+            String property = eval.getNode().jjtGetChild(eval.getNode().jjtGetNumChildren() - 1).toString();
+
+            if (property.startsWith("\"") && property.endsWith("\"")) {
+                property = property.substring(1, property.length() - 1);
+            }
+
+            classProp[1] = property;
+        }
+
+        return classProp;
+    }
+
     private Object acceptableErrorValue(Class toClass) {
         if (!toClass.isPrimitive()) {
             return null;
         return null;
     }
 
-    public static String buildConverterFilename(Class clazz) {
-        String className = clazz.getName();
-        String resource = className.replace('.', '/') + "-conversion.properties";
-
-        return resource;
-    }
-
     private Map buildConverterMapping(Class clazz) throws Exception {
         Map mapping = new HashMap();
 
                 Map.Entry entry = (Map.Entry) iterator.next();
                 String propName = (String) entry.getKey();
                 String className = (String) entry.getValue();
+
                 if (!propName.startsWith("Collection_")) {
                     entry.setValue(createTypeConverter(className));
                 }
         return mapping;
     }
 
-    private TypeConverter createTypeConverter(String className) throws Exception, InstantiationException {
+    private TypeConverter createTypeConverter(String className) throws Exception {
         Class conversionClass = Thread.currentThread().getContextClassLoader().loadClass(className);
 
-        return (TypeConverter) conversionClass.newInstance();
+        return (TypeConverter) ObjectFactory.getObjectFactory().buildBean(conversionClass);
     }
 
     private void loadConversionProps(String propsName) throws Exception {

src/java/com/opensymphony/xwork/util/XWorkList.java

  */
 package com.opensymphony.xwork.util;
 
+import com.opensymphony.xwork.ObjectFactory;
+
 import java.util.AbstractList;
 import java.util.ArrayList;
 
     public synchronized Object get(int index) {
         while (index >= this.size()) {
             try {
-                this.add(clazz.newInstance());
+                this.add(ObjectFactory.getObjectFactory().buildBean(clazz));
             } catch (Exception e) {
                 e.printStackTrace();
                 throw new RuntimeException(e.getMessage());

src/java/com/opensymphony/xwork/util/XWorkMap.java

  */
 package com.opensymphony.xwork.util;
 
+import com.opensymphony.xwork.ObjectFactory;
+
 import java.util.HashMap;
 
 
 
         if (o == null) {
             try {
-                o = clazz.newInstance();
+                o = ObjectFactory.getObjectFactory().buildBean(clazz);
                 this.put(key, o);
             } catch (Exception e) {
                 e.printStackTrace();

src/java/com/opensymphony/xwork/util/XWorkMethodAccessor.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.xwork.util;
 
-import ognl.ObjectMethodAccessor;
 import ognl.MethodFailedException;
+import ognl.ObjectMethodAccessor;
 
 import java.util.Map;
 
+
 /**
  * User: plightbo
  * Date: Dec 28, 2003
  * Time: 8:34:20 PM
  */
 public class XWorkMethodAccessor extends ObjectMethodAccessor {
+    //~ Static fields/initializers /////////////////////////////////////////////
+
     public static final String DENY_METHOD_EXECUTION = "xwork.MethodAccessor.denyMethodExecution";
 
+    //~ Methods ////////////////////////////////////////////////////////////////
+
     public Object callMethod(Map context, Object object, String string, Object[] objects) throws MethodFailedException {
         Boolean create = (Boolean) context.get(DENY_METHOD_EXECUTION);
-        boolean c = (create == null ? false : create.booleanValue());
+        boolean c = ((create == null) ? false : create.booleanValue());
+
         if (!c) {
             return super.callMethod(context, object, string, objects);
         } else {
 
     public Object callStaticMethod(Map context, Class aClass, String string, Object[] objects) throws MethodFailedException {
         Boolean create = (Boolean) context.get(DENY_METHOD_EXECUTION);
-        boolean c = (create == null ? false : create.booleanValue());
+        boolean c = ((create == null) ? false : create.booleanValue());
+
         if (!c) {
             return super.callStaticMethod(context, aClass, string, objects);
         } else {

src/java/com/opensymphony/xwork/validator/ValidatorFactory.java

 
 import com.opensymphony.util.ClassLoaderUtil;
 
+import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.util.OgnlUtil;
 
 import org.apache.commons.logging.Log;
         Validator validator;
 
         try {
-            validator = (Validator) clazz.newInstance();
-            OgnlUtil.setProperties(params, validator);
+            validator = ObjectFactory.getObjectFactory().buildValidator(clazz, params);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new IllegalArgumentException("There was a problem creating a FieldValidator of type " + clazz.getName());
+            throw new IllegalArgumentException("There was a problem creating a Validator of type " + clazz.getName());
         }
 
         return validator;

src/test/com/opensymphony/xwork/SimpleAction.java

     }
 
     public boolean[] getBools() {
-        boolean[] b = new boolean[]{true, false, false, true};
+        boolean[] b = new boolean[] {true, false, false, true};
 
         return b;
     }

src/test/com/opensymphony/xwork/config/providers/XmlConfigurationProviderActionsTest.java

 package com.opensymphony.xwork.config.providers;
 
 import com.opensymphony.xwork.MockInterceptor;
+import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.SimpleAction;
-import com.opensymphony.xwork.config.ConfigurationException;
 import com.opensymphony.xwork.config.ConfigurationProvider;
 import com.opensymphony.xwork.config.entities.ActionConfig;
+import com.opensymphony.xwork.config.entities.InterceptorConfig;
 import com.opensymphony.xwork.config.entities.PackageConfig;
 import com.opensymphony.xwork.config.entities.ResultConfig;
 import com.opensymphony.xwork.interceptor.TimerInterceptor;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public void testActions() throws ConfigurationException {
+    public void testActions() throws Exception {
         final String filename = "com/opensymphony/xwork/config/providers/xwork-test-actions.xml";
         ConfigurationProvider provider = buildConfigurationProvider(filename);
+        ObjectFactory objectFactory = ObjectFactory.getObjectFactory();
 
         // setup expectations
         // bar action is very simple, just two params
         params.put("foo", "18");
         params.put("bar", "24");
         results.put("success", new ResultConfig("success", MockResult.class, new HashMap()));
-        interceptors.add(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
+
+        InterceptorConfig timerInterceptorConfig = new InterceptorConfig("timer", TimerInterceptor.class, new HashMap());
+        interceptors.add(objectFactory.buildInterceptor(timerInterceptorConfig, new HashMap()));
 
         ActionConfig fooAction = new ActionConfig(null, SimpleAction.class, params, results, interceptors);
 
         HashMap interceptorParams = new HashMap();
         interceptorParams.put("expectedFoo", "expectedFooValue");
         interceptorParams.put("foo", MockInterceptor.DEFAULT_FOO_VALUE);
+
+        InterceptorConfig mockInterceptorConfig = new InterceptorConfig("mock", MockInterceptor.class, new HashMap());
         interceptors = new ArrayList();
-        interceptors.add(InterceptorBuilder.buildInterceptor(MockInterceptor.class, interceptorParams));
+        interceptors.add(objectFactory.buildInterceptor(mockInterceptorConfig, interceptorParams));
 
         ActionConfig intAction = new ActionConfig(null, SimpleAction.class, new HashMap(), new HashMap(), interceptors);
 
         interceptorParams.put("expectedFoo", "expectedFooValue");
         interceptorParams.put("foo", "foo123");
         interceptors = new ArrayList();
-        interceptors.add(InterceptorBuilder.buildInterceptor(MockInterceptor.class, interceptorParams));
+        interceptors.add(objectFactory.buildInterceptor(mockInterceptorConfig, interceptorParams));
 
         ActionConfig intOverAction = new ActionConfig(null, SimpleAction.class, new HashMap(), new HashMap(), interceptors);
 

src/test/com/opensymphony/xwork/config/providers/XmlConfigurationProviderInterceptorsTest.java

 package com.opensymphony.xwork.config.providers;
 
 import com.opensymphony.xwork.MockInterceptor;
+import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.SimpleAction;
 import com.opensymphony.xwork.config.ConfigurationException;
 import com.opensymphony.xwork.config.ConfigurationManager;
  * To change this template use Options | File Templates.
  */
 public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestBase {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    InterceptorConfig loggingInterceptor = new InterceptorConfig("logging", LoggingInterceptor.class, new HashMap());
+    InterceptorConfig mockInterceptor = new InterceptorConfig("mock", MockInterceptor.class, new HashMap());
+    InterceptorConfig timerInterceptor = new InterceptorConfig("timer", TimerInterceptor.class, new HashMap());
+    ObjectFactory objectFactory = ObjectFactory.getObjectFactory();
+
     //~ Methods ////////////////////////////////////////////////////////////////
 
     public void testBasicInterceptors() throws ConfigurationException {
         ConfigurationProvider provider = buildConfigurationProvider(filename);
 
         // setup expectations
-        // the timer & logging interceptors
-        InterceptorConfig timerInterceptor = new InterceptorConfig("timer", TimerInterceptor.class, new HashMap());
-        InterceptorConfig loggingInterceptor = new InterceptorConfig("logging", LoggingInterceptor.class, new HashMap());
-
         // the test interceptor with a parameter
         Map params = new HashMap();
         params.put("foo", "expectedFoo");
 
         // the default interceptor stack
         InterceptorStackConfig defaultStack = new InterceptorStackConfig("defaultStack");
-        defaultStack.addInterceptor(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
-        defaultStack.addInterceptor(InterceptorBuilder.buildInterceptor(MockInterceptor.class, params));
+        defaultStack.addInterceptor(objectFactory.buildInterceptor(timerInterceptor, new HashMap()));
+        defaultStack.addInterceptor(objectFactory.buildInterceptor(mockInterceptor, params));
 
         // the derivative interceptor stack
         InterceptorStackConfig derivativeStack = new InterceptorStackConfig("derivativeStack");
-        derivativeStack.addInterceptor(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
-        derivativeStack.addInterceptor(InterceptorBuilder.buildInterceptor(MockInterceptor.class, params));
-        derivativeStack.addInterceptor(InterceptorBuilder.buildInterceptor(LoggingInterceptor.class, new HashMap()));
+        derivativeStack.addInterceptor(objectFactory.buildInterceptor(timerInterceptor, new HashMap()));
+        derivativeStack.addInterceptor(objectFactory.buildInterceptor(mockInterceptor, params));
+        derivativeStack.addInterceptor(objectFactory.buildInterceptor(loggingInterceptor, new HashMap()));
 
         // execute the configuration
         provider.init(configuration);
         // expectations - the inherited interceptor stack
         // default package
         ArrayList interceptors = new ArrayList();
-        interceptors.add(InterceptorBuilder.buildInterceptor(LoggingInterceptor.class, new HashMap()));
+        interceptors.add(objectFactory.buildInterceptor(loggingInterceptor, new HashMap()));
 
         ActionConfig actionWithOwnRef = new ActionConfig(null, SimpleAction.class, new HashMap(), new HashMap(), interceptors);
 
         interceptors = new ArrayList();
-        interceptors.add(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
+        interceptors.add(objectFactory.buildInterceptor(timerInterceptor, new HashMap()));
 
         ActionConfig actionWithDefaultRef = new ActionConfig(null, SimpleAction.class, new HashMap(), new HashMap(), interceptors);
 
         ActionConfig actionWithNoRef = new ActionConfig(null, SimpleAction.class, new HashMap(), new HashMap(), interceptors);
 
         interceptors = new ArrayList();
-        interceptors.add(InterceptorBuilder.buildInterceptor(LoggingInterceptor.class, new HashMap()));
+        interceptors.add(objectFactory.buildInterceptor(loggingInterceptor, new HashMap()));
 
         ActionConfig anotherActionWithOwnRef = new ActionConfig(null, SimpleAction.class, new HashMap(), new HashMap(), interceptors);
 
 
         // expectations - the inherited interceptor stack
         InterceptorStackConfig inheritedStack = new InterceptorStackConfig("subDefaultStack");
-        inheritedStack.addInterceptor(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
+        inheritedStack.addInterceptor(objectFactory.buildInterceptor(timerInterceptor, new HashMap()));
 
         provider.init(configuration);
 
 
         // expectations - the inherited interceptor stack
         inheritedStack = new InterceptorStackConfig("subSubDefaultStack");
-        inheritedStack.addInterceptor(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
-        inheritedStack.addInterceptor(InterceptorBuilder.buildInterceptor(TimerInterceptor.class, new HashMap()));
+        inheritedStack.addInterceptor(objectFactory.buildInterceptor(timerInterceptor, new HashMap()));
+        inheritedStack.addInterceptor(objectFactory.buildInterceptor(timerInterceptor, new HashMap()));
 
         PackageConfig subSubPkg = configuration.getPackageConfig("subSubPackage");
         assertEquals(1, subSubPkg.getInterceptorConfigs().size());

src/test/com/opensymphony/xwork/interceptor/ChainingInterceptorTest.java

 package com.opensymphony.xwork.interceptor;
 
 import com.mockobjects.dynamic.Mock;
+
 import com.opensymphony.xwork.*;
 import com.opensymphony.xwork.util.OgnlValueStack;
+
 import junit.framework.TestCase;
 
 import java.util.Date;

src/test/com/opensymphony/xwork/util/Foo.java

     Bar bar;
     Date birthday;
     Foo child;
+    List cats;
+    List strings;
+    Map catMap;
     String title;
     long[] points;
     Foo[] relatives;
     boolean useful;
     int number;
     long aLong;
-    List cats;
-    Map catMap;
-    List strings;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
         return birthday;
     }
 
+    public void setCatMap(Map catMap) {
+        this.catMap = catMap;
+    }
+
+    public Map getCatMap() {
+        return catMap;
+    }
+
+    public void setCats(List cats) {
+        this.cats = cats;
+    }
+
+    public List getCats() {
+        return cats;
+    }
+
     public void setChild(Foo child) {
         this.child = child;
     }
         return relatives;
     }
 
+    public void setStrings(List strings) {
+        this.strings = strings;
+    }
+
+    public List getStrings() {
+        return strings;
+    }
+
     public void setTitle(String title) {
         this.title = title;
     }
     public boolean isUseful() {
         return useful;
     }
-
-    public List getCats() {
-        return cats;
-    }
-
-    public void setCats(List cats) {
-        this.cats = cats;
-    }
-
-    public Map getCatMap() {
-        return catMap;
-    }
-
-    public void setCatMap(Map catMap) {
-        this.catMap = catMap;
-    }
-
-    public List getStrings() {
-        return strings;
-    }
-
-    public void setStrings(List strings) {
-        this.strings = strings;
-    }
 }

src/test/com/opensymphony/xwork/util/OgnlValueStackTest.java

         assertEquals("blah", action.getName());
     }
 
+    public void testConvertStringArrayToList() {
+        Foo foo = new Foo();
+        OgnlValueStack vs = new OgnlValueStack();
+        vs.push(foo);
+
+        vs.setValue("strings", new String[] {"one", "two"});
+
+        assertNotNull(foo.getStrings());
+        assertEquals("one", foo.getStrings().get(0));
+        assertEquals("two", foo.getStrings().get(1));
+    }
+
     public void testDeepProperties() {
         OgnlValueStack vs = new OgnlValueStack();
 
         assertEquals(0, action.getBar());
     }
 
-    public void testTypeConversionError() {
-        TestBean bean = new TestBean();
-        OgnlValueStack stack = new OgnlValueStack();
-        stack.push(bean);
-        stack.getContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
-        stack.setValue("count","a");
-        Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
-        assertTrue(conversionErrors.containsKey("count"));
-    }
-
     public void testSerializable() throws IOException, ClassNotFoundException {
         OgnlValueStack vs = new OgnlValueStack();
 
         assertEquals(123, foo.getChild().getBar().getSomethingElse());
     }
 
-    public void testSetReallyDeepBarAsString() {
-        Foo foo = new Foo();
-        Foo foo2 = new Foo();
-        foo.setChild(foo2);
-
-        Foo foo3 = new Foo();
-        foo2.setChild(foo3);
-
-        OgnlValueStack vs = new OgnlValueStack();
-        vs.push(foo);
-
-        vs.setValue("child.child.bar", "bar:123");
-
-        assertEquals("bar", foo.getChild().getChild().getBar().getTitle());
-        assertEquals(123, foo.getChild().getChild().getBar().getSomethingElse());
-    }
-
     public void testSetNullList() {
         Foo foo = new Foo();
         OgnlValueStack vs = new OgnlValueStack();
         assertEquals("Deep null cat", ((Cat) ((Cat) foo.getCats().get(0)).getFoo().getCats().get(1)).name);
     }
 
-    public void testConvertStringArrayToList() {
-        Foo foo = new Foo();
-        OgnlValueStack vs = new OgnlValueStack();
-        vs.push(foo);
-
-        vs.setValue("strings", new String[]{"one", "two"});
-
-        assertNotNull(foo.getStrings());
-        assertEquals("one", foo.getStrings().get(0));
-        assertEquals("two", foo.getStrings().get(1));
-    }
-
     public void testSetNullMap() {
         Foo foo = new Foo();
         OgnlValueStack vs = new OgnlValueStack();
         assertEquals("Deep null cat", ((Cat) ((Cat) foo.getCatMap().get("One")).getFoo().getCatMap().get("Two")).name);
     }
 
+    public void testSetReallyDeepBarAsString() {
+        Foo foo = new Foo();
+        Foo foo2 = new Foo();
+        foo.setChild(foo2);
+
+        Foo foo3 = new Foo();
+        foo2.setChild(foo3);
+
+        OgnlValueStack vs = new OgnlValueStack();
+        vs.push(foo);
+
+        vs.setValue("child.child.bar", "bar:123");
+
+        assertEquals("bar", foo.getChild().getChild().getBar().getTitle());
+        assertEquals(123, foo.getChild().getChild().getBar().getSomethingElse());
+    }
+
     public void testSettingDogGender() {
         OgnlValueStack vs = new OgnlValueStack();
 
         assertEquals("Rover", vs.findValue("name"));
     }
 
+    public void testTypeConversionError() {
+        TestBean bean = new TestBean();
+        OgnlValueStack stack = new OgnlValueStack();
+        stack.push(bean);
+        stack.getContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+        stack.setValue("count", "a");
+
+        Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
+        assertTrue(conversionErrors.containsKey("count"));
+    }
+
     //~ Inner Classes //////////////////////////////////////////////////////////
 
     class BadJavaBean {

src/test/com/opensymphony/xwork/validator/DateRangeValidatorTest.java

 
 import junit.framework.TestCase;
 
-import java.util.List;
-import java.util.Map;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 
 /**
  *         Created Feb 9, 2003 1:25:42 AM
  */
 public class DateRangeValidatorTest extends TestCase {
-    //~ Methods ////////////////////////////////////////////////////////////////
+    //~ Instance fields ////////////////////////////////////////////////////////
 
     private Locale origLocale;
 
+    //~ Methods ////////////////////////////////////////////////////////////////
+
     /**
      * Tests whether the date range validation is working. Should produce an validation error,
      * because the action config sets date to 12/20/2002 while expected range is Dec 22-25.
 
         String errorMessage = (String) errorMessages.get(0);
         assertNotNull(errorMessage);
-
     }
 
     protected void setUp() throws Exception {
     protected void tearDown() throws Exception {
         Locale.setDefault(origLocale);
     }
-
 }

src/test/com/opensymphony/xwork/validator/SimpleActionValidationTest.java

  * @author Jason Carreira
  */
 public class SimpleActionValidationTest extends TestCase {
-    //~ Methods ////////////////////////////////////////////////////////////////
+    //~ Instance fields ////////////////////////////////////////////////////////
 
     private Locale origLocale;
 
+    //~ Methods ////////////////////////////////////////////////////////////////