Commits

Anonymous committed 9640204

Refactoring Locale access... not using ActionContext everywhere.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@100e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (11)

docs/localisation.html

  <div class="snip-attachments"></div>
  
  <h3 class="heading-1">ActionSupport.getText() and LocalizedTextUtil
-</h3><p class="paragraph"/>The implementation of com.opensymphony.xwork.LocaleAware in com.opensymphony.xwork.ActionSupport uses com.opensymphony.xwork.util.LocalizedTextUtil to find localized message texts for message keys. LocalizedTextUtil uses a system of defaults for finding resource bundle property files for searching for the message text. If LocalizedTextUtil.findText(Class aClass, String aTextName, Locale locale) is called (or LocalizedTextUtil.findText(Class aClass, String aTextName), which just uses the Locale from ActionContext.getContext.getLocale()), the following search order is used:
+</h3><p class="paragraph"/>The implementation of com.opensymphony.xwork.TextProvider in com.opensymphony.xwork.ActionSupport uses com.opensymphony.xwork.util.LocalizedTextUtil to find localized message texts for message keys. LocalizedTextUtil uses a system of defaults for finding resource bundle property files for searching for the message text. If LocalizedTextUtil.findText(Class aClass, String aTextName, Locale locale) is called (or LocalizedTextUtil.findText(Class aClass, String aTextName), which just uses the Locale from ActionContext.getContext.getLocale()), the following search order is used:
+
 <ol>
 <li>The class name is used with the call <div class="code"><pre>ResourceBundle.getBundle(aBundleName, locale, <span class="java&#45;object">Thread</span>.currentThread().getContextClassLoader())</pre></div></li>
 <li>If the message text is not found, each parent class of the action is used as above until java.lang.Object is found</li>
 <li>If the message text has still not been found, findDefaultText(aTextName, locale) is called to search the default message bundles</li>
 </ol><p class="paragraph"/>The findDefaultText(aTextName, locale) method searches named resource bundles which have been registered with LocalzedTextUtil in reverse order of their registration (i.e. the first resource bundle name registered is the last to be searched). By default, one default resource bundle name is registered with LocalizedTextUtil for search, "com/opensymphony/xwork/xwork-messages", which is bundled with the jar file to provide system-level message texts.
 
+
   </div>
 </body>
 </html>

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

  * Time: 3:45:29 PM
  * To change this template use Options | File Templates.
  */
-public class ActionSupport implements Action, Serializable, Validateable, ValidationAware, LocaleAware {
+public class ActionSupport implements Action, Serializable, Validateable, ValidationAware, TextProvider, LocaleProvider {
     //~ Static fields/initializers /////////////////////////////////////////////
 
     protected transient static final Log LOG = LogFactory.getLog(ActionSupport.class);
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
-    private final LocaleAware localeAware = new LocaleAwareSupport(getClass());
+    private final TextProvider textProvider = new TextProviderSupport(getClass(), this);
     private final ValidationAware validationAware = new ValidationAwareSupport();
 
     //~ Methods ////////////////////////////////////////////////////////////////
     }
 
     public Locale getLocale() {
-        return localeAware.getLocale();
+        return ActionContext.getContext().getLocale();
     }
 
     public String getText(String aTextName) {
-        return localeAware.getText(aTextName);
+        return textProvider.getText(aTextName);
     }
 
     public String getText(String aTextName, String defaultValue) {
-        return localeAware.getText(aTextName, defaultValue);
+        return textProvider.getText(aTextName, defaultValue);
     }
 
     public String getText(String aTextName, List args) {
-        return localeAware.getText(aTextName, args);
+        return textProvider.getText(aTextName, args);
     }
 
     public String getText(String aTextName, String defaultValue, List args) {
-        return localeAware.getText(aTextName, defaultValue, args);
+        return textProvider.getText(aTextName, defaultValue, args);
     }
 
     public ResourceBundle getTexts(String aBundleName) {
-        return localeAware.getTexts(aBundleName);
+        return textProvider.getTexts(aBundleName);
     }
 
     public ResourceBundle getTexts() {
-        return localeAware.getTexts();
+        return textProvider.getTexts();
     }
 
     public void addActionError(String anErrorMessage) {

src/java/com/opensymphony/xwork/LocaleAware.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.List;
-
-
-/**
- * LocaleAware
- * @author Jason Carreira
- * Created Feb 10, 2003 9:55:48 AM
- */
-public interface LocaleAware {
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Get the locale for this action.
-     *
-     * Applications may customize how locale is chosen by
-     * subclassing ActionSupport and override this methodName.
-     *
-     * @return     the locale to use
-     */
-    Locale getLocale();
-
-    /**
-     * 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   aTextName  name of text to be found
-     * @return     value of named text
-     */
-    String getText(String aTextName);
-
-    /**
-     * 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   aTextName  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
-     */
-    String getText(String aTextName, String defaultValue);
-
-    /**
-     * 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   aTextName  name of text to be found
-     * @param   args a List of args to be used in a MessageFormat message
-     * @return     value of named text
-     */
-    String getText(String aTextName, List 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   aTextName  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
-     */
-    String getText(String aTextName, String defaultValue, List args);
-
-    /**
-    * Get the named bundle.
-    *
-    * 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 LocaleAware 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
-    */
-    ResourceBundle getTexts(String aBundleName);
-
-    /**
-    * Get the resource bundle associated with this action.
-    * This will be based on the actual subclass that is used.
-    *
-    * @return     resouce bundle
-    */
-    ResourceBundle getTexts();
-}

src/java/com/opensymphony/xwork/LocaleAwareSupport.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork;
-
-import com.opensymphony.xwork.util.LocalizedTextUtil;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.List;
-
-
-/**
- * LocaleAwareSupport
- * @author Jason Carreira
- * Created Aug 3, 2003 12:21:12 AM
- */
-public class LocaleAwareSupport implements LocaleAware {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private Class clazz;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public LocaleAwareSupport(Class clazz) {
-        this.clazz = clazz;
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-    * Get the locale for this action.
-    *
-    * Applications may customize how locale is chosen by
-    * subclassing ActionSupport and override this methodName.
-    *
-    * @return     the locale to use
-    */
-    public Locale getLocale() {
-        return ActionContext.getContext().getLocale();
-    }
-
-    /**
-    * 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   aTextName  name of text to be found
-    * @return     value of named text
-    */
-    public String getText(String aTextName) {
-        return LocalizedTextUtil.findText(clazz, aTextName);
-    }
-
-    /**
-     * 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   aTextName  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 aTextName, String defaultValue) {
-        return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), defaultValue, new Object[0]);
-    }
-
-    /**
-     * 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   aTextName  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 aTextName, List args) {
-        return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), aTextName, args.toArray());
-    }
-
-    /**
-     * 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   aTextName  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 aTextName, String defaultValue, List args) {
-        return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), defaultValue, args.toArray());
-    }
-
-    /**
-    * Get the named bundle.
-    *
-    * 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 LocaleAware 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() {
-        return getTexts(clazz.getName());
-    }
-}

src/java/com/opensymphony/xwork/LocaleProvider.java

+package com.opensymphony.xwork;
+
+import java.util.Locale;
+
+/**
+ * LocaleProvider
+ * @author Jason Carreira
+ * Date: Oct 29, 2003 9:11:22 PM
+ */
+public interface LocaleProvider {
+    Locale getLocale();
+}

src/java/com/opensymphony/xwork/TextProvider.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.List;
+
+
+/**
+ * TextProvider
+ * @author Jason Carreira
+ * Created Feb 10, 2003 9:55:48 AM
+ */
+public interface TextProvider {
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    /**
+     * 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   aTextName  name of text to be found
+     * @return     value of named text
+     */
+    String getText(String aTextName);
+
+    /**
+     * 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   aTextName  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
+     */
+    String getText(String aTextName, String defaultValue);
+
+    /**
+     * 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   aTextName  name of text to be found
+     * @param   args a List of args to be used in a MessageFormat message
+     * @return     value of named text
+     */
+    String getText(String aTextName, List 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   aTextName  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
+     */
+    String getText(String aTextName, String defaultValue, List args);
+
+    /**
+    * Get the named bundle.
+    *
+    * 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
+    */
+    ResourceBundle getTexts(String aBundleName);
+
+    /**
+    * Get the resource bundle associated with this action.
+    * This will be based on the actual subclass that is used.
+    *
+    * @return     resouce bundle
+    */
+    ResourceBundle getTexts();
+}

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

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.util.LocalizedTextUtil;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+
+/**
+ * TextProviderSupport
+ * @author Jason Carreira
+ * Created Aug 3, 2003 12:21:12 AM
+ */
+public class TextProviderSupport implements TextProvider {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private Class clazz;
+    private LocaleProvider localeProvider;
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    public TextProviderSupport(Class clazz, LocaleProvider provider) {
+        this.clazz = clazz;
+        this.localeProvider = provider;
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    private Locale getLocale() {
+        return localeProvider.getLocale();
+    }
+
+    /**
+    * 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   aTextName  name of text to be found
+    * @return     value of named text
+    */
+    public String getText(String aTextName) {
+        return LocalizedTextUtil.findText(clazz, aTextName);
+    }
+
+    /**
+     * 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   aTextName  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 aTextName, String defaultValue) {
+        return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), defaultValue, new Object[0]);
+    }
+
+    /**
+     * 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   aTextName  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 aTextName, List args) {
+        return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), aTextName, args.toArray());
+    }
+
+    /**
+     * 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   aTextName  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 aTextName, String defaultValue, List args) {
+        return LocalizedTextUtil.findText(clazz, aTextName, getLocale(), defaultValue, args.toArray());
+    }
+
+    /**
+    * Get the named bundle.
+    *
+    * 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() {
+        return getTexts(clazz.getName());
+    }
+}

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

  */
 package com.opensymphony.xwork.validator;
 
-import com.opensymphony.xwork.LocaleAware;
-import com.opensymphony.xwork.LocaleAwareSupport;
-import com.opensymphony.xwork.ValidationAware;
+import com.opensymphony.xwork.*;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 public class DelegatingValidatorContext implements ValidatorContext {
     //~ Instance fields ////////////////////////////////////////////////////////
 
-    private LocaleAware localeAware;
+    private LocaleProvider localeProvider;
+    private TextProvider textProvider;
     private ValidationAware validationAware;
 
     //~ Constructors ///////////////////////////////////////////////////////////
 
-    public DelegatingValidatorContext(ValidationAware validationAware, LocaleAware localeAware) {
-        this.localeAware = localeAware;
+    public DelegatingValidatorContext(ValidationAware validationAware, TextProvider textProvider, LocaleProvider localeProvider) {
+        this.textProvider = textProvider;
         this.validationAware = validationAware;
+        this.localeProvider = localeProvider;
     }
 
     public DelegatingValidatorContext(Object object) {
-        this(makeValidationAware(object), makeLocaleAware(object));
+        this.localeProvider = makeLocaleProvider(object);
+        this.validationAware = makeValidationAware(object);
+        this.textProvider = makeTextProvider(object,localeProvider);
     }
 
     //~ Methods ////////////////////////////////////////////////////////////////
     }
 
     public Locale getLocale() {
-        return localeAware.getLocale();
+        return localeProvider.getLocale();
     }
 
     public String getText(String aTextName) {
-        return localeAware.getText(aTextName);
+        return textProvider.getText(aTextName);
     }
 
     public String getText(String aTextName, String defaultValue) {
-        return localeAware.getText(aTextName, defaultValue);
+        return textProvider.getText(aTextName, defaultValue);
     }
 
     public String getText(String aTextName, List args) {
-        return localeAware.getText(aTextName, args);
+        return textProvider.getText(aTextName, args);
     }
 
     public String getText(String aTextName, String defaultValue, List args) {
-        return localeAware.getText(aTextName, defaultValue, args);
+        return textProvider.getText(aTextName, defaultValue, args);
     }
 
     public ResourceBundle getTexts(String aBundleName) {
-        return localeAware.getTexts(aBundleName);
+        return textProvider.getTexts(aBundleName);
     }
 
     public ResourceBundle getTexts() {
-        return localeAware.getTexts();
+        return textProvider.getTexts();
     }
 
     public void addActionError(String anErrorMessage) {
         return validationAware.hasFieldErrors();
     }
 
-    protected static LocaleAware makeLocaleAware(Object object) {
-        if (object instanceof LocaleAware) {
-            return (LocaleAware) object;
+    protected static TextProvider makeTextProvider(Object object, LocaleProvider localeProvider) {
+        if (object instanceof LocaleProvider) {
+            return (TextProvider) object;
         } else {
-            return new LocaleAwareSupport(object.getClass());
+            return new TextProviderSupport(object.getClass(), localeProvider);
         }
     }
 
         }
     }
 
-    protected void setLocaleAware(LocaleAware localeAware) {
-        this.localeAware = localeAware;
+    protected static LocaleProvider makeLocaleProvider(Object object) {
+        if (object instanceof LocaleProvider) {
+            return (LocaleProvider) object;
+        } else {
+            return new ActionContextLocaleProvider();
+        }
+    }
+
+    protected void setTextProvider(TextProvider textProvider) {
+        this.textProvider = textProvider;
     }
 
-    protected LocaleAware getLocaleAware() {
-        return localeAware;
+    protected TextProvider getTextProvider() {
+        return textProvider;
     }
 
     protected void setValidationAware(ValidationAware validationAware) {
             return false;
         }
     }
+
+    private static class ActionContextLocaleProvider implements LocaleProvider {
+        public Locale getLocale() {
+            return ActionContext.getContext().getLocale();
+        }
+
+    }
 }

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

  */
 package com.opensymphony.xwork.validator;
 
-import com.opensymphony.xwork.LocaleAware;
+import com.opensymphony.xwork.TextProvider;
 import com.opensymphony.xwork.ValidationAware;
+import com.opensymphony.xwork.LocaleProvider;
 
 
 /**
  * @author Jason Carreira
  * Created Aug 3, 2003 12:30:32 AM
  */
-public interface ValidatorContext extends ValidationAware, LocaleAware {
+public interface ValidatorContext extends ValidationAware, TextProvider, LocaleProvider {
 }

src/java/com/opensymphony/xwork/validator/validators/VisitorFieldValidator.java

         String message;
 
         public AppendingValidatorContext(ValidatorContext parent, Object object, String field, String message) {
-            super(parent, makeLocaleAware(object));
+            super(parent, makeTextProvider(object, parent), parent);
 
             //            super(parent);
             this.field = field;

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

             ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("", MockConfigurationProvider.FOO_ACTION_NAME, null);
             ActionContext.getContext().setLocale(Locale.US);
 
-            LocaleAware localeAware = (LocaleAware) proxy.getAction();
+            TextProvider localeAware = (TextProvider) proxy.getAction();
             assertEquals("Foo Range Message", localeAware.getText("foo.range"));
         } catch (Exception e) {
             e.printStackTrace();
             ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("", MockConfigurationProvider.FOO_ACTION_NAME, null);
             ActionContext.getContext().setLocale(Locale.GERMANY);
 
-            LocaleAware localeAware = (LocaleAware) proxy.getAction();
+            TextProvider localeAware = (TextProvider) proxy.getAction();
             assertEquals("I don't know German", localeAware.getText("foo.range"));
         } catch (Exception e) {
             e.printStackTrace();