You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ma...@apache.org on 2009/12/27 19:01:09 UTC
svn commit: r894087 [4/46] - in /struts/xwork/trunk: ./ assembly/
assembly/src/ assembly/src/main/ assembly/src/main/assembly/
assembly/src/main/resources/ core/ core/src/ core/src/main/
core/src/main/java/ core/src/main/java/com/ core/src/main/java/co...
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProvider.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProvider.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProvider.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProvider.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.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:
+ * <bean class="org.demo.MyTextProvider" name="myTextProvider" type="com.opensymphony.xwork2.TextProvider" />
+ * <constant name="struts.xworkTextProvider" value="myTextProvider" />
+ * <p/>
+ * if you want to also use your implemntation for framework's messages define another constant (remember to put
+ * into it all framework messages)
+ * <constant name="system" value="myTextProvider" />
+ * <p/>
+ * Take a look on {@link com.opensymphony.xwork2.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<Object> 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<Object> 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<Object> 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();
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.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;
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.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<Object> 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<Object> args) {
+ Object[] argsArray = ((args != null && !args.equals(Collections.emptyList())) ? args.toArray() : null);
+ if (clazz != null) {
+ return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, argsArray);
+ } else {
+ 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<Object> 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();
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Unchainable.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Unchainable.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Unchainable.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Unchainable.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+
+package com.opensymphony.xwork2;
+
+/**
+ * Simple marker interface to indicate an object should <b>not</b> have its properties copied during chaining.
+ *
+ * @see com.opensymphony.xwork2.interceptor.ChainingInterceptor
+ */
+public interface Unchainable {
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Unchainable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Unchainable.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.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;
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+
+import java.util.List;
+
+/**
+ * An unknown handler manager contains a list of UnknownHandler and iterates on them by order
+ *
+ * @see com.opensymphony.xwork2.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();
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Validateable.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Validateable.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Validateable.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Validateable.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+
+/**
+ * Provides an interface in which a call for a validation check can be done.
+ *
+ * @author Jason Carreira
+ * @see ActionSupport
+ * @see com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor
+ */
+public interface Validateable {
+
+ /**
+ * Performs validation.
+ */
+ void validate();
+
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Validateable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/Validateable.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAware.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAware.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAware.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAware.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.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();
+
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAware.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAware.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.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$ $Id$
+ */
+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();
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWork.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWork.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWork.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWork.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.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);
+ }
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWork.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWork.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkException.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkException.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkException.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkException.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+import com.opensymphony.xwork2.util.location.Locatable;
+import com.opensymphony.xwork2.util.location.Location;
+import com.opensymphony.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
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2;
+
+
+/**
+ * Contains constants for some default XWork messages.
+ *
+ * @author Jason Carreira
+ */
+public interface XWorkMessages {
+
+ public static final String ACTION_EXECUTION_ERROR = "xwork.error.action.execution";
+ public static final String MISSING_ACTION_EXCEPTION = "xwork.exception.missing-action";
+ public static final String MISSING_PACKAGE_ACTION_EXCEPTION = "xwork.exception.missing-package-action";
+ public static final String DEFAULT_INVALID_FIELDVALUE = "xwork.default.invalid.fieldvalue";
+
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+
+package com.opensymphony.xwork2;
+
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.inject.*;
+import com.opensymphony.xwork2.test.StubConfigurationProvider;
+import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
+import junit.framework.TestCase;
+
+
+/**
+ * Base JUnit TestCase to extend for XWork specific JUnit tests. Uses
+ * the generic test setup for logic.
+ *
+ * @author plightbo
+ */
+public abstract class XWorkTestCase extends TestCase {
+
+ protected ConfigurationManager configurationManager;
+ protected Configuration configuration;
+ protected Container container;
+ protected ActionProxyFactory actionProxyFactory;
+
+ public XWorkTestCase() {
+ super();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ configurationManager = XWorkTestCaseHelper.setUp();
+ configuration = configurationManager.getConfiguration();
+ container = configuration.getContainer();
+ actionProxyFactory = container.getInstance(ActionProxyFactory.class);
+ }
+
+ @Override
+ 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);
+ }
+
+ protected void loadButAdd(final Class<?> type, final Object impl) {
+ loadButAdd(type, Container.DEFAULT_NAME, impl);
+ }
+
+ protected void loadButAdd(final Class<?> type, final String name, final Object impl) {
+ loadConfigurationProviders(new StubConfigurationProvider() {
+ @Override
+ public void register(ContainerBuilder builder,
+ LocatableProperties props) throws ConfigurationException {
+ builder.factory(type, name, new Factory() {
+ public Object create(Context context) throws Exception {
+ return impl;
+ }
+
+ }, Scope.SINGLETON);
+ }
+ });
+ }
+
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/Configuration.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/Configuration.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/Configuration.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/Configuration.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.entities.UnknownHandlerConfig;
+import com.opensymphony.xwork2.inject.Container;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * XWork configuration.
+ *
+ * @author Mike
+ */
+public interface Configuration extends Serializable {
+
+ void rebuildRuntimeConfiguration();
+
+ PackageConfig getPackageConfig(String name);
+
+ Set<String> getPackageConfigNames();
+
+ Map<String, PackageConfig> getPackageConfigs();
+
+ /**
+ * The current runtime configuration. Currently, if changes have been made to the Configuration since the last
+ * time buildRuntimeConfiguration() was called, you'll need to make sure to.
+ *
+ * @return the current runtime configuration
+ */
+ RuntimeConfiguration getRuntimeConfiguration();
+
+ void addPackageConfig(String name, PackageConfig packageConfig);
+
+ /**
+ * Removes a package from the the list of packages. Changes to the configuration won't take effect until buildRuntimeConfiguration
+ * is called.
+ * @param packageName the name of the package to remove
+ * @return the package removed (if any)
+ */
+ PackageConfig removePackageConfig(String packageName);
+
+ /**
+ * Allow the Configuration to clean up any resources that have been used.
+ */
+ void destroy();
+
+ /**
+ * @deprecated Since 2.1
+ * @param providers
+ * @throws ConfigurationException
+ */
+ @Deprecated void reload(List<ConfigurationProvider> providers) throws ConfigurationException;
+
+ /**
+ * @since 2.1
+ * @param containerProviders
+ * @throws ConfigurationException
+ */
+ List<PackageProvider> reloadContainer(List<ContainerProvider> containerProviders) throws ConfigurationException;
+
+ /**
+ * @return the container
+ */
+ Container getContainer();
+
+ Set<String> getLoadedFileNames();
+
+ /**
+ * @since 2.1
+ * @return list of unknown handlers
+ */
+ List<UnknownHandlerConfig> getUnknownHandlerStack();
+
+ /**
+ * @since 2.1
+ * @param unknownHandlerStack
+ */
+ void setUnknownHandlerStack(List<UnknownHandlerConfig> unknownHandlerStack);
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/Configuration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/Configuration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.XWorkException;
+
+
+/**
+ * ConfigurationException
+ *
+ * @author Jason Carreira
+ */
+public class ConfigurationException extends XWorkException {
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with no detail message.
+ */
+ public ConfigurationException() {
+ }
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with the specified
+ * detail message.
+ *
+ * @param s the detail message.
+ */
+ public ConfigurationException(String s) {
+ super(s);
+ }
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with the specified
+ * detail message.
+ *
+ * @param s the detail message.
+ */
+ public ConfigurationException(String s, Object target) {
+ super(s, target);
+ }
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with no detail message.
+ */
+ public ConfigurationException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with no detail message.
+ */
+ public ConfigurationException(Throwable cause, Object target) {
+ super(cause, target);
+ }
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with the specified
+ * detail message.
+ *
+ * @param s the detail message.
+ */
+ public ConfigurationException(String s, Throwable cause) {
+ super(s, cause);
+ }
+
+ /**
+ * Constructs a <code>ConfigurationException</code> with the specified
+ * detail message.
+ *
+ * @param s the detail message.
+ */
+ public ConfigurationException(String s, Throwable cause, Object target) {
+ super(s, cause, target);
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
+import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+import com.opensymphony.xwork2.util.FileManager;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * ConfigurationManager - central for XWork Configuration management, including
+ * its ConfigurationProvider.
+ *
+ * @author Jason Carreira
+ * @author tm_jee
+ * @version $Date$ $Id$
+ */
+public class ConfigurationManager {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(ConfigurationManager.class);
+ protected Configuration configuration;
+ protected Lock providerLock = new ReentrantLock();
+ private List<ContainerProvider> containerProviders = new CopyOnWriteArrayList<ContainerProvider>();
+ private List<PackageProvider> packageProviders = new CopyOnWriteArrayList<PackageProvider>();
+ protected String defaultFrameworkBeanName;
+
+ public ConfigurationManager() {
+ this("xwork");
+ }
+
+ public ConfigurationManager(String name) {
+ this.defaultFrameworkBeanName = name;
+ }
+
+ /**
+ * Get the current XWork configuration object. By default an instance of DefaultConfiguration will be returned
+ *
+ * @see com.opensymphony.xwork2.config.impl.DefaultConfiguration
+ */
+ public synchronized Configuration getConfiguration() {
+ if (configuration == null) {
+ setConfiguration(new DefaultConfiguration(defaultFrameworkBeanName));
+ try {
+ configuration.reloadContainer(getContainerProviders());
+ } catch (ConfigurationException e) {
+ setConfiguration(null);
+ throw new ConfigurationException("Unable to load configuration.", e);
+ }
+ } else {
+ conditionalReload();
+ }
+
+ return configuration;
+ }
+
+ public synchronized void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /**
+ * Get the current list of ConfigurationProviders. If no custom ConfigurationProviders have been added, this method
+ * will return a list containing only the default ConfigurationProvider, XMLConfigurationProvider. if a custom
+ * ConfigurationProvider has been added, then the XmlConfigurationProvider must be added by hand.
+ * </p>
+ * <p/>
+ * WARNING: This returns only ContainerProviders that can be cast into ConfigurationProviders
+ *
+ * @return the list of registered ConfigurationProvider objects
+ * @see ConfigurationProvider
+ * @deprecated Since 2.1, use {@link #getContainerProviders()}
+ */
+ @Deprecated public List<ConfigurationProvider> getConfigurationProviders() {
+ List<ContainerProvider> contProviders = getContainerProviders();
+ List<ConfigurationProvider> providers = new ArrayList<ConfigurationProvider>();
+ for (ContainerProvider prov : contProviders) {
+ if (prov instanceof ConfigurationProvider) {
+ providers.add((ConfigurationProvider) prov);
+ }
+ }
+ return providers;
+ }
+
+ /**
+ * Get the current list of ConfigurationProviders. If no custom ConfigurationProviders have been added, this method
+ * will return a list containing only the default ConfigurationProvider, XMLConfigurationProvider. if a custom
+ * ConfigurationProvider has been added, then the XmlConfigurationProvider must be added by hand.
+ * </p>
+ * <p/>
+ * TODO: the lazy instantiation of XmlConfigurationProvider should be refactored to be elsewhere. the behavior described above seems unintuitive.
+ *
+ * @return the list of registered ConfigurationProvider objects
+ * @see ConfigurationProvider
+ */
+ public List<ContainerProvider> getContainerProviders() {
+ providerLock.lock();
+ try {
+ if (containerProviders.size() == 0) {
+ containerProviders.add(new XWorkConfigurationProvider());
+ containerProviders.add(new XmlConfigurationProvider("xwork.xml", false));
+ }
+
+ return containerProviders;
+ } finally {
+ providerLock.unlock();
+ }
+ }
+
+ /**
+ * Set the list of configuration providers
+ *
+ * @param configurationProviders
+ * @deprecated Since 2.1, use {@link #setContainerProvider()}
+ */
+ @Deprecated public void setConfigurationProviders(List<ConfigurationProvider> configurationProviders) {
+ // Silly copy necessary due to lack of ability to cast generic lists
+ List<ContainerProvider> contProviders = new ArrayList<ContainerProvider>();
+ contProviders.addAll(configurationProviders);
+
+ setContainerProviders(contProviders);
+ }
+
+ /**
+ * Set the list of configuration providers
+ *
+ * @param containerProviders
+ */
+ public void setContainerProviders(List<ContainerProvider> containerProviders) {
+ providerLock.lock();
+ try {
+ this.containerProviders = new CopyOnWriteArrayList<ContainerProvider>(containerProviders);
+ } finally {
+ providerLock.unlock();
+ }
+ }
+
+ /**
+ * adds a configuration provider to the List of ConfigurationProviders. a given ConfigurationProvider may be added
+ * more than once
+ *
+ * @param provider the ConfigurationProvider to register
+ * @deprecated Since 2.1, use {@link #addContainerProvider()}
+ */
+ @Deprecated public void addConfigurationProvider(ConfigurationProvider provider) {
+ addContainerProvider(provider);
+ }
+
+ /**
+ * adds a configuration provider to the List of ConfigurationProviders. a given ConfigurationProvider may be added
+ * more than once
+ *
+ * @param provider the ConfigurationProvider to register
+ */
+ public void addContainerProvider(ContainerProvider provider) {
+ if (!containerProviders.contains(provider)) {
+ containerProviders.add(provider);
+ }
+ }
+
+ /**
+ * clears the registered ConfigurationProviders. this method will call destroy() on each of the registered
+ * ConfigurationProviders
+ *
+ * @see com.opensymphony.xwork2.config.ConfigurationProvider#destroy
+ * @deprecated Since 2.1, use {@link #clearContainerProviders()}
+ */
+ @Deprecated public void clearConfigurationProviders() {
+ clearContainerProviders();
+ }
+
+ public void clearContainerProviders() {
+ for (ContainerProvider containerProvider : containerProviders) {
+ try {
+ containerProvider.destroy();
+ }
+ catch(Exception e) {
+ LOG.warn("error while destroying container provider ["+containerProvider+"]", e);
+ }
+ }
+ containerProviders.clear();
+ }
+
+ /**
+ * Destroy its managing Configuration instance
+ */
+ public synchronized void destroyConfiguration() {
+ clearConfigurationProviders(); // let's destroy the ConfigurationProvider first
+ containerProviders = new CopyOnWriteArrayList<ContainerProvider>();
+ if (configuration != null)
+ configuration.destroy(); // let's destroy it first, before nulling it.
+ configuration = null;
+ }
+
+
+ /**
+ * Reloads the Configuration files if the configuration files indicate that they need to be reloaded.
+ */
+ public synchronized void conditionalReload() {
+ if (FileManager.isReloadingConfigs()) {
+ boolean reload;
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Checking ConfigurationProviders for reload.");
+ }
+
+ reload = false;
+
+ List<ContainerProvider> providers = getContainerProviders();
+ for (ContainerProvider provider : providers) {
+ if (provider.needsReload()) {
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Detected container provider "+provider+" needs to be reloaded. Reloading all providers.");
+ }
+ reload = true;
+
+ //break;
+ }
+ }
+
+ if (packageProviders != null && reload) {
+ for (PackageProvider provider : packageProviders) {
+ if (provider.needsReload()) {
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Detected package provider "+provider+" needs to be reloaded. Reloading all providers.");
+ }
+ reload = true;
+
+ //break;
+ }
+ }
+ }
+
+ if (reload) {
+ for (ContainerProvider containerProvider : containerProviders) {
+ try {
+ containerProvider.destroy();
+ }
+ catch(Exception e) {
+ LOG.warn("error while destroying configuration provider ["+containerProvider+"]", e);
+ }
+ }
+ packageProviders = configuration.reloadContainer(providers);
+ }
+ }
+ }
+
+ public synchronized void reload() {
+ packageProviders = getConfiguration().reloadContainer(getContainerProviders());
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+/**
+ * Interface to be implemented by all forms of XWork configuration classes.
+ */
+public interface ConfigurationProvider extends ContainerProvider, PackageProvider {
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+/**
+ * ConfigurationUtil
+ *
+ * @author Jason Carreira
+ * Created May 23, 2003 11:22:49 PM
+ */
+public class ConfigurationUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigurationUtil.class);
+
+
+ private ConfigurationUtil() {
+ }
+
+
+ public static List<PackageConfig> buildParentsFromString(Configuration configuration, String parent) {
+ if ((parent == null) || ("".equals(parent))) {
+ return Collections.emptyList();
+ }
+
+ StringTokenizer tokenizer = new StringTokenizer(parent, ", ");
+ List<PackageConfig> parents = new ArrayList<PackageConfig>();
+
+ while (tokenizer.hasMoreTokens()) {
+ String parentName = tokenizer.nextToken().trim();
+
+ if (!"".equals(parentName)) {
+ PackageConfig parentPackageContext = configuration.getPackageConfig(parentName);
+
+ if (parentPackageContext != null) {
+ parents.add(parentPackageContext);
+ }
+ }
+ }
+
+ return parents;
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
+
+
+/**
+ * Provides beans and constants/properties for the Container
+ *
+ * @since 2.1
+ */
+public interface ContainerProvider {
+
+ /**
+ * Called before removed from the configuration manager
+ */
+ public void destroy();
+
+ /**
+ * Initializes with the configuration
+ * @param configuration The configuration
+ * @throws ConfigurationException If anything goes wrong
+ */
+ public void init(Configuration configuration) throws ConfigurationException;
+
+ /**
+ * Tells whether the ContainerProvider should reload its configuration
+ *
+ * @return <tt>true</tt>, whether the ContainerProvider should reload its configuration, <tt>false</tt>otherwise.
+ */
+ public boolean needsReload();
+
+ /**
+ * Registers beans and properties for the Container
+ *
+ * @param builder The builder to register beans with
+ * @param props The properties to register constants with
+ * @throws ConfigurationException If anything goes wrong
+ */
+ public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException;
+
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+/**
+ * Provides configuration packages. The separate init and loadPackages calls are due to the need to
+ * preserve backwards compatibility with the 2.0 {@link ConfigurationProvider} interface
+ *
+ * @since 2.1
+ */
+public interface PackageProvider {
+
+ /**
+ * Initializes with the configuration
+ * @param configuration The configuration
+ * @throws ConfigurationException If anything goes wrong
+ */
+ public void init(Configuration configuration) throws ConfigurationException;
+
+ /**
+ * Tells whether the PackageProvider should reload its configuration
+ *
+ * @return <tt>true</tt>, whether the PackageProvider should reload its configuration, <tt>false</tt>otherwise.
+ */
+ public boolean needsReload();
+
+ /**
+ * Loads the packages for the configuration.
+ * @throws ConfigurationException
+ */
+ public void loadPackages() throws ConfigurationException;
+
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.XWorkException;
+
+
+/**
+ * Exception when a reference can't be resolved.
+ *
+ * @author Mike
+ */
+public class ReferenceResolverException extends XWorkException {
+
+ public ReferenceResolverException() {
+ super();
+ }
+
+ public ReferenceResolverException(String s) {
+ super(s);
+ }
+
+ public ReferenceResolverException(String s, Throwable cause) {
+ super(s, cause);
+ }
+
+ public ReferenceResolverException(Throwable cause) {
+ super(cause);
+ }
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java
URL: http://svn.apache.org/viewvc/struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java?rev=894087&view=auto
==============================================================================
--- struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java (added)
+++ struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java Sun Dec 27 18:00:13 2009
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+
+import java.io.Serializable;
+import java.util.Map;
+
+
+/**
+ * RuntimeConfiguration
+ *
+ * @author Jason Carreira
+ * Created Feb 25, 2003 10:56:02 PM
+ */
+public interface RuntimeConfiguration extends Serializable {
+
+ /**
+ * get the fully expanded ActionConfig for a specified namespace and (action) name
+ *
+ * @param namespace the namespace of the Action. if this is null, then the empty namespace, "", will be used
+ * @param name the name of the Action. may not be null.
+ * @return the requested ActionConfig or null if there was no ActionConfig associated with the specified namespace
+ * and name
+ */
+ ActionConfig getActionConfig(String namespace, String name);
+
+ /**
+ * returns a Map of all the registered ActionConfigs. Again, these ActionConfigs are fully expanded so that any
+ * inherited interceptors, results, etc. will be included
+ *
+ * @return a Map of Map keyed by namespace and name respectively such that
+ * <pre>
+ * ActionConfig config = (ActionConfig)((Map)getActionConfigs.get(namespace)).get(name);
+ * </pre>
+ * should return a valid config for valid namespace/name pairs
+ */
+ Map<String, Map<String, ActionConfig>> getActionConfigs();
+}
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/xwork/trunk/core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL