Commits

Anonymous committed 73a13b6

More refactorings, half the tests working

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/no-statics@1605e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (51)

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

 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.PreResultListener;
 import com.opensymphony.xwork2.util.ValueStack;
     protected ObjectFactory objectFactory;
     protected ActionEventListener actionEventListener;
     protected ValueStackFactory valueStackFactory;
-
+    protected Container container;
     protected UnknownHandler unknownHandler;
 
     public DefaultActionInvocation(final Map extraContext, final boolean pushAction) throws Exception {
         this.objectFactory = fac;
     }
     
+    @Inject
+    public void setContainer(Container cont) {
+        this.container = cont;
+    }
+    
     @Inject(required=false)
     public void setUnknownHandler(UnknownHandler hand) {
         this.unknownHandler = hand;
 
         //put this DefaultActionInvocation into the context map
         contextMap.put(ActionContext.ACTION_INVOCATION, this);
+        contextMap.put(ActionContext.CONTAINER, container);
 
         return contextMap;
     }

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

         this.container = container;
     }
 
+    /**
+     * @deprecated Since 2.1
+     */
     public static ObjectFactory getObjectFactory() {
         return ActionContext.getContext().getContainer().getInstance(ObjectFactory.class);
     }

src/java/com/opensymphony/xwork2/XWorkTestCase.java

 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
 import com.opensymphony.xwork2.config.impl.MockConfiguration;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
     }
     
     protected void loadWithOverriding(ConfigurationProvider... providers) {
-        XmlConfigurationProvider def = new XmlConfigurationProvider("xwork-default.xml");
-        def.setThrowExceptionOnDuplicateBeans(false);
+        XWorkConfigurationProvider def = new XWorkConfigurationProvider();
         ConfigurationProvider[] sum = new ConfigurationProvider[providers.length + 1];
         System.arraycopy(providers, 0, sum, 0, providers.length);
         sum[providers.length] = def;

src/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java

 import com.opensymphony.xwork2.inject.Context;
 import com.opensymphony.xwork2.inject.Factory;
 import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
 import com.opensymphony.xwork2.ognl.OgnlValueStackFactory;
 import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
 import com.opensymphony.xwork2.util.CompoundRoot;
             setContext(bootstrap);
             container = builder.create(false);
             setContext(container);
+            objectFactory = container.getInstance(ObjectFactory.class);
             
             for (ConfigurationProvider configurationProvider : providers)
             {
         builder.factory(TextProvider.class, DefaultTextProvider.class);
         builder.factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class);
         builder.factory(PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class);
+        builder.factory(OgnlUtil.class);
+        builder.constant("devMode", "false");
         return builder.create(true);
     }
 

src/java/com/opensymphony/xwork2/config/impl/MockConfiguration.java

 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.RuntimeConfiguration;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
 import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
 import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.Context;
 import com.opensymphony.xwork2.inject.Factory;
 import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
 
 import java.util.HashSet;
     private Container container;
     
     public MockConfiguration() {
-        container = new ContainerBuilder()
-            .factory(ReflectionProvider.class, OgnlReflectionProvider.class)
-            .factory(XWorkConverter.class)
-            .factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class)
-            .factory(ObjectFactory.class)
-            .factory(ActionProxyFactory.class, DefaultActionProxyFactory.class)
-            .factory(Configuration.class, new Factory() {
-
-                public Object create(Context context) throws Exception {
-                    return MockConfiguration.this;
-                }
-                
-            })
-            .create(true);
+        ContainerBuilder builder = new ContainerBuilder();
+        LocatableProperties props = new LocatableProperties();
+        new XWorkConfigurationProvider().register(builder, props);
+        builder.constant("devMode", "false");
+        container = builder.create(true);
     }
 
     public PackageConfig getPackageConfig(String name) {

src/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java

 import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
 import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer;
 import com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler;
+import com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Scope;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextFactory;
 import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
 import com.opensymphony.xwork2.ognl.ObjectProxy;
 import com.opensymphony.xwork2.ognl.OgnlReflectionContextFactory;
 import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
 import com.opensymphony.xwork2.ognl.OgnlValueStackFactory;
 import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
 import com.opensymphony.xwork2.ognl.accessor.ObjectAccessor;
             throws ConfigurationException {
 
         builder.factory(com.opensymphony.xwork2.ObjectFactory.class)
-               .factory(ActionProxyFactory.class, DefaultActionProxyFactory.class)
-               .factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class)
-               .factory(XWorkConverter.class)
-               .factory(ValueStackFactory.class, OgnlValueStackFactory.class)
-               .factory(ReflectionProvider.class, OgnlReflectionProvider.class)
-               .factory(ReflectionContextFactory.class, OgnlReflectionContextFactory.class)
-               .factory(PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class)
-               .factory(PropertyAccessor.class, Object.class.getName(), ObjectAccessor.class)
-               .factory(PropertyAccessor.class, Iterator.class.getName(), XWorkIteratorPropertyAccessor.class)
-               .factory(PropertyAccessor.class, Enumeration.class.getName(), XWorkEnumerationAcccessor.class)
-               .factory(PropertyAccessor.class, List.class.getName(), XWorkListPropertyAccessor.class)
-               .factory(PropertyAccessor.class, Map.class.getName(), XWorkMapPropertyAccessor.class)
-               .factory(PropertyAccessor.class, Collection.class.getName(), XWorkCollectionPropertyAccessor.class)
-               .factory(PropertyAccessor.class, Set.class.getName(), XWorkCollectionPropertyAccessor.class)
-               .factory(PropertyAccessor.class, ObjectProxy.class.getName(), ObjectProxyPropertyAccessor.class)
-               .factory(MethodAccessor.class, Object.class.getName(), XWorkMethodAccessor.class)
-               .factory(MethodAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class)
-               .factory(NullHandler.class, Object.class.getName(), InstantiatingNullHandler.class)
-               .factory(ActionValidatorManager.class, AnnotationActionValidatorManager.class)
-               .factory(ActionValidatorManager.class, "no-annotations", DefaultActionValidatorManager.class)
-               .factory(TextProvider.class, DefaultTextProvider.class)
-               .constant("devMode", Boolean.FALSE.toString());
+               .factory(ActionProxyFactory.class, DefaultActionProxyFactory.class, Scope.SINGLETON)
+               .factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON)
+               .factory(XWorkConverter.class, Scope.SINGLETON)
+               .factory(ValueStackFactory.class, OgnlValueStackFactory.class, Scope.SINGLETON)
+               .factory(ReflectionProvider.class, OgnlReflectionProvider.class, Scope.SINGLETON)
+               .factory(ReflectionContextFactory.class, OgnlReflectionContextFactory.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, Object.class.getName(), ObjectAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, Iterator.class.getName(), XWorkIteratorPropertyAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, Enumeration.class.getName(), XWorkEnumerationAcccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, List.class.getName(), XWorkListPropertyAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, Map.class.getName(), XWorkMapPropertyAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, Collection.class.getName(), XWorkCollectionPropertyAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, Set.class.getName(), XWorkCollectionPropertyAccessor.class, Scope.SINGLETON)
+               .factory(PropertyAccessor.class, ObjectProxy.class.getName(), ObjectProxyPropertyAccessor.class, Scope.SINGLETON)
+               .factory(MethodAccessor.class, Object.class.getName(), XWorkMethodAccessor.class, Scope.SINGLETON)
+               .factory(MethodAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class, Scope.SINGLETON)
+               .factory(NullHandler.class, Object.class.getName(), InstantiatingNullHandler.class, Scope.SINGLETON)
+               .factory(ActionValidatorManager.class, AnnotationActionValidatorManager.class, Scope.SINGLETON)
+               .factory(ActionValidatorManager.class, "no-annotations", DefaultActionValidatorManager.class, Scope.SINGLETON)
+               .factory(TextProvider.class, DefaultTextProvider.class, Scope.SINGLETON)
+               .factory(OgnlUtil.class, Scope.SINGLETON)
+               .factory(XWorkBasicConverter.class, Scope.SINGLETON);
+        props.setProperty("devMode", Boolean.FALSE.toString());
     }
 
 }

