You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2011/12/02 17:33:45 UTC

svn commit: r1209569 [14/50] - in /struts/struts2/branches/STRUTS_3_X: apps/blank/src/main/java/example/ apps/blank/src/test/java/example/ apps/jboss-blank/src/main/java/example/ apps/jboss-blank/src/test/java/example/ apps/mailreader/src/main/java/mai...

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/DefaultUnknownHandlerManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/DefaultUnknownHandlerManager.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/DefaultUnknownHandlerManager.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/DefaultUnknownHandlerManager.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.xwork2.config.Configuration;
+import org.apache.struts2.xwork2.config.entities.ActionConfig;
+import org.apache.struts2.xwork2.config.entities.UnknownHandlerConfig;
+import org.apache.struts2.xwork2.inject.Container;
+import org.apache.struts2.xwork2.inject.Inject;
+
+/**
+ * Default implementation of UnknownHandlerManager
+ *
+ * @see UnknownHandlerManager
+ */
+public class DefaultUnknownHandlerManager implements UnknownHandlerManager {
+    protected ArrayList<UnknownHandler> unknownHandlers;
+    private Configuration configuration;
+    private Container container;
+
+    @Inject
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
+        build();
+    }
+
+    @Inject
+    public void setContainer(Container container) {
+        this.container = container;
+        build();
+    }
+
+    /**
+     * Builds a list of UnknowHandlers in the order specified by the configured "unknown-handler-stack".
+     * If "unknown-handler-stack" was not configured, all UnknowHandlers will be returned, in no specific order
+     */
+    protected void build() {
+        if (configuration != null && container != null) {
+            List<UnknownHandlerConfig> unkownHandlerStack = configuration.getUnknownHandlerStack();
+            unknownHandlers = new ArrayList<UnknownHandler>();
+
+            if (unkownHandlerStack != null && !unkownHandlerStack.isEmpty()) {
+                //get UnknownHandlers in the specified order
+                for (UnknownHandlerConfig unknownHandlerConfig : unkownHandlerStack) {
+                    UnknownHandler uh = container.getInstance(UnknownHandler.class, unknownHandlerConfig.getName());
+                    unknownHandlers.add(uh);
+                }
+            } else {
+                //add all available UnknownHandlers
+                Set<String> unknowHandlerNames = container.getInstanceNames(UnknownHandler.class);
+                if (unknowHandlerNames != null) {
+                    for (String unknowHandlerName : unknowHandlerNames) {
+                        UnknownHandler uh = container.getInstance(UnknownHandler.class, unknowHandlerName);
+                        unknownHandlers.add(uh);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Iterate over UnknownHandlers and return the result of the first one that can handle it
+     */
+    public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) {
+        for (UnknownHandler unknownHandler : unknownHandlers) {
+            Result result = unknownHandler.handleUnknownResult(actionContext, actionName, actionConfig, resultCode);
+            if (result != null)
+                return result;
+        }
+
+        return null;
+    }
+
+    /**
+     * Iterate over UnknownHandlers and return the result of the first one that can handle it
+     *
+     * @throws NoSuchMethodException
+     */
+    public Object handleUnknownMethod(Object action, String methodName) throws NoSuchMethodException {
+        for (UnknownHandler unknownHandler : unknownHandlers) {
+            Object result = unknownHandler.handleUnknownActionMethod(action, methodName);
+            if (result != null)
+                return result;
+        }
+
+        return null;
+    }
+
+    /**
+     * Iterate over UnknownHandlers and return the result of the first one that can handle it
+     *
+     * @throws NoSuchMethodException
+     */
+    public ActionConfig handleUnknownAction(String namespace, String actionName) {
+        for (UnknownHandler unknownHandler : unknownHandlers) {
+            ActionConfig result = unknownHandler.handleUnknownAction(namespace, actionName);
+            if (result != null)
+                return result;
+        }
+
+        return null;
+    }
+
+    public boolean hasUnknownHandlers() {
+        return unknownHandlers != null && !unknownHandlers.isEmpty();
+    }
+
+    public List<UnknownHandler> getUnknownHandlers() {
+        return unknownHandlers;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/InvalidMetadataException.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/InvalidMetadataException.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/InvalidMetadataException.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/InvalidMetadataException.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+/**
+ * <code>InvalidMetadataException</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: InvalidMetadataException.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class InvalidMetadataException extends RuntimeException {
+
+    /**
+	 * Create a new <code>InvalidMetadataException</code> with the supplied error message.
+     * 
+	 * @param msg the error message
+	 */
+	public InvalidMetadataException(String msg) {
+		super(msg);
+	}
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/LocaleProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/LocaleProvider.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/LocaleProvider.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/LocaleProvider.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import java.util.Locale;
+
+
+/**
+ * Indicates that the implementing class can provide its own {@link Locale}.
+ * <p/>
+ * This is useful for when an action may wish override the default locale. All that is
+ * needed is to implement this interface and return your own custom locale.
+ * The {@link TextProvider} interface uses this interface heavily for retrieving
+ * internationalized messages from resource bundles.
+ *
+ * @author Jason Carreira
+ */
+public interface LocaleProvider {
+
+    /**
+     * Gets the provided locale.
+     *
+     * @return  the locale.
+     */
+    Locale getLocale();
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/MockActionInvocation.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/MockActionInvocation.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/MockActionInvocation.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/MockActionInvocation.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.struts2.xwork2;
+
+/**
+ * Mock for an {@link ActionInvocation}.
+ *
+ * @author plightbo
+ * @deprecated Please use @see org.apache.struts2.xwork2.mock.MockActionInvocation instead
+ */
+@Deprecated public class MockActionInvocation extends org.apache.struts2.xwork2.mock.MockActionInvocation {
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ModelDriven.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ModelDriven.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ModelDriven.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ModelDriven.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+
+/**
+ * ModelDriven Actions provide a model object to be pushed onto the ValueStack
+ * in addition to the Action itself, allowing a FormBean type approach like Struts.
+ *
+ * @author Jason Carreira
+ */
+public interface ModelDriven<T> {
+
+    /**
+     * Gets the model to be pushed onto the ValueStack instead of the Action itself.
+     *
+     * @return the model
+     */
+    T getModel();
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ObjectFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ObjectFactory.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ObjectFactory.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ObjectFactory.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.config.ConfigurationException;
+import org.apache.struts2.xwork2.config.entities.ActionConfig;
+import org.apache.struts2.xwork2.config.entities.InterceptorConfig;
+import org.apache.struts2.xwork2.config.entities.ResultConfig;
+import org.apache.struts2.xwork2.inject.Container;
+import org.apache.struts2.xwork2.inject.Inject;
+import org.apache.struts2.xwork2.interceptor.Interceptor;
+import org.apache.struts2.xwork2.util.ClassLoaderUtil;
+import org.apache.struts2.xwork2.util.logging.Logger;
+import org.apache.struts2.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.xwork2.util.reflection.ReflectionException;
+import org.apache.struts2.xwork2.util.reflection.ReflectionExceptionHandler;
+import org.apache.struts2.xwork2.util.reflection.ReflectionProvider;
+import org.apache.struts2.xwork2.validator.Validator;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * ObjectFactory is responsible for building the core framework objects. Users may register their 
+ * own implementation of the ObjectFactory to control instantiation of these Objects.
+ * <p/>
+ * This default implementation uses the {@link #buildBean(Class,java.util.Map) buildBean} 
+ * method to create all classes (interceptors, actions, results, etc).
+ * <p/>
+ *
+ * @author Jason Carreira
+ */
+public class ObjectFactory implements Serializable {
+    private static final Logger LOG = LoggerFactory.getLogger(ObjectFactory.class);
+
+    private transient ClassLoader ccl;
+    private Container container;
+    protected ReflectionProvider reflectionProvider;
+
+    @Inject(value="objectFactory.classloader", required=false)
+    public void setClassLoader(ClassLoader cl) {
+        this.ccl = cl;
+    }
+    
+    @Inject
+    public void setReflectionProvider(ReflectionProvider prov) {
+        this.reflectionProvider = prov;
+    }
+
+    public ObjectFactory() {
+    }
+    
+    public ObjectFactory(ReflectionProvider prov) {
+        this.reflectionProvider = prov;
+    }
+    
+    @Inject
+    public void setContainer(Container container) {
+        this.container = container;
+    }
+
+    /**
+     * @deprecated Since 2.1
+     */
+    @Deprecated public static ObjectFactory getObjectFactory() {
+        return ActionContext.getContext().getContainer().getInstance(ObjectFactory.class);
+    }
+
+    /**
+     * Allows for ObjectFactory implementations that support
+     * Actions without no-arg constructors.
+     *
+     * @return true if no-arg constructor is required, false otherwise
+     */
+    public boolean isNoArgConstructorRequired() {
+        return true;
+    }
+
+    /**
+     * Utility method to obtain the class matched to className. Caches look ups so that subsequent
+     * lookups will be faster.
+     *
+     * @param className The fully qualified name of the class to return
+     * @return The class itself
+     * @throws ClassNotFoundException
+     */
+    public Class getClassInstance(String className) throws ClassNotFoundException {
+        if (ccl != null) {
+            return ccl.loadClass(className);
+        }
+
+        return ClassLoaderUtil.loadClass(className, this.getClass());
+    }
+
+    /**
+     * Build an instance of the action class to handle a particular request (eg. web request)
+     * @param actionName the name the action configuration is set up with in the configuration
+     * @param namespace the namespace the action is configured in
+     * @param config the action configuration found in the config for the actionName / namespace
+     * @param extraContext a Map of extra context which uses the same keys as the {@link ActionContext}
+     * @return instance of the action class to handle a web request
+     * @throws Exception
+     */
+    public Object buildAction(String actionName, String namespace, ActionConfig config, Map<String, Object> extraContext) throws Exception {
+        return buildBean(config.getClassName(), extraContext);
+    }
+
+    /**
+     * Build a generic Java object of the given type.
+     *
+     * @param clazz the type of Object to build
+     * @param extraContext a Map of extra context which uses the same keys as the {@link ActionContext}
+     */
+    public Object buildBean(Class clazz, Map<String, Object> extraContext) throws Exception {
+        return clazz.newInstance();
+    }
+
+    /**
+     * @param obj
+     */
+    protected Object injectInternalBeans(Object obj) {
+        if (obj != null && container != null) {
+            container.inject(obj);
+        }
+        return obj;
+    }
+
+    /**
+     * Build a generic Java object of the given type.
+     *
+     * @param className the type of Object to build
+     * @param extraContext a Map of extra context which uses the same keys as the {@link ActionContext}
+     */
+    public Object buildBean(String className, Map<String, Object> extraContext) throws Exception {
+        return buildBean(className, extraContext, true);
+    }
+    
+    /**
+     * Build a generic Java object of the given type.
+     *
+     * @param className the type of Object to build
+     * @param extraContext a Map of extra context which uses the same keys as the {@link ActionContext}
+     */
+    public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception {
+        Class clazz = getClassInstance(className);
+        Object obj = buildBean(clazz, extraContext);
+        if (injectInternal) {
+            injectInternalBeans(obj);
+        }
+        return obj;
+    }
+
+    /**
+     * 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<String, String> interceptorRefParams) throws ConfigurationException {
+        String interceptorClassName = interceptorConfig.getClassName();
+        Map<String, String> thisInterceptorClassParams = interceptorConfig.getParams();
+        Map<String, String> params = (thisInterceptorClassParams == null) ? new HashMap<String, String>() : new HashMap<String, String>(thisInterceptorClassParams);
+        params.putAll(interceptorRefParams);
+
+        String message;
+        Throwable cause;
+
+        try {
+            // interceptor instances are long-lived and used across user sessions, so don't try to pass in any extra context
+            Interceptor interceptor = (Interceptor) buildBean(interceptorClassName, null);
+            reflectionProvider.setProperties(params, interceptor);
+            interceptor.init();
+
+            return interceptor;
+        } catch (InstantiationException e) {
+            cause = e;
+            message = "Unable to instantiate an instance of Interceptor class [" + interceptorClassName + "].";
+        } catch (IllegalAccessException e) {
+            cause = e;
+            message = "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + interceptorClassName + "].";
+        } catch (ClassCastException e) {
+            cause = e;
+            message = "Class [" + interceptorClassName + "] does not implement org.apache.struts2.xwork2.interceptor.Interceptor";
+        } catch (Exception e) {
+            cause = e;
+            message = "Caught Exception while registering Interceptor class " + interceptorClassName;
+        } catch (NoClassDefFoundError e) {
+            cause = e;
+            message = "Could not load class " + interceptorClassName + ". Perhaps it exists but certain dependencies are not available?";
+        }
+
+        throw new ConfigurationException(message, cause, interceptorConfig);
+    }
+
+    /**
+     * Build a Result using the type in the ResultConfig and set the parameters in the ResultConfig.
+     *
+     * @param resultConfig the ResultConfig found for the action with the result code returned
+     * @param extraContext a Map of extra context which uses the same keys as the {@link ActionContext}
+     */
+    public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception {
+        String resultClassName = resultConfig.getClassName();
+        Result result = null;
+
+        if (resultClassName != null) {
+            result = (Result) buildBean(resultClassName, extraContext);
+            Map<String, String> params = resultConfig.getParams();
+            if (params != null) {
+                for (Map.Entry<String, String> paramEntry : params.entrySet()) {
+                    try {
+                        reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true);
+                    } catch (ReflectionException ex) {
+                        if (result instanceof ReflectionExceptionHandler) {
+                            ((ReflectionExceptionHandler) result).handle(ex);
+                        }
+                    }
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Build a Validator of the given type and set the parameters on it
+     *
+     * @param className the type of Validator to build
+     * @param params    property name -> value Map to set onto the Validator instance
+     * @param extraContext a Map of extra context which uses the same keys as the {@link ActionContext}
+     */
+    public Validator buildValidator(String className, Map<String, String> params, Map<String, Object> extraContext) throws Exception {
+        Validator validator = (Validator) buildBean(className, null);
+        reflectionProvider.setProperties(params, validator);
+
+        return validator;
+    }
+
+    static class ContinuationsClassLoader extends ClassLoader {
+        
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Preparable.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Preparable.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Preparable.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Preparable.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+
+/**
+ * Preparable Actions will have their <code>prepare()</code> method called if the {@link org.apache.struts2.xwork2.interceptor.PrepareInterceptor}
+ * is applied to the ActionConfig.
+ *
+ * @author Jason Carreira
+ * @see org.apache.struts2.xwork2.interceptor.PrepareInterceptor
+ */
+public interface Preparable {
+
+    /**
+     * This method is called to allow the action to prepare itself.
+     *
+     * @throws Exception thrown if a system level exception occurs.
+     */
+    void prepare() throws Exception;
+    
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ResourceBundleTextProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ResourceBundleTextProvider.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ResourceBundleTextProvider.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ResourceBundleTextProvider.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import java.util.ResourceBundle;
+
+/**
+ * Extension Interface for TextProvider to help supporting ResourceBundles.
+ *
+ * @author Rene Gielen
+ */
+public interface ResourceBundleTextProvider extends TextProvider {
+
+    /**
+     * Set the resource bundle to use.
+     *
+     * @param bundle the bundle to use.
+     */
+    void setBundle(ResourceBundle bundle);
+
+    /**
+     * Set the class to use for reading the resource bundle.
+     *
+     * @param clazz the class to use for loading.
+     */
+    void setClazz(Class clazz);
+
+    /**
+     * Set the LocaleProvider to use.
+     *
+     * @param localeProvider the LocaleProvider to use.
+     */
+    void setLocaleProvider(LocaleProvider localeProvider);
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Result.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Result.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Result.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Result.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import java.io.Serializable;
+
+
+/**
+ * All results (except for <code>Action.NONE</code>) of an {@link Action} are mapped to a View implementation.
+ * <p/>
+ * Examples of Views might be:
+ * <ul>
+ * <li>SwingPanelView - pops up a new Swing panel</li>
+ * <li>ActionChainView - executes another action</li>
+ * <li>SerlvetRedirectView - redirects the HTTP response to a URL</li>
+ * <li>ServletDispatcherView - dispatches the HTTP response to a URL</li>
+ * </ul>
+ *
+ * @author plightbo
+ */
+public interface Result extends Serializable {
+
+    /**
+     * Represents a generic interface for all action execution results.
+     * Whether that be displaying a webpage, generating an email, sending a JMS message, etc.
+     *
+     * @param invocation  the invocation context.
+     * @throws Exception can be thrown.
+     */
+    public void execute(ActionInvocation invocation) throws Exception;
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TestNGXWorkTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TestNGXWorkTestCase.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TestNGXWorkTestCase.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TestNGXWorkTestCase.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.config.Configuration;
+import org.apache.struts2.xwork2.config.ConfigurationManager;
+import org.apache.struts2.xwork2.config.ConfigurationProvider;
+import org.apache.struts2.xwork2.config.impl.MockConfiguration;
+import org.apache.struts2.xwork2.inject.Container;
+import org.apache.struts2.xwork2.util.XWorkTestCaseHelper;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+
+/**
+ * Base test class for TestNG unit tests.  Provides common XWork variables
+ * and performs XWork setup and teardown processes
+ */
+public class TestNGXWorkTestCase {
+
+    protected ConfigurationManager configurationManager;
+    protected Configuration configuration;
+    protected Container container;
+    protected ActionProxyFactory actionProxyFactory;
+
+    @BeforeTest
+    protected void setUp() throws Exception {
+        configurationManager = XWorkTestCaseHelper.setUp();
+        configuration = new MockConfiguration();
+        ((MockConfiguration) configuration).selfRegister();
+        container = configuration.getContainer();
+        actionProxyFactory = container.getInstance(ActionProxyFactory.class);
+    }
+
+    @AfterTest
+    protected void tearDown() throws Exception {
+        XWorkTestCaseHelper.tearDown(configurationManager);
+        configurationManager = null;
+        configuration = null;
+        container = null;
+        actionProxyFactory = null;
+    }
+
+    protected void loadConfigurationProviders(ConfigurationProvider... providers) {
+        configurationManager = XWorkTestCaseHelper.loadConfigurationProviders(configurationManager, providers);
+        configuration = configurationManager.getConfiguration();
+        container = configuration.getContainer();
+        actionProxyFactory = container.getInstance(ActionProxyFactory.class);
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProvider.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProvider.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProvider.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.util.ValueStack;
+
+import java.util.List;
+import java.util.ResourceBundle;
+
+
+/**
+ * Provides access to {@link ResourceBundle}s and their underlying text messages.
+ * Implementing classes can delegate {@link TextProviderSupport}. Messages will be
+ * searched in multiple resource bundles, startinag with the one associated with
+ * this particular class (action in most cases), continuing to try the message
+ * bundle associated with each superclass as well. It will stop once a bundle is
+ * found that contains the given text. This gives a cascading style that allow
+ * global texts to be defined for an application base class.
+ * <p/>
+ * You can override {@link LocaleProvider#getLocale()} to change the behaviour of how
+ * to choose locale for the bundles that are returned. Typically you would
+ * use the {@link LocaleProvider} interface to get the users configured locale.
+ * <p/>
+ * When you want to use your own implementation for Struts 2 project you have to define following
+ * bean and constant in struts.xml:
+ * &lt;bean class=&quot;org.demo.MyTextProvider&quot; name=&quot;myTextProvider&quot; type=&quot;org.apache.struts2.xwork2.TextProvider&quot; /&gt;
+ * &lt;constant name=&quot;struts.xworkTextProvider&quot; value=&quot;myTextProvider&quot; /&gt;
+ * <p/>
+ * if you want to also use your implemntation for framework's messages define another constant (remember to put
+ * into it all framework messages)
+ * &lt;constant name=&quot;system&quot; value=&quot;myTextProvider&quot; /&gt;
+ * <p/>
+ * Take a look on {@link ActionSupport} for example TextProvider implemntation.
+ *
+ * @author Jason Carreira
+ * @author Rainer Hermanns
+ * @see LocaleProvider
+ * @see TextProviderSupport
+ */
+public interface TextProvider {
+
+    /**
+     * Checks if a message key exists.
+     *
+     * @param key message key to check for
+     * @return boolean true if key exists, false otherwise.
+     */
+    boolean hasKey(String key);
+
+    /**
+     * Gets a message based on a message key, or null if no message is found.
+     *
+     * @param key the resource bundle key that is to be searched for
+     * @return the message as found in the resource bundle, or null if none is found.
+     */
+    String getText(String key);
+
+    /**
+     * Gets a message based on a key, or, if the message is not found, a supplied
+     * default value is returned.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    String getText(String key, String defaultValue);
+
+    /**
+     * Gets a message based on a key using the supplied obj, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param obj          obj to be used in a {@link java.text.MessageFormat} message
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    String getText(String key, String defaultValue, String obj);
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or null if no message is found.
+     *
+     * @param key  the resource bundle key that is to be searched for
+     * @param args a list args to be used in a {@link java.text.MessageFormat} message
+     * @return the message as found in the resource bundle, or null if none is found.
+     */
+    String getText(String key, List<?> args);
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or null if no message is found.
+     *
+     * @param key  the resource bundle key that is to be searched for
+     * @param args an array args to be used in a {@link java.text.MessageFormat} message
+     * @return the message as found in the resource bundle, or null if none is found.
+     */
+    String getText(String key, String[] args);
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param args         a list args to be used in a {@link java.text.MessageFormat} message
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    String getText(String key, String defaultValue, List<?> args);
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param args         an array args to be used in a {@link java.text.MessageFormat} message
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    String getText(String key, String defaultValue, String[] args);
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned. Instead of using the value stack in the ActionContext
+     * this version of the getText() method uses the provided value stack.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param args         a list args to be used in a {@link java.text.MessageFormat} message
+     * @param stack        the value stack to use for finding the text
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    String getText(String key, String defaultValue, List<?> args, ValueStack stack);
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned. Instead of using the value stack in the ActionContext
+     * this version of the getText() method uses the provided value stack.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param args         an array args to be used in a {@link java.text.MessageFormat} message
+     * @param stack        the value stack to use for finding the text
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    String getText(String key, String defaultValue, String[] args, ValueStack stack);
+
+    /**
+     * Get the named bundle, such as "com/acme/Foo".
+     *
+     * @param bundleName the name of the resource bundle, such as <code>"com/acme/Foo"</code>.
+     * @return the bundle
+     */
+    ResourceBundle getTexts(String bundleName);
+
+    /**
+     * Get the resource bundle associated with the implementing class (usually an action).
+     *
+     * @return the bundle
+     */
+    ResourceBundle getTexts();
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderFactory.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderFactory.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderFactory.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.inject.Inject;
+
+import java.util.ResourceBundle;
+
+/**
+ * This factory enables users to provide and correctly initialize a custom TextProvider.
+ *
+ * @author Oleg Gorobets
+ * @author Rene Gielen
+ */
+public class TextProviderFactory {
+
+    private TextProvider textProvider;
+
+    @Inject
+    public void setTextProvider(TextProvider textProvider) {
+        this.textProvider = textProvider;
+    }
+
+    protected TextProvider getTextProvider() {
+        if (this.textProvider == null) {
+            return new TextProviderSupport();
+        } else {
+            return textProvider;
+        }
+    }
+
+    public TextProvider createInstance(Class clazz, LocaleProvider provider) {
+        TextProvider instance = getTextProvider();
+        if (instance instanceof ResourceBundleTextProvider) {
+            ((ResourceBundleTextProvider) instance).setClazz(clazz);
+            ((ResourceBundleTextProvider) instance).setLocaleProvider(provider);
+        }
+        return instance;
+    }
+
+    public TextProvider createInstance(ResourceBundle bundle, LocaleProvider provider) {
+        TextProvider instance = getTextProvider();
+        if (instance instanceof ResourceBundleTextProvider) {
+            ((ResourceBundleTextProvider) instance).setBundle(bundle);
+            ((ResourceBundleTextProvider) instance).setLocaleProvider(provider);
+        }
+        return instance;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderSupport.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderSupport.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/TextProviderSupport.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.util.LocalizedTextUtil;
+import org.apache.struts2.xwork2.util.ValueStack;
+
+import java.util.*;
+
+
+/**
+ * Default TextProvider implementation.
+ *
+ * @author Jason Carreira
+ * @author Rainer Hermanns
+ */
+public class TextProviderSupport implements ResourceBundleTextProvider {
+
+    private Class clazz;
+    private LocaleProvider localeProvider;
+    private ResourceBundle bundle;
+
+    /**
+     * Default constructor
+     */
+    public TextProviderSupport() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param clazz    a clazz to use for reading the resource bundle.
+     * @param provider a locale provider.
+     */
+    public TextProviderSupport(Class clazz, LocaleProvider provider) {
+        this.clazz = clazz;
+        this.localeProvider = provider;
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param bundle   the resource bundle.
+     * @param provider a locale provider.
+     */
+    public TextProviderSupport(ResourceBundle bundle, LocaleProvider provider) {
+        this.bundle = bundle;
+        this.localeProvider = provider;
+    }
+
+    /**
+     * @param bundle the resource bundle.
+     */
+    public void setBundle(ResourceBundle bundle) {
+        this.bundle = bundle;
+    }
+
+    /**
+     * @param clazz a clazz to use for reading the resource bundle.
+     */
+    public void setClazz(Class clazz) {
+        this.clazz = clazz;
+    }
+
+
+    /**
+     * @param localeProvider a locale provider.
+     */
+    public void setLocaleProvider(LocaleProvider localeProvider) {
+        this.localeProvider = localeProvider;
+    }
+
+
+    /**
+     * Checks if a key is available in the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class.
+     */
+    public boolean hasKey(String key) {
+    	String message;
+    	if (clazz != null) {
+            message =  LocalizedTextUtil.findText(clazz, key, getLocale(), null, new Object[0] );
+        } else {
+            message = LocalizedTextUtil.findText(bundle, key, getLocale(), null, new Object[0]);
+        }
+    	return message != null;
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class.
+     *
+     * @param key name of text to be found
+     * @return value of named text
+     */
+    public String getText(String key) {
+        return getText(key, key, Collections.emptyList());
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class. If no text is found for this text name, the default value is returned.
+     *
+     * @param key    name of text to be found
+     * @param defaultValue the default value which will be returned if no text is found
+     * @return value of named text
+     */
+    public String getText(String key, String defaultValue) {
+        return getText(key, defaultValue, Collections.emptyList());
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class. If no text is found for this text name, the default value is returned.
+     *
+     * @param key    name of text to be found
+     * @param defaultValue the default value which will be returned if no text is found
+     * @return value of named text
+     */
+    public String getText(String key, String defaultValue, String arg) {
+        List<Object> args = new ArrayList<Object>();
+        args.add(arg);
+        return getText(key, defaultValue, args);
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class. If no text is found for this text name, the default value is returned.
+     *
+     * @param key name of text to be found
+     * @param args      a List of args to be used in a MessageFormat message
+     * @return value of named text
+     */
+    public String getText(String key, List<?> args) {
+        return getText(key, key, args);
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class. If no text is found for this text name, the default value is returned.
+     *
+     * @param key name of text to be found
+     * @param args      an array of args to be used in a MessageFormat message
+     * @return value of named text
+     */
+    public String getText(String key, String[] args) {
+        return getText(key, key, args);
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class. If no text is found for this text name, the default value is returned.
+     *
+     * @param key    name of text to be found
+     * @param defaultValue the default value which will be returned if no text is found
+     * @param args         a List of args to be used in a MessageFormat message
+     * @return value of named text
+     */
+    public String getText(String key, String defaultValue, List<?> args) {
+        Object[] argsArray = ((args != null && !args.equals(Collections.emptyList())) ? args.toArray() : null);
+        if (clazz != null) {
+            return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, argsArray);
+        } else {
+            return LocalizedTextUtil.findText(bundle, key, getLocale(), defaultValue, argsArray);
+        }
+    }
+
+    /**
+     * Get a text from the resource bundles associated with this action.
+     * The resource bundles are searched, starting with the one associated
+     * with this particular action, and testing all its superclasses' bundles.
+     * It will stop once a bundle is found that contains the given text. This gives
+     * a cascading style that allow global texts to be defined for an application base
+     * class. If no text is found for this text name, the default value is returned.
+     *
+     * @param key          name of text to be found
+     * @param defaultValue the default value which will be returned if no text is found
+     * @param args         an array of args to be used in a MessageFormat message
+     * @return value of named text
+     */
+    public String getText(String key, String defaultValue, String[] args) {
+        if (clazz != null) {
+            return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, args);
+        } else {
+            return LocalizedTextUtil.findText(bundle, key, getLocale(), defaultValue, args);
+        }
+    }
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned. Instead of using the value stack in the ActionContext
+     * this version of the getText() method uses the provided value stack.
+     *
+     * @param key    the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param args         a list args to be used in a {@link java.text.MessageFormat} message
+     * @param stack        the value stack to use for finding the text
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    public String getText(String key, String defaultValue, List<?> args, ValueStack stack) {
+        Object[] argsArray = ((args != null) ? args.toArray() : null);
+        Locale locale;
+        if (stack == null){
+        	locale = getLocale();
+        }else{
+        	locale = (Locale) stack.getContext().get(ActionContext.LOCALE);
+        }
+        if (locale == null) {
+            locale = getLocale();
+        }
+        if (clazz != null) {
+            return LocalizedTextUtil.findText(clazz, key, locale, defaultValue, argsArray, stack);
+        } else {
+            return LocalizedTextUtil.findText(bundle, key, locale, defaultValue, argsArray, stack);
+        }
+    }
+
+
+    /**
+     * Gets a message based on a key using the supplied args, as defined in
+     * {@link java.text.MessageFormat}, or, if the message is not found, a supplied
+     * default value is returned. Instead of using the value stack in the ActionContext
+     * this version of the getText() method uses the provided value stack.
+     *
+     * @param key          the resource bundle key that is to be searched for
+     * @param defaultValue the default value which will be returned if no message is found
+     * @param args         an array args to be used in a {@link java.text.MessageFormat} message
+     * @param stack        the value stack to use for finding the text
+     * @return the message as found in the resource bundle, or defaultValue if none is found
+     */
+    public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
+        Locale locale;
+        if (stack == null){
+        	locale = getLocale();
+        }else{
+        	locale = (Locale) stack.getContext().get(ActionContext.LOCALE);
+        }
+        if (locale == null) {
+            locale = getLocale();
+        }
+        if (clazz != null) {
+            return LocalizedTextUtil.findText(clazz, key, locale, defaultValue, args, stack);
+        } else {
+            return LocalizedTextUtil.findText(bundle, key, locale, defaultValue, args, stack);
+        }
+
+    }
+
+    /**
+     * Get the named bundle.
+     * <p/>
+     * You can override the getLocale() methodName to change the behaviour of how
+     * to choose locale for the bundles that are returned. Typically you would
+     * use the TextProvider interface to get the users configured locale, or use
+     * your own methodName to allow the user to select the locale and store it in
+     * the session (by using the SessionAware interface).
+     *
+     * @param aBundleName bundle name
+     * @return a resource bundle
+     */
+    public ResourceBundle getTexts(String aBundleName) {
+        return LocalizedTextUtil.findResourceBundle(aBundleName, getLocale());
+    }
+
+    /**
+     * Get the resource bundle associated with this action.
+     * This will be based on the actual subclass that is used.
+     *
+     * @return resouce bundle
+     */
+    public ResourceBundle getTexts() {
+        if (clazz != null) {
+            return getTexts(clazz.getName());
+        }
+        return bundle;
+    }
+
+    /**
+     * Get's the locale from the localeProvider.
+     *
+     * @return the locale from the localeProvider.
+     */
+    private Locale getLocale() {
+        return localeProvider.getLocale();
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Unchainable.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Unchainable.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Unchainable.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Unchainable.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.struts2.xwork2;
+
+/**
+ * Simple marker interface to indicate an object should <b>not</b> have its properties copied during chaining.
+ *
+ * @see org.apache.struts2.xwork2.interceptor.ChainingInterceptor
+ */
+public interface Unchainable {
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandler.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandler.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandler.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandler.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.config.entities.ActionConfig;
+
+/**
+ * Handles cases when the result or action is unknown.
+ * <p/>
+ * This allows other classes like Struts plugins to provide intelligent defaults easier.
+ */
+public interface UnknownHandler {
+    
+    /**
+     * Handles the case when an action configuration is unknown.  Implementations can return a new ActionConfig
+     * to be used to process the request.
+     * 
+     * @param namespace The namespace
+     * @param actionName The action name
+     * @return An generated ActionConfig, can return <tt>null</tt>
+     * @throws XWorkException
+     */
+    public ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException;
+    
+    /**
+     * Handles the case when a result cannot be found for an action and result code. 
+     * 
+     * @param actionContext The action context
+     * @param actionName The action name
+     * @param actionConfig The action config
+     * @param resultCode The returned result code
+     * @return A result to be executed, can return <tt>null</tt>
+     * @throws XWorkException
+     */
+    public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws XWorkException;
+    
+    /**
+     * Handles the case when an action method cannot be found.  This method is responsible both for finding the method and executing it.
+     * 
+     * @since 2.1
+     * @param action The action object
+     * @param methodName The method name to call
+     * @return The result returned from invoking the action method
+     * @throws NoSuchMethodException If the method cannot be found
+     */
+	public Object handleUnknownActionMethod(Object action, String methodName) throws NoSuchMethodException;
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandlerManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandlerManager.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandlerManager.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/UnknownHandlerManager.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.config.entities.ActionConfig;
+
+import java.util.List;
+
+/**
+ * An unknown handler manager contains a list of UnknownHandler and iterates on them by order
+ *
+ * @see DefaultUnknownHandlerManager
+ */
+public interface UnknownHandlerManager {
+    Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode);
+
+    Object handleUnknownMethod(Object action, String methodName) throws NoSuchMethodException;
+
+    ActionConfig handleUnknownAction(String namespace, String actionName);
+
+    boolean hasUnknownHandlers();
+
+    List<UnknownHandler> getUnknownHandlers();
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Validateable.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Validateable.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Validateable.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/Validateable.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+
+/**
+ * Provides an interface in which a call for a validation check can be done.
+ *
+ * @author Jason Carreira
+ * @see ActionSupport
+ * @see org.apache.struts2.xwork2.interceptor.DefaultWorkflowInterceptor
+ */
+public interface Validateable {
+
+    /**
+     * Performs validation.
+     */
+    void validate();
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAware.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAware.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAware.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ValidationAware classes can accept Action (class level) or field level error messages. Action level messages are kept
+ * in a Collection. Field level error messages are kept in a Map from String field name to a List of field error msgs.
+ *
+ * @author plightbo 
+ */
+public interface ValidationAware {
+
+    /**
+     * Set the Collection of Action-level String error messages.
+     *
+     * @param errorMessages Collection of String error messages
+     */
+    void setActionErrors(Collection<String> 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
+     */
+    Collection<String> getActionErrors();
+
+    /**
+     * Set the Collection of Action-level String messages (not errors).
+     *
+     * @param messages Collection of String messages (not errors).
+     */
+    void setActionMessages(Collection<String> messages);
+
+    /**
+     * Get the Collection of Action-level messages for this action. Messages should not be added
+     * directly here, as implementations are free to return a new Collection or an Unmodifiable
+     * Collection.
+     *
+     * @return Collection of String messages
+     */
+    Collection<String> getActionMessages();
+
+    /**
+     * Set the field error map of fieldname (String) to Collection of String error messages.
+     *
+     * @param errorMap field error map
+     */
+    void setFieldErrors(Map<String, List<String>> 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
+     */
+    Map<String, List<String>> getFieldErrors();
+
+    /**
+     * Add an Action-level error message to this Action.
+     *
+     * @param anErrorMessage  the error message
+     */
+    void addActionError(String anErrorMessage);
+
+    /**
+     * Add an Action-level message to this Action.
+     *
+     * @param aMessage  the message
+     */
+    void addActionMessage(String aMessage);
+
+    /**
+     * 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
+     */
+    boolean hasActionErrors();
+
+    /**
+     * Checks whether there are any Action-level messages.
+     *
+     * @return true if any Action-level messages have been registered
+     */
+    boolean hasActionMessages();
+
+    /**
+     * Checks whether there are any action errors or field errors.
+     * <p/>
+     * <b>Note</b>: that this does not have the same meaning as in WW 1.x.
+     *
+     * @return <code>(hasActionErrors() || hasFieldErrors())</code>
+     */
+    boolean hasErrors();
+
+    /**
+     * Check whether there are any field errors associated with this action.
+     *
+     * @return whether there are any field errors
+     */
+    boolean hasFieldErrors();
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAwareSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAwareSupport.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAwareSupport.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/ValidationAwareSupport.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * Provides a default implementation of ValidationAware. Returns new collections for
+ * errors and messages (defensive copy).
+ *
+ * @author Jason Carreira
+ * @author tm_jee
+ * @version $Date: 2011-12-02 12:24:48 +0100 (Fri, 02 Dec 2011) $ $Id: ValidationAwareSupport.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class ValidationAwareSupport implements ValidationAware, Serializable {
+
+    private Collection<String> actionErrors;
+    private Collection<String> actionMessages;
+    private Map<String, List<String>> fieldErrors;
+
+
+    public synchronized void setActionErrors(Collection<String> errorMessages) {
+        this.actionErrors = errorMessages;
+    }
+
+    public synchronized Collection<String> getActionErrors() {
+        return new ArrayList<String>(internalGetActionErrors());
+    }
+
+    public synchronized void setActionMessages(Collection<String> messages) {
+        this.actionMessages = messages;
+    }
+
+    public synchronized Collection<String> getActionMessages() {
+        return new ArrayList<String>(internalGetActionMessages());
+    }
+
+    public synchronized void setFieldErrors(Map<String, List<String>> errorMap) {
+        this.fieldErrors = errorMap;
+    }
+
+    public synchronized Map<String, List<String>> getFieldErrors() {
+        return new LinkedHashMap<String, List<String>>(internalGetFieldErrors());
+    }
+
+    public synchronized void addActionError(String anErrorMessage) {
+        internalGetActionErrors().add(anErrorMessage);
+    }
+
+    public synchronized void addActionMessage(String aMessage) {
+        internalGetActionMessages().add(aMessage);
+    }
+
+    public synchronized void addFieldError(String fieldName, String errorMessage) {
+        final Map<String, List<String>> errors = internalGetFieldErrors();
+        List<String> thisFieldErrors = errors.get(fieldName);
+
+        if (thisFieldErrors == null) {
+            thisFieldErrors = new ArrayList<String>();
+            errors.put(fieldName, thisFieldErrors);
+        }
+
+        thisFieldErrors.add(errorMessage);
+    }
+
+    public synchronized boolean hasActionErrors() {
+        return (actionErrors != null) && !actionErrors.isEmpty();
+    }
+
+    public synchronized boolean hasActionMessages() {
+        return (actionMessages != null) && !actionMessages.isEmpty();
+    }
+
+    public synchronized boolean hasErrors() {
+        return (hasActionErrors() || hasFieldErrors());
+    }
+
+    public synchronized boolean hasFieldErrors() {
+        return (fieldErrors != null) && !fieldErrors.isEmpty();
+    }
+
+    private Collection<String> internalGetActionErrors() {
+        if (actionErrors == null) {
+            actionErrors = new ArrayList<String>();
+        }
+
+        return actionErrors;
+    }
+
+    private Collection<String> internalGetActionMessages() {
+        if (actionMessages == null) {
+            actionMessages = new ArrayList<String>();
+        }
+
+        return actionMessages;
+    }
+
+    private Map<String, List<String>> internalGetFieldErrors() {
+        if (fieldErrors == null) {
+            fieldErrors = new LinkedHashMap<String, List<String>>();
+        }
+
+        return fieldErrors;
+    }
+
+    /**
+     * Clears field errors map.
+     * <p/>
+     * Will clear the map that contains field errors.
+     */
+    public synchronized void clearFieldErrors() {
+        internalGetFieldErrors().clear();
+    }
+
+    /**
+     * Clears action errors list.
+     * <p/>
+     * Will clear the list that contains action errors.
+     */
+    public synchronized void clearActionErrors() {
+        internalGetActionErrors().clear();
+    }
+
+    /**
+     * Clears messages list.
+     * <p/>
+     * Will clear the list that contains action messages.
+     */
+    public synchronized void clearMessages() {
+        internalGetActionMessages().clear();
+    }
+
+    /**
+     * Clears all error list/maps.
+     * <p/>
+     * Will clear the map and list that contain
+     * field errors and action errors.
+     */
+    public synchronized void clearErrors() {
+        internalGetFieldErrors().clear();
+        internalGetActionErrors().clear();
+    }
+
+    /**
+     * Clears all error and messages list/maps.
+     * <p/>
+     * Will clear the maps/lists that contain
+     * field errors, action errors and action messages.
+     */
+    public synchronized void clearErrorsAndMessages() {
+        internalGetFieldErrors().clear();
+        internalGetActionErrors().clear();
+        internalGetActionMessages().clear();
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWork.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWork.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWork.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWork.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.config.Configuration;
+import org.apache.struts2.xwork2.config.ConfigurationManager;
+import org.apache.struts2.xwork2.util.logging.LoggerFactory;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Simple facade to make using XWork standalone easier
+ */
+public class XWork {
+    
+    ConfigurationManager configurationManager;
+    
+    public XWork() {
+        this(new ConfigurationManager());
+    }
+    
+    public XWork(ConfigurationManager mgr) {
+        this.configurationManager = mgr;
+    }
+    
+    public void setLoggerFactory(LoggerFactory factory) {
+        LoggerFactory.setLoggerFactory(factory);
+    }
+    
+    /**
+     * Executes an action
+     * 
+     * @param namespace The namespace
+     * @param name The action name
+     * @param method The method name
+     * @throws Exception If anything goes wrong
+     */
+    public void executeAction(String namespace, String name, String method) throws XWorkException {
+        Map<String, Object> extraContext = Collections.emptyMap();
+        executeAction(namespace, name, method, extraContext);
+    }
+    
+    /**
+     * Executes an action with extra context information
+     * 
+     * @param namespace The namespace
+     * @param name The action name
+     * @param method The method name
+     * @param extraContext A map of extra context information
+     * @throws Exception If anything goes wrong
+     */
+    public void executeAction(String namespace, String name, String method, Map<String, Object> extraContext) throws XWorkException {
+        Configuration config = configurationManager.getConfiguration();
+        try {
+            ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
+                    namespace, name, method, extraContext, true, false);
+        
+            proxy.execute();
+        } catch (Exception e) {
+            throw new XWorkException(e);
+        } finally {
+            ActionContext.setContext(null);
+        }
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWorkException.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWorkException.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWorkException.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/XWorkException.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2002-2007,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2;
+
+import org.apache.struts2.xwork2.util.location.Locatable;
+import org.apache.struts2.xwork2.util.location.Location;
+import org.apache.struts2.xwork2.util.location.LocationUtils;
+
+
+/**
+ * A generic runtime exception that optionally contains Location information 
+ *
+ * @author Jason Carreira
+ */
+public class XWorkException extends RuntimeException implements Locatable {
+
+    private Location location;
+
+
+    /**
+     * Constructs a <code>XWorkException</code> with no detail message.
+     */
+    public XWorkException() {
+    }
+
+    /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message.
+     *
+     * @param s the detail message.
+     */
+    public XWorkException(String s) {
+        this(s, null, null);
+    }
+    
+    /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message and target.
+     *
+     * @param s the detail message.
+     * @param target the target of the exception.
+     */
+    public XWorkException(String s, Object target) {
+        this(s, (Throwable) null, target);
+    }
+
+    /**
+     * Constructs a <code>XWorkException</code> with the root cause
+     *
+     * @param cause The wrapped exception
+     */
+    public XWorkException(Throwable cause) {
+        this(null, cause, null);
+    }
+    
+    /**
+     * Constructs a <code>XWorkException</code> with the root cause and target
+     *
+     * @param cause The wrapped exception
+     * @param target The target of the exception
+     */
+    public XWorkException(Throwable cause, Object target) {
+        this(null, cause, target);
+    }
+
+    /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message and exception cause.
+     *
+     * @param s the detail message.
+     * @param cause the wrapped exception
+     */
+    public XWorkException(String s, Throwable cause) {
+        this(s, cause, null);
+    }
+    
+    
+     /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message, cause, and target
+     *
+     * @param s the detail message.
+     * @param cause The wrapped exception
+     * @param target The target of the exception
+     */
+    public XWorkException(String s, Throwable cause, Object target) {
+        super(s, cause);
+        
+        this.location = LocationUtils.getLocation(target);
+        if (this.location == Location.UNKNOWN) {
+            this.location = LocationUtils.getLocation(cause);
+        }
+    }
+
+
+    /**
+     * Gets the underlying cause
+     * 
+     * @return the underlying cause, <tt>null</tt> if no cause
+     * @deprecated Use {@link #getCause()} 
+     */
+    @Deprecated public Throwable getThrowable() {
+        return getCause();
+    }
+
+
+    /**
+     * Gets the location of the error, if available
+     *
+     * @return the location, <tt>null</tt> if not available 
+     */
+    public Location getLocation() {
+        return this.location;
+    }
+    
+    
+    /**
+     * Returns a short description of this throwable object, including the 
+     * location. If no detailed message is available, it will use the message
+     * of the underlying exception if available.
+     *
+     * @return a string representation of this <code>Throwable</code>.
+     */
+    @Override
+    public String toString() {
+        String msg = getMessage();
+        if (msg == null && getCause() != null) {
+            msg = getCause().getMessage();
+        }
+
+        if (location != null) {
+            if (msg != null) {
+                return msg + " - " + location.toString();
+            } else {
+                return location.toString();
+            }
+        } else {
+            return msg;
+        }
+    }
+}
\ No newline at end of file