Commits

Anonymous committed d84da54

Starting work on embedded container

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

  • Participants
  • Parent commits ad3922f
  • Branches no-statics

Comments (0)

Files changed (4)

src/java/com/opensymphony/xwork2/config/ConfigurationManager.java

 
 import com.opensymphony.xwork2.util.FileManager;
 import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
         providerLock.lock();
         try {
             if (configurationProviders.size() == 0) {
-                configurationProviders.add(new XmlConfigurationProvider("xwork-default.xml", true));
+                configurationProviders.add(new XWorkConfigurationProvider());
                 configurationProviders.add(new XmlConfigurationProvider("xwork.xml", false));
             }
 

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

+package com.opensymphony.xwork2.config.providers;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.DefaultActionProxyFactory;
+import com.opensymphony.xwork2.DefaultTextProvider;
+import com.opensymphony.xwork2.TextProvider;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.conversion.NullHandler;
+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.XWorkConverter;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
+import com.opensymphony.xwork2.util.reflection.ReflectionContextFactory;
+import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
+
+import ognl.MethodAccessor;
+import ognl.PropertyAccessor;
+import com.opensymphony.xwork2.util.CompoundRoot;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import com.opensymphony.xwork2.validator.AnnotationActionValidatorManager;
+import com.opensymphony.xwork2.validator.DefaultActionValidatorManager;
+import com.opensymphony.xwork2.ognl.ObjectProxy;
+import com.opensymphony.xwork2.ognl.OgnlReflectionContextFactory;
+import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
+import com.opensymphony.xwork2.ognl.OgnlValueStackFactory;
+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;
+
+public class XWorkConfigurationProvider implements 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.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());
+    }
+
+}

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

+/**
+ * 
+ */
+package com.opensymphony.xwork2.ognl.accessor;
+
+import java.util.Map;
+
+import ognl.ObjectPropertyAccessor;
+import ognl.OgnlException;
+
+import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
+import com.opensymphony.xwork2.ognl.OgnlValueStack;
+import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
+
+public class ObjectAccessor extends ObjectPropertyAccessor {
+    public Object getProperty(Map map, Object o, Object o1) throws OgnlException {
+        Object obj = super.getProperty(map, o, o1);
+        OgnlValueStack.link(map, o.getClass(), (String) o1);
+
+        map.put(XWorkConverter.LAST_BEAN_CLASS_ACCESSED, o.getClass());
+        map.put(XWorkConverter.LAST_BEAN_PROPERTY_ACCESSED, o1.toString());
+        ReflectionContextState.updateCurrentPropertyPath(map, o1);
+        return obj;
+    }
+
+    public void setProperty(Map map, Object o, Object o1, Object o2) throws OgnlException {
+        super.setProperty(map, o, o1, o2);
+    }
+}

src/java/xwork-default.xml

 <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 2.0//EN" "http://www.opensymphony.com/xwork/xwork-2.0.dtd">
 
 <xwork>
-
-    <bean class="com.opensymphony.xwork2.ObjectFactory"/>
-    <bean type="com.opensymphony.xwork2.ActionProxyFactory"
-          class="com.opensymphony.xwork2.DefaultActionProxyFactory"/>
-    <bean type="com.opensymphony.xwork2.conversion.ObjectTypeDeterminer"
-          class="com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer"/>
-    <bean name="xwork1"
-          type="com.opensymphony.xwork2.conversion.ObjectTypeDeterminer"
-          class="com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer"/>
-    <bean name="xwork1"
-          type="com.opensymphony.xwork2.conversion.impl.XWorkConverter"
-          class="com.opensymphony.xwork2.conversion.impl.XWorkConverter"/>
-    <bean type="com.opensymphony.xwork2.conversion.impl.XWorkConverter"
-          class="com.opensymphony.xwork2.conversion.impl.XWorkConverter"/>
-          
-    <bean name="default"
-    	  type="com.opensymphony.xwork2.util.ValueStackFactory"
-    	  class="com.opensymphony.xwork2.ognl.OgnlValueStackFactory" />
-    <bean name="default"
-          type="com.opensymphony.xwork2.util.reflection.ReflectionProvider"
-          class="com.opensymphony.xwork2.ognl.OgnlReflectionProvider" />
-    <bean name="default"
-          type="com.opensymphony.xwork2.util.reflection.ReflectionContextFactory"
-          class="com.opensymphony.xwork2.ognl.OgnlReflectionContextFactory" />
-    
-    <bean name="com.opensymphony.xwork2.util.CompoundRoot" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor" />
-    <bean name="java.lang.Object" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.ObjectAccessor" />
-    <bean name="java.util.Iterator" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkIteratorPropertyAccessor" />
-    <bean name="java.util.Enumeration" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkEnumerationAcccessor" />
-    <bean name="java.util.List" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkListPropertyAccessor" />
-    <bean name="java.util.Map" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor" />
-    <bean name="java.util.Collection" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
-    <bean name="java.util.Set" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
-    <bean name="com.opensymphony.xwork2.ognl.ObjectProxy" type="ognl.PropertyAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.ObjectProxyPropertyAccessor" />
-    	  
- 	<bean name="java.lang.Object" type="ognl.MethodAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor" />
-  	<bean name="com.opensymphony.xwork2.util.CompoundRoot" type="ognl.MethodAccessor"
-    	  class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor" />
-    	  
-  	<bean name="java.lang.Object" type="com.opensymphony.xwork2.conversion.NullHandler"
-    	  class="com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler" />
-    	  
- 	<bean name="no-annotations" type="com.opensymphony.xwork2.validator.ActionValidatorManager"
- 		  class="com.opensymphony.xwork2.validator.DefaultActionValidatorManager" />
- 		  
-    <bean type="com.opensymphony.xwork2.validator.ActionValidatorManager"
- 		  class="com.opensymphony.xwork2.validator.AnnotationActionValidatorManager" />
- 		  
-    <bean type="com.opensymphony.xwork2.TextProvider"
-    	  class="com.opensymphony.xwork2.DefaultTextProvider" />
-   	
-    <constant name="devMode" value="false" />
-
     <package name="xwork-default" abstract="true">
 
         <!-- START SNIPPET: xwork2-default-result-types -->