src/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java

     private XWorkConverter xworkConverter;
     
     @Inject
-    public void setReflectionProvider(ReflectionProvider prov) {
+    public DefaultObjectTypeDeterminer(@Inject XWorkConverter conv, @Inject XWorkBasicConverter basicConv,
+                                       @Inject ReflectionProvider prov) {
         this.reflectionProvider = prov;
+        this.xworkConverter = conv;
+        
+        // HACK: this is to get around a dumb circular dependency
+        basicConv.setObjectTypeDeterminer(this);
+        this.xworkConverter.setDefaultTypeConverter(basicConv);
     }
     
-    @Inject
-    public void setXWorkConverter(XWorkConverter conv) {
-       this.xworkConverter = conv; 
-    }
-
     /**
      * Determines the key class by looking for the value of @Key annotation for the given class.
      * If no annotation is found, the key class is determined by using the generic parametrics.

src/java/com/opensymphony/xwork2/conversion/impl/GenericsObjectTypeDeterminer.java

 
 package com.opensymphony.xwork2.conversion.impl;
 
+import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
+
 
 /**
  * GenericsObjectTypeDeterminer
  *             annotation processing.
  */
 public class GenericsObjectTypeDeterminer extends DefaultObjectTypeDeterminer {
+
+    public GenericsObjectTypeDeterminer(XWorkConverter conv,
+            XWorkBasicConverter basicConv, ReflectionProvider prov) {
+        super(conv, basicConv, prov);
+    }
 }

src/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java

 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.XWorkException;
+import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
 import com.opensymphony.xwork2.conversion.TypeConverter;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.TextUtils;
 
 
 public class XWorkBasicConverter extends DefaultTypeConverter {
 
     private static String MILLISECOND_FORMAT = ".SSS";
+    
+    private ObjectTypeDeterminer objectTypeDeterminer;
+    
+    public void setObjectTypeDeterminer(ObjectTypeDeterminer det) {
+        this.objectTypeDeterminer = det;
+    }
 
     public Object convertValue(Map context, Object o, Member member, String s, Object value, Class toType) {
         Object result = null;
 
         if (o != null) {
             //memberType = (Class) XWorkConverter.getInstance().getConverter(o.getClass(), XWorkConverter.CONVERSION_COLLECTION_PREFIX + prop);
-            memberType = XWorkConverter.getInstance().getObjectTypeDeterminer().getElementClass(o.getClass(), prop, null);
+            memberType = objectTypeDeterminer.getElementClass(o.getClass(), prop, null);
 
             if (memberType == null) {
                 memberType = String.class;

src/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java

      */
     protected HashSet<String> unknownMappings = new HashSet<String>(); 	// non-action (eg. returned value)
     
-    protected TypeConverter defaultTypeConverter = new XWorkBasicConverter();
-    protected ObjectTypeDeterminer objectTypeDeterminer = null;
+    private TypeConverter defaultTypeConverter;
     private ObjectFactory objectFactory;
 
 
     }
 
 
-    public static XWorkConverter getInstance() {
-         return ActionContext.getContext().getInstance(XWorkConverter.class);
-     }
-    
     @Inject
     public void setObjectFactory(ObjectFactory factory) {
         this.objectFactory = factory;
     }
-
+    
+    // HACK: Will actually be set by default object type determiner to get around the circular dep
+    public void setDefaultTypeConverter(TypeConverter conv) {
+        this.defaultTypeConverter = conv;
+    }
+    
     public static String buildConverterFilename(Class clazz) {
         String className = clazz.getName();
         String resource = className.replace('.', '/') + "-conversion.properties";
         return resource;
     }
 
-    public void setDefaultConverter(TypeConverter defaultTypeConverter) {
-        this.defaultTypeConverter = defaultTypeConverter;
-    }
-
     public Object convertValue(Map map, Object o, Class aClass) {
         return convertValue(map, null, null, null, o, aClass);
     }
             try {
                 if (LOG.isDebugEnabled())
                     LOG.debug("falling back to Ognl's default type conversion");
-                return super.convertValue(context, target, member, property, value, toClass);
+                return super.convertValue(value, toClass);
             } catch (Exception e) {
                 e.printStackTrace();
                 handleConversionException(context, property, value, target);
         return result;
     }
 
-    public ObjectTypeDeterminer getObjectTypeDeterminer() {
-        return objectTypeDeterminer;
-    }
-
-    /**
-     * @param determiner
-     */
-    @Inject
-    public void setObjectTypeDeterminer(ObjectTypeDeterminer determiner) {
-        objectTypeDeterminer = determiner;
-    }
 
 }

src/java/com/opensymphony/xwork2/inject/ContainerBuilder.java

       new ArrayList<InternalFactory<?>>();
   final List<Class<?>> staticInjections = new ArrayList<Class<?>>();
   boolean created;
+  boolean allowDuplicates = false;
 
   private static final InternalFactory<Container> CONTAINER_FACTORY =
       new InternalFactory<Container>() {
    * Ensures a key isn't already mapped.
    */
   private void checkKey(Key<?> key) {
-    if (factories.containsKey(key)) {
+    if (factories.containsKey(key) && !allowDuplicates) {
       throw new DependencyException(
           "Dependency mapping for " + key + " already exists.");
     }
       throw new IllegalStateException("Container already created.");
     }
   }
+  
+  public void setAllowDuplicates(boolean val) {
+      allowDuplicates = val;
+  }
 
   /**
    * Implemented by classes which participate in building a container.

src/java/com/opensymphony/xwork2/ognl/OgnlReflectionProvider.java

 import ognl.OgnlException;
 import ognl.OgnlRuntime;
 
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.reflection.ReflectionException;
 import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
 
 public class OgnlReflectionProvider implements ReflectionProvider {
+    
+    private OgnlUtil ognlUtil;
+    
+    @Inject
+    public void setOgnlUtil(OgnlUtil ognlUtil) {
+        this.ognlUtil = ognlUtil;
+    }
 
     public Field getField(Class inClass, String name) {
         return OgnlRuntime.getField(inClass, name);
     }
 
     public void setProperties(Map props, Object o, Map context) {
-        OgnlUtil.setProperties(props, o, context);
+        ognlUtil.setProperties(props, o, context);
     }
 
     public void setProperties(Map props, Object o, Map context,
             boolean throwPropertyExceptions) {
-        OgnlUtil.setProperties(props, o, context, throwPropertyExceptions);
+        ognlUtil.setProperties(props, o, context, throwPropertyExceptions);
         
     }
 
     public void setProperties(Map properties, Object o) {
-        OgnlUtil.setProperties(properties, o);
+        ognlUtil.setProperties(properties, o);
     }
 
     public PropertyDescriptor getPropertyDescriptor(Class targetClass,
 
     public void copy(Object from, Object to, Map context,
             Collection exclusions, Collection inclusions) {
-        OgnlUtil.copy(from, to, context, exclusions, inclusions);
+        ognlUtil.copy(from, to, context, exclusions, inclusions);
     }
 
     public Object getRealTarget(String property, Map context, Object root)
             throws ReflectionException {
         try {
-            return OgnlUtil.getRealTarget(property, context, root);
+            return ognlUtil.getRealTarget(property, context, root);
         } catch (OgnlException e) {
             throw new ReflectionException(e);
         }
     }
 
     public void setProperty(String name, Object value, Object o, Map context) {
-        OgnlUtil.setProperty(name, value, o, context);
+        ognlUtil.setProperty(name, value, o, context);
     }
 
     public Map getBeanMap(Object source) throws IntrospectionException,
             ReflectionException {
         try {
-            return OgnlUtil.getBeanMap(source);
+            return ognlUtil.getBeanMap(source);
         } catch (OgnlException e) {
             throw new ReflectionException(e);
         }
     public Object getValue(String expression, Map context, Object root)
             throws ReflectionException {
         try {
-            return OgnlUtil.getValue(expression, context, root);
+            return ognlUtil.getValue(expression, context, root);
         } catch (OgnlException e) {
             throw new ReflectionException(e);
         }
 
     public PropertyDescriptor[] getPropertyDescriptors(Object source)
             throws IntrospectionException {
-        return OgnlUtil.getPropertyDescriptors(source);
+        return ognlUtil.getPropertyDescriptors(source);
     }
 
 }

src/java/com/opensymphony/xwork2/ognl/OgnlUtil.java

 import ognl.OgnlContext;
 import ognl.OgnlException;
 import ognl.OgnlRuntime;
+import ognl.TypeConverter;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.XWorkException;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.CompoundRoot;
+import com.opensymphony.xwork2.util.ValueStack;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 public class OgnlUtil {
 
     private static final Log log = LogFactory.getLog(OgnlUtil.class);
-    private static HashMap expressions = new HashMap();
-    private static HashMap beanInfoCache = new HashMap();
-
-
+    private HashMap expressions = new HashMap();
+    private HashMap beanInfoCache = new HashMap();
+    
+    private TypeConverter defaultConverter;
+    
+    @Inject
+    public void setXWorkConverter(XWorkConverter conv) {
+        this.defaultConverter = new OgnlTypeConverterWrapper(conv);
+    }
+    
     /**
      * Sets the object's properties using the default type converter, defaulting to not throw
      * exceptions for problems setting the properties.
      * @param o       the object
      * @param context the action context
      */
-    public static void setProperties(Map props, Object o, Map context) {
+    public void setProperties(Map props, Object o, Map context) {
         setProperties(props, o, context, false);
     }
 
      * @param throwPropertyExceptions boolean which tells whether it should throw exceptions for
      *                                problems setting the properties
      */
-    public static void setProperties(Map props, Object o, Map context, boolean throwPropertyExceptions) {
+    public void setProperties(Map props, Object o, Map context, boolean throwPropertyExceptions) {
         if (props == null) {
             return;
         }
 
-        Ognl.setTypeConverter(context, new OgnlTypeConverterWrapper(XWorkConverter.getInstance()));
+        Ognl.setTypeConverter(context, getTypeConverterFromContext(context));
 
         Object oldRoot = Ognl.getRoot(context);
         Ognl.setRoot(context, o);
      * @param properties
      * @param o
      */
-    public static void setProperties(Map properties, Object o) {
+    public void setProperties(Map properties, Object o) {
         setProperties(properties, o, false);
     }
 
      * @param throwPropertyExceptions boolean which tells whether it should throw exceptions for
      *                                problems setting the properties
      */
-    public static void setProperties(Map properties, Object o, boolean throwPropertyExceptions) {
+    public void setProperties(Map properties, Object o, boolean throwPropertyExceptions) {
         Map context = Ognl.createDefaultContext(o);
         setProperties(properties, o, context, throwPropertyExceptions);
     }
      * @param o       the object upon which to set the property
      * @param context the context which may include the TypeConverter
      */
-    public static void setProperty(String name, Object value, Object o, Map context) {
+    public void setProperty(String name, Object value, Object o, Map context) {
         setProperty(name, value, o, context, false);
     }
 
      * @param throwPropertyExceptions boolean which tells whether it should throw exceptions for
      *                                problems setting the property
      */
-    public static void setProperty(String name, Object value, Object o, Map context, boolean throwPropertyExceptions) {
-        Ognl.setTypeConverter(context, new OgnlTypeConverterWrapper(XWorkConverter.getInstance()));
+    public void setProperty(String name, Object value, Object o, Map context, boolean throwPropertyExceptions) {
+        Ognl.setTypeConverter(context, getTypeConverterFromContext(context));
 
         Object oldRoot = Ognl.getRoot(context);
         Ognl.setRoot(context, o);
      *
      * @return the real target or null if no object can be found with the specified property
      */
-    public static Object getRealTarget(String property, Map context, Object root) throws OgnlException {
+    public Object getRealTarget(String property, Map context, Object root) throws OgnlException {
         //special keyword, they must be cutting the stack
         if ("top".equals(property)) {
             return root;
      * Wrapper around Ognl.setValue() to handle type conversion for collection elements.
      * Ideally, this should be handled by OGNL directly.
      */
-    public static void setValue(String name, Map context, Object root, Object value) throws OgnlException {
+    public void setValue(String name, Map context, Object root, Object value) throws OgnlException {
         Ognl.setValue(compile(name), context, root, value);
     }
 
-    public static Object getValue(String name, Map context, Object root) throws OgnlException {
+    public Object getValue(String name, Map context, Object root) throws OgnlException {
         return Ognl.getValue(compile(name), context, root);
     }
 
-    public static Object getValue(String name, Map context, Object root, Class resultType) throws OgnlException {
+    public Object getValue(String name, Map context, Object root, Class resultType) throws OgnlException {
         return Ognl.getValue(compile(name), context, root, resultType);
     }
 
 
-    public static Object compile(String expression) throws OgnlException {
+    public Object compile(String expression) throws OgnlException {
         synchronized (expressions) {
             Object o = expressions.get(expression);
 
      * @param inclusions collection of method names to included copying  (can be null)
      *                   note if exclusions AND inclusions are supplied and not null nothing will get copied.
      */
-    public static void copy(Object from, Object to, Map context, Collection exclusions, Collection inclusions) {
+    public void copy(Object from, Object to, Map context, Collection exclusions, Collection inclusions) {
         if (from == null || to == null) {
             log.warn("Attempting to copy from or to a null source. This is illegal and is bein skipped. This may be due to an error in an OGNL expression, action chaining, or some other event.");
 
             return;
         }
 
+        TypeConverter conv = getTypeConverterFromContext(context);
         Map contextFrom = Ognl.createDefaultContext(from);
-        Ognl.setTypeConverter(contextFrom, new OgnlTypeConverterWrapper(XWorkConverter.getInstance()));
+        Ognl.setTypeConverter(contextFrom, conv);
         Map contextTo = Ognl.createDefaultContext(to);
-        Ognl.setTypeConverter(contextTo, new OgnlTypeConverterWrapper(XWorkConverter.getInstance()));
+        Ognl.setTypeConverter(contextTo, conv);
 
         PropertyDescriptor[] fromPds;
         PropertyDescriptor[] toPds;
                     PropertyDescriptor toPd = (PropertyDescriptor) toPdHash.get(fromPd.getName());
                     if ((toPd != null) && (toPd.getWriteMethod() != null)) {
                         try {
-                            Object expr = OgnlUtil.compile(fromPd.getName());
+                            Object expr = compile(fromPd.getName());
                             Object value = Ognl.getValue(expr, contextFrom, from);
                             Ognl.setValue(expr, contextTo, to, value);
                         } catch (OgnlException e) {
      * @param to      the target object
      * @param context the action context we're running under
      */
-    public static void copy(Object from, Object to, Map context) {
-        OgnlUtil.copy(from, to, context, null, null);
+    public void copy(Object from, Object to, Map context) {
+        copy(from, to, context, null, null);
     }
 
     /**
      * @return  property descriptors.
      * @throws IntrospectionException is thrown if an exception occurs during introspection.
      */
-    public static PropertyDescriptor[] getPropertyDescriptors(Object source) throws IntrospectionException {
+    public PropertyDescriptor[] getPropertyDescriptors(Object source) throws IntrospectionException {
         BeanInfo beanInfo = getBeanInfo(source);
         return beanInfo.getPropertyDescriptors();
     }
      * @throws IntrospectionException is thrown if an exception occurs during introspection.
      * @throws OgnlException is thrown by OGNL if the property value could not be retrieved
      */
-    public static Map getBeanMap(Object source) throws IntrospectionException, OgnlException {
+    public Map getBeanMap(Object source) throws IntrospectionException, OgnlException {
         Map beanMap = new HashMap();
         Map sourceMap = Ognl.createDefaultContext(source);
         PropertyDescriptor[] propertyDescriptors = getPropertyDescriptors(source);
             String propertyName = propertyDescriptor.getDisplayName();
             Method readMethod = propertyDescriptor.getReadMethod();
             if (readMethod != null) {
-                Object expr = OgnlUtil.compile(propertyName);
+                Object expr = compile(propertyName);
                 Object value = Ognl.getValue(expr, sourceMap, source);
                 beanMap.put(propertyName, value);
             } else {
      * @return  java bean info.
      * @throws IntrospectionException is thrown if an exception occurs during introspection.
      */
-    public static BeanInfo getBeanInfo(Object from) throws IntrospectionException {
+    public BeanInfo getBeanInfo(Object from) throws IntrospectionException {
         synchronized (beanInfoCache) {
             BeanInfo beanInfo;
             beanInfo = (BeanInfo) beanInfoCache.get(from.getClass());
         }
     }
 
-    static void internalSetProperty(String name, Object value, Object o, Map context, boolean throwPropertyExceptions) {
+    void internalSetProperty(String name, Object value, Object o, Map context, boolean throwPropertyExceptions) {
         try {
             setValue(name, context, o, value);
         } catch (OgnlException e) {
             }
         }
     }
+    
+    TypeConverter getTypeConverterFromContext(Map context) {
+        /*ValueStack stack = (ValueStack) context.get(ActionContext.VALUE_STACK);
+        Container cont = (Container)stack.getContext().get(ActionContext.CONTAINER);
+        if (cont != null) {
+            return new OgnlTypeConverterWrapper(cont.getInstance(XWorkConverter.class));
+        } else {
+            throw new IllegalArgumentException("Cannot find type converter in context map");
+        }
+        */
+        return defaultConverter;
+    }
 }

src/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java

 package com.opensymphony.xwork2.ognl;
 
 import java.io.Serializable;
-import java.util.Collection;
-import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import ognl.Ognl;
 import ognl.OgnlContext;
 import ognl.OgnlException;
-import ognl.OgnlRuntime;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import com.opensymphony.xwork2.DefaultTextProvider;
 import com.opensymphony.xwork2.TextProvider;
 import com.opensymphony.xwork2.XWorkException;
-import com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
-import com.opensymphony.xwork2.ognl.accessor.ObjectAccessor;
-import com.opensymphony.xwork2.ognl.accessor.ObjectProxyPropertyAccessor;
-import com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor;
-import com.opensymphony.xwork2.ognl.accessor.XWorkEnumerationAcccessor;
-import com.opensymphony.xwork2.ognl.accessor.XWorkIteratorPropertyAccessor;
-import com.opensymphony.xwork2.ognl.accessor.XWorkListPropertyAccessor;
-import com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor;
-import com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor;
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
-import com.opensymphony.xwork2.util.reflection.ReflectionProviderFactory;
 
 /**
  * Ognl implementation of a value stack that allows for dynamic Ognl expressions to be evaluated against it. When
     transient Map context;
     Class defaultType;
     Map overrides;
+    OgnlUtil ognlUtil;
     
-    public OgnlValueStack(XWorkConverter xworkConverter, CompoundRootAccessor accessor, TextProvider prov) {
+    protected OgnlValueStack(XWorkConverter xworkConverter, CompoundRootAccessor accessor, TextProvider prov) {
         setRoot(xworkConverter, accessor, new CompoundRoot());
         push(prov);
     }
 
 
-    public OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundRootAccessor accessor) {
+    protected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundRootAccessor accessor) {
         setRoot(xworkConverter, accessor, new CompoundRoot(vs.getRoot()));
     }
+    
+    @Inject
+    public void setOgnlUtil(OgnlUtil ognlUtil) {
+        this.ognlUtil = ognlUtil;
+    }
 
-    private void setRoot(XWorkConverter xworkConverter,
+    protected void setRoot(XWorkConverter xworkConverter,
             CompoundRootAccessor accessor, CompoundRoot compoundRoot) {
         this.root = compoundRoot;
         this.context = Ognl.createDefaultContext(this.root, accessor, new OgnlTypeConverterWrapper(xworkConverter),
         try {
             context.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, expr);
             context.put(REPORT_ERRORS_ON_NO_PROP, (throwExceptionOnFailure) ? Boolean.TRUE : Boolean.FALSE);
-            OgnlUtil.setValue(expr, context, root, value);
+            ognlUtil.setValue(expr, context, root, value);
         } catch (OgnlException e) {
             if (throwExceptionOnFailure) {
                 e.printStackTrace(System.out);
                 return findValue(expr, defaultType);
             }
 
-            Object value = OgnlUtil.getValue(expr, context, root);
+            Object value = ognlUtil.getValue(expr, context, root);
             if (value != null) {
                 return value;
             } else {
                 expr = (String) overrides.get(expr);
             }
 
-            Object value = OgnlUtil.getValue(expr, context, root, asType);
+            Object value = ognlUtil.getValue(expr, context, root, asType);
             if (value != null) {
                 return value;
             } else {

src/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java

 /**
  * Creates an Ognl value stack
  */
-public class OgnlValueStackFactory extends ValueStackFactory {
+public class OgnlValueStackFactory implements ValueStackFactory {
     
     private XWorkConverter xworkConverter;
     private CompoundRootAccessor compoundRootAccessor;
     private TextProvider textProvider;
+    private Container container;
 
     @Inject
     public void setXWorkConverter(XWorkConverter conv) {
         this.textProvider = textProvider;
     }
 
-    @Override
     public ValueStack createValueStack() {
-        return new OgnlValueStack(xworkConverter, compoundRootAccessor, textProvider);
+        ValueStack stack = new OgnlValueStack(xworkConverter, compoundRootAccessor, textProvider);
+        container.inject(stack);
+        return stack;
     }
 
-    @Override
     public ValueStack createValueStack(ValueStack stack) {
-        return new OgnlValueStack(stack, xworkConverter, compoundRootAccessor);
+        ValueStack result = new OgnlValueStack(stack, xworkConverter, compoundRootAccessor);
+        container.inject(result);
+        return result;
     }
     
     @Inject
         if (compoundRootAccessor == null) {
             throw new IllegalStateException("Couldn't find the compound root accessor");
         }
+        this.container = container;
     }
 }

src/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java

     private XWorkConverter xworkConverter;
     private ObjectFactory objectFactory;
     private ObjectTypeDeterminer objectTypeDeterminer;
+    private OgnlUtil ognlUtil;
     
     @Inject
     public void setXWorkConverter(XWorkConverter conv) {
     public void setObjectTypeDeterminer(ObjectTypeDeterminer ot) {
         this.objectTypeDeterminer = ot;
     }
+    
+    @Inject
+    public void setOgnlUtil(OgnlUtil util) {
+        this.ognlUtil = util;
+    }
 
     public Object getProperty(Map context, Object target, Object name)
             throws OgnlException {
                 Object v = values[i];
                 try {
                     Object o = objectFactory.buildBean(convertToClass, context);
-                    OgnlUtil.setValue((String) name, context, o, v);
+                    ognlUtil.setValue((String) name, context, o, v);
                     c.add(o);
                 } catch (Exception e) {
                     throw new OgnlException("Error converting given String values for Collection.", e);

src/java/com/opensymphony/xwork2/ognl/accessor/XWorkMapPropertyAccessor.java

             if (lastClass == null || lastProperty == null) {
                 return super.getProperty(context, target, name);
             }
-            Class keyClass = xworkConverter.getObjectTypeDeterminer()
+            Class keyClass = objectTypeDeterminer
                     .getKeyClass(lastClass, lastProperty);
 
             if (keyClass == null) {

src/java/com/opensymphony/xwork2/util/TextParseUtil.java

  */
 package com.opensymphony.xwork2.util;
 
+import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
+import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.TextUtils;
 
 import java.util.HashSet;
             }
         }
 
-        return XWorkConverter.getInstance().convertValue(stack.getContext(), result, asType);
+        XWorkConverter conv = ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(XWorkConverter.class);
+        return conv.convertValue(stack.getContext(), result, asType);
     }
 
     /**

src/java/com/opensymphony/xwork2/util/ValueStackFactory.java

 /**
  * Factory that creates a value stack, defaulting to the OgnlValueStackFactory
  */
-public abstract class ValueStackFactory {
-
-    /**
-     * Gets the facatory to use for getting instances of {@link com.opensymphony.xwork2.util.ValueStack}
-     *
-     * @return the factory
-     */
-    public static ValueStackFactory getFactory() {
-        return ActionContext.getContext().getInstance(ValueStackFactory.class);
-    }
+public interface ValueStackFactory {
 
     /**
      * Get a new instance of {@link com.opensymphony.xwork2.util.ValueStack}
      *
      * @return  a new {@link com.opensymphony.xwork2.util.ValueStack}.
      */
-    public abstract ValueStack createValueStack();
+    ValueStack createValueStack();
     
     /**
      * Get a new instance of {@link com.opensymphony.xwork2.util.ValueStack}
      * @param stack an existing stack to include.
      * @return  a new {@link com.opensymphony.xwork2.util.ValueStack}.
      */
-    public abstract ValueStack createValueStack(ValueStack stack);
+    ValueStack createValueStack(ValueStack stack);
     
 }

src/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java

 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
+import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
 import com.opensymphony.xwork2.ognl.OgnlValueStack;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
 
 /**
  * Generic test setup methods to be used with any unit testing framework. 
         
         // Reset the value stack
         ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
+        stack.getContext().put(ActionContext.CONTAINER, container);
         ActionContext.setContext(new ActionContext(stack.getContext()));
     
         // clear out localization
             configurationManager = new ConfigurationManager();
         }
         configurationManager.clearConfigurationProviders();
+        configurationManager.addConfigurationProvider(new ConfigurationProvider() {
+            public void destroy() {}
+            public void init(Configuration configuration) throws ConfigurationException {}
+            public void loadPackages() throws ConfigurationException {}
+            public boolean needsReload() { return false; }
+
+            public void register(ContainerBuilder builder,
+                    LocatableProperties props) throws ConfigurationException {
+                builder.setAllowDuplicates(true);
+            }
+            
+        });
+        configurationManager.addConfigurationProvider(new XWorkConfigurationProvider());
         for (ConfigurationProvider prov : providers) {
+            if (prov instanceof XmlConfigurationProvider) {
+                ((XmlConfigurationProvider)prov).setThrowExceptionOnDuplicateBeans(false);
+            }
             configurationManager.addConfigurationProvider(prov);
         }
         configurationManager.getConfiguration().reload(
         
         // Reset the value stack
         ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
+        stack.getContext().put(ActionContext.CONTAINER, container);
         ActionContext.setContext(new ActionContext(stack.getContext()));
         
         return configurationManager;

src/test/com/opensymphony/xwork2/ActionContextTest.java

  *
  * @author Jason Carreira
  */
-public class ActionContextTest extends TestCase {
+public class ActionContextTest extends XWorkTestCase {
 
     private static final String APPLICATION_KEY = "com.opensymphony.xwork2.ActionContextTest.application";
     private static final String SESSION_KEY = "com.opensymphony.xwork2.ActionContextTest.session";
 
     private ActionContext context;
 
-    public void setUp() {
-        ValueStack valueStack = ValueStackFactory.getFactory().createValueStack();
+    public void setUp() throws Exception {
+        super.setUp();
+        ValueStack valueStack = container.getInstance(ValueStackFactory.class).createValueStack();
         Map extraContext = valueStack.getContext();
         Map application = new HashMap();
         application.put(APPLICATION_KEY, APPLICATION_KEY);
         ActionContext.setContext(context);
     }
 
-    public void tearDown() {
-        ActionContext.setContext(null);
-    }
-
     public void testContextParams() {
         assertTrue(ActionContext.getContext().getApplication().containsKey(APPLICATION_KEY));
         assertTrue(ActionContext.getContext().getSession().containsKey(SESSION_KEY));

src/test/com/opensymphony/xwork2/ActionContextThreadLocalTest.java

 
 	
 	public void testGetContext() throws Exception {
-		assertNotNull(ActionContext.getContext());
+		assertNull(ActionContext.getContext());
 	}
 	
 	public void testSetContext() throws Exception {

src/test/com/opensymphony/xwork2/ActionNestingTest.java

         super.setUp();
         loadConfigurationProviders(new NestedTestConfigurationProvider());
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
-
-        // create the action context
-        Map contextMap = stack.getContext();
-
-        // give the value stack a context
-        stack.push(this);
-        context = new ActionContext(contextMap);
-        ActionContext.setContext(context);
+        context = ActionContext.getContext();
+        context.getValueStack().push(this);
     }
 
     protected void tearDown() throws Exception {
         super.tearDown();
-        ActionContext.setContext(null);
     }
 
     public void testNestedContext() throws Exception {
         }
 
         public void register(ContainerBuilder builder, LocatableProperties props) {
-            builder.factory(ObjectFactory.class);
-            builder.factory(ActionProxyFactory.class, DefaultActionProxyFactory.class);
-            builder.factory(ReflectionProvider.class, OgnlReflectionProvider.class);
         }
         
         public void loadPackages() {

src/test/com/opensymphony/xwork2/ActionSupportTest.java

  */
 package com.opensymphony.xwork2;
 
+import java.util.HashMap;
 import java.util.ResourceBundle;
 import java.util.List;
 import java.util.Locale;
         ActionContext.getContext().setLocale(Locale.ITALY);
         assertEquals(Locale.ITALY, as.getLocale());
 
-        ActionContext.setContext(null);
+        ActionContext.setContext(new ActionContext(new HashMap()));
         assertEquals(defLocale, as.getLocale()); // ActionContext will create a new context, when it was set to null before
     }
 
         ActionContext.getContext().setLocale(new Locale("da"));
         MyActionSupport mas = new MyActionSupport();
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
 
         List args = new ArrayList();
         args.add("Santa");
         ActionContext.getContext().setLocale(new Locale("da"));
         MyActionSupport mas = new MyActionSupport();
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
 
         String[] args = { "Santa", "loud" };
         assertEquals("Hello World", mas.getText("hello", "this is default", args, stack)); // no args in bundle

src/test/com/opensymphony/xwork2/ChainResultTest.java

         values.put("actionName", expectedActionName);
         values.put("namespace", expectedNamespace);
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(values);
 
         Mock actionProxyMock = new Mock(ActionProxy.class);

src/test/com/opensymphony/xwork2/LocaleAwareTest.java

     protected void setUp() throws Exception {
         loadConfigurationProviders(new XmlConfigurationProvider("xwork-test-beans.xml"), new MockConfigurationProvider());
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
+        stack.getContext().put(ActionContext.CONTAINER, container);
         ActionContext.setContext(new ActionContext(stack.getContext()));
     }
 }

src/test/com/opensymphony/xwork2/ProxyInvocationTest.java

         super.setUp();
 
         // ensure we're using the default configuration, not simple config
-        loadWithOverriding(new XmlConfigurationProvider("xwork-proxyinvoke.xml"));
+        loadConfigurationProviders(new XmlConfigurationProvider("xwork-proxyinvoke.xml"));
     }
 }

src/test/com/opensymphony/xwork2/config/ConfigurationManagerTest.java

 
 import com.mockobjects.dynamic.C;
 import com.mockobjects.dynamic.Mock;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.util.FileManager;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
         configurationManager.destroyConfiguration();
 
         configProviderMock = new Mock(ConfigurationProvider.class);
+        configProviderMock.matchAndReturn("equals", C.ANY_ARGS, false);
 
         ConfigurationProvider mockProvider = (ConfigurationProvider) configProviderMock.proxy();
+        configurationManager.addConfigurationProvider(new XWorkConfigurationProvider());
         configurationManager.addConfigurationProvider(mockProvider);
         
         //the first time it always inits
         configProviderMock.expect("register", C.ANY_ARGS);
         configProviderMock.expect("loadPackages", C.ANY_ARGS);
         configProviderMock.matchAndReturn("toString", "mock");
+        
         configurationManager.getConfiguration();
     }
 

src/test/com/opensymphony/xwork2/config/providers/ConfigurationTestBase.java

         container = configuration.getContainer();
         
         XmlConfigurationProvider prov = new XmlConfigurationProvider(filename, true);
-        prov.setObjectFactory(new ObjectFactory(new OgnlReflectionProvider()));
+        prov.setObjectFactory(container.getInstance(ObjectFactory.class));
         prov.init(configuration);
         prov.loadPackages();
         return prov;

src/test/com/opensymphony/xwork2/config/providers/MockConfigurationProvider.java

     public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
         if (params != null) {
             for (String key : params.keySet()) {
-                builder.constant(key, params.get(key));
+                props.setProperty(key, params.get(key));
             }
         }
     }

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

     private List exceptionMappings;
     private Map params;
     private Map results;
+    private ObjectFactory objectFactory;
 
 
     public void testActions() throws Exception {
         final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions.xml";
         ConfigurationProvider provider = buildConfigurationProvider(filename);
-        ObjectFactory objectFactory = ObjectFactory.getObjectFactory();
 
         // setup expectations
         // bar action is very simple, just two params
         results = new HashMap();
         interceptors = new ArrayList();
         exceptionMappings = new ArrayList();
+        this.objectFactory = container.getInstance(ObjectFactory.class);
     }
 }

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderGlobalResultInheritenceTest.java

         ConfigurationProvider provider = buildConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml");
 
         ConfigurationManager configurationManager = new ConfigurationManager();
+        configurationManager.addConfigurationProvider(new XWorkConfigurationProvider());
         configurationManager.addConfigurationProvider(provider);
         Configuration configuration = configurationManager.getConfiguration();
 

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java

 import java.util.ArrayList;
 import java.util.List;
 
+import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.RuntimeConfiguration;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
  * @author tm_jee
  * @version $Date$ $Id$
  */
-public class XmlConfigurationProviderInterceptorParamOverridingTest extends TestCase {
+public class XmlConfigurationProviderInterceptorParamOverridingTest extends XWorkTestCase {
 
 	public void testParamOveriding() throws Exception {
 		DefaultConfiguration conf = new DefaultConfiguration();
 		final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml");
 		conf.reload(new ArrayList<ConfigurationProvider>(){
 			{
+			    add(new XWorkConfigurationProvider());
 				add(p);
 			}
 		});

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorsSpringTest.java

 public class XmlConfigurationProviderInterceptorsSpringTest extends ConfigurationTestBase {
 
     InterceptorConfig timerInterceptor = new InterceptorConfig("timer", TimerInterceptor.class, new HashMap());
-    ObjectFactory objectFactory = ObjectFactory.getObjectFactory();
+    ObjectFactory objectFactory;
     StaticApplicationContext sac;
 
 
         //objFactory.setApplicationContext(sac);
         //ObjectFactory.setObjectFactory(objFactory);
 
-        configurationManager.destroyConfiguration();
+        objectFactory = container.getInstance(ObjectFactory.class);
     }
 }

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

     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 = new ObjectFactory();
+    ObjectFactory objectFactory;
+    
+    public void setUp() throws Exception {
+        super.setUp();
+        objectFactory = container.getInstance(ObjectFactory.class);
+    }
 
 
     public void testBasicInterceptors() throws ConfigurationException {
     }
 
     public void testInterceptorDefaultRefs() throws ConfigurationException {
-        ConfigurationProvider provider = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml");
-        configurationManager.clearConfigurationProviders();
-        configurationManager.addConfigurationProvider(provider);
+        loadConfigurationProviders(new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml"));
 
         // expectations - the inherited interceptor stack
         // default package

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderPackagesTest.java

         assertTrue(multipleParents.contains(singlePackage));
 
         configurationManager.addConfigurationProvider(provider);
+        configurationManager.reload();
 
         RuntimeConfiguration runtimeConfiguration = configurationManager.getConfiguration().getRuntimeConfiguration();
         assertNotNull(runtimeConfiguration.getActionConfig("/multiple", "default"));

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java

         assertEquals(namespace4, namespace5.getParents().get(0));
 
         configurationManager.addConfigurationProvider(provider);
+        configurationManager.reload();
 
         RuntimeConfiguration runtimeConfiguration = configurationManager.getConfiguration().getRuntimeConfiguration();
         assertNotNull(runtimeConfiguration.getActionConfig("/namespace1", "action1"));

src/test/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml

  >
 
 <xwork>
-	<include file="xwork-test-beans.xml" />
     <!-- this package has a default interceptor ref - so actions with no refs should have the default ref -->
     <package name="default">
         <interceptors>

src/test/com/opensymphony/xwork2/conversion/impl/AnnotationXWorkConverterTest.java

         SimpleAnnotationAction action = new SimpleAnnotationAction();
         action.setBean(new AnnotatedTestBean());
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(action);
 
         Map ognlStackContext = stack.getContext();
         SimpleAnnotationAction action = new SimpleAnnotationAction();
         action.setDate(null);
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(action);
 
         Map ognlStackContext = stack.getContext();
 
     public void testFieldErrorMessageAddedWhenConversionFailsOnModelDriven() {
         ModelDrivenAnnotationAction action = new ModelDrivenAnnotationAction();
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(action);
         stack.push(action.getModel());
 
 
     public void testFindConversionErrorMessage() {
         ModelDrivenAnnotationAction action = new ModelDrivenAnnotationAction();
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(action);
         stack.push(action.getModel());
 
 
     public void testFindConversionMappingForInterface() {
         ModelDrivenAnnotationAction2 action = new ModelDrivenAnnotationAction2();
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(action);
         stack.push(action.getModel());
 
 
     // TODO: Fixme... This test does not work with GenericsObjectDeterminer!
     public void testStringToCollectionConversion() {
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         Map stackContext = stack.getContext();
         stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
         stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
     }
 
     public void testValueStackWithTypeParameter() {
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        ValueStack stack = ActionContext.getContext().getValueStack();
         stack.push(new Foo1());
         Bar1 bar = (Bar1) stack.findValue("bar", Bar1.class);
         assertNotNull(bar);
         super.setUp();
         converter = container.getInstance(XWorkConverter.class);
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
-        ac = new ActionContext(stack.getContext());
+        ac = ActionContext.getContext();
         ac.setLocale(Locale.US);
-        ActionContext.setContext(ac);
         context = ac.getContextMap();
     }
 

src/test/com/opensymphony/xwork2/conversion/impl/ObjectTypeDeterminerFactoryTest.java

-package com.opensymphony.xwork2.conversion.impl;
-
-import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
-import com.opensymphony.xwork2.conversion.ObjectTypeDeterminerFactory;
-import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer;
-
-import junit.framework.*;
-
-/**
- * ObjectTypeDeterminerFactoryTest test for given class.
- *
- * @author Rene Gielen
- */
-public class ObjectTypeDeterminerFactoryTest extends TestCase {
-
-
-    public void testDefaultInstanceTypeIsDefaultObjectTypeDeterminer() throws Exception {
-        assertEquals(ObjectTypeDeterminerFactory.getInstance().getClass(),DefaultObjectTypeDeterminer.class);
-    }
-
-    public void testSetInstance() throws Exception {
-        ObjectTypeDeterminer objectTypeDeterminer = ObjectTypeDeterminerFactory.getInstance();
-        try {
-            ObjectTypeDeterminerFactory.setInstance(null);
-            assertEquals(ObjectTypeDeterminerFactory.getInstance(), objectTypeDeterminer);
-            ObjectTypeDeterminerFactory.setInstance(new DefaultObjectTypeDeterminer());
-            assertTrue(ObjectTypeDeterminerFactory.getInstance().getClass().equals(objectTypeDeterminer.getClass()));
-        } finally {
-            ObjectTypeDeterminerFactory.setInstance(objectTypeDeterminer);
-        }
-    }
-}

src/test/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java

 
     Map context;
     XWorkConverter converter;
+    OgnlValueStack stack;
 
 //    public void testConversionToSetKeepsOriginalSetAndReplacesContents() {
 //        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         SimpleAction action = new SimpleAction();
         action.setBean(new TestBean());
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(action);
 
         Map ognlStackContext = stack.getContext();
         SimpleAction action = new SimpleAction();
         action.setDate(null);
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(action);
 
         Map ognlStackContext = stack.getContext();
 
     public void testFieldErrorMessageAddedWhenConversionFailsOnModelDriven() {
         ModelDrivenAction action = new ModelDrivenAction();
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(action);
         stack.push(action.getModel());
 
 
     public void testFindConversionErrorMessage() {
         ModelDrivenAction action = new ModelDrivenAction();
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(action);
         stack.push(action.getModel());
 
 
     public void testFindConversionMappingForInterface() {
         ModelDrivenAction2 action = new ModelDrivenAction2();
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(action);
         stack.push(action.getModel());
 
         SimpleAction action = new SimpleAction();
         action.setBean(new TestBean());
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(action);
 
         Map ognlStackContext = stack.getContext();
     }
 
     public void testStringToCollectionConversion() {
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         Map stackContext = stack.getContext();
         stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
         stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
     }
 
     public void testValueStackWithTypeParameter() {
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
         stack.push(new Foo1());
         Bar1 bar = (Bar1) stack.findValue("bar", Bar1.class);
         assertNotNull(bar);
     }
 
     public void testNestedConverters() {
-        OgnlValueStack stack = new OgnlValueStack();
         Cat cat = new Cat();
         cat.setFoo(new Foo());
         stack.push(cat);
     }
 
     protected void setUp() throws Exception {
-        ObjectFactory.setObjectFactory(new ObjectFactory(new OgnlReflectionProvider()));
+        super.setUp();
 
-        configurationManager = new ConfigurationManager();
-        converter = XWorkConverter.getInstance();
-        configurationManager.destroyConfiguration();
+        converter = container.getInstance(XWorkConverter.class);
 
-        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
-        ActionContext ac = new ActionContext(stack.getContext());
+        ActionContext ac = ActionContext.getContext();
         ac.setLocale(Locale.US);
-        ActionContext.setContext(ac);
         context = ac.getContextMap();
+        stack = (OgnlValueStack) ac.getValueStack();
     }
 
-    protected void tearDown() throws Exception {
-        ActionContext.setContext(null);
-    }
 }

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

  *
  * @author Jason Carreira
  */
-public class ChainingInterceptorTest extends TestCase {
+public class ChainingInterceptorTest extends XWorkTestCase {
 
     ActionInvocation invocation;
     ChainingInterceptor interceptor;
 
     protected void setUp() throws Exception {
         super.setUp();
-        stack = ValueStackFactory.getFactory().createValueStack();
+        stack = ActionContext.getContext().getValueStack();
         mockInvocation = new Mock(ActionInvocation.class);
         mockInvocation.expectAndReturn("getStack", stack);
         mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
         mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap()));
         invocation = (ActionInvocation) mockInvocation.proxy();
         interceptor = new ChainingInterceptor();
+        container.inject(interceptor);
     }
 
 

src/test/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptorTest.java

         interceptor = new ConversionErrorInterceptor();
         mockInvocation = new Mock(ActionInvocation.class);
         invocation = (ActionInvocation) mockInvocation.proxy();
-        stack = ValueStackFactory.getFactory().createValueStack();
+        stack = ActionContext.getContext().getValueStack();
         context = new ActionContext(stack.getContext());
         conversionErrors = new HashMap();
         context.setConversionErrors(conversionErrors);

src/test/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java

  * 
  * @author Matthew E. Porter (matthew dot porter at metissian dot com)
  */
-public class ExceptionMappingInterceptorTest extends TestCase {
+public class ExceptionMappingInterceptorTest extends XWorkTestCase {
 
     ActionInvocation invocation;
     ExceptionMappingInterceptor interceptor;
 
     protected void setUp() throws Exception {
         super.setUp();
-        stack = ValueStackFactory.getFactory().createValueStack();
+        stack = ActionContext.getContext().getValueStack();
         mockInvocation = new Mock(ActionInvocation.class);
         mockInvocation.expectAndReturn("getStack", stack);
         mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap()));