Index: C:/workspace/xwork/src/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java =================================================================== --- C:/workspace/xwork/src/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java (revision 1324) +++ C:/workspace/xwork/src/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java (working copy) @@ -62,7 +62,7 @@ */ public DelegatingValidatorContext(Class clazz) { localeProvider = new ActionContextLocaleProvider(); - textProvider = new TextProviderSupport(clazz, localeProvider); + textProvider = TextProviderFactory.getInstance(clazz, localeProvider); validationAware = new LoggingValidationAware(clazz); } @@ -174,7 +174,7 @@ if (object instanceof TextProvider) { return (TextProvider) object; } else { - return new TextProviderSupport(object.getClass(), localeProvider); + return TextProviderFactory.getInstance(object.getClass(), localeProvider); } } Index: C:/workspace/xwork/src/java/com/opensymphony/xwork2/TextProviderFactory.java =================================================================== --- C:/workspace/xwork/src/java/com/opensymphony/xwork2/TextProviderFactory.java (revision 0) +++ C:/workspace/xwork/src/java/com/opensymphony/xwork2/TextProviderFactory.java (revision 0) @@ -0,0 +1,39 @@ +/** + * @author Oleg Gorobets + */ + +package com.opensymphony.xwork2; + +import java.util.ResourceBundle; + +public class TextProviderFactory { + + private static TextProvider instance = new TextProviderSupport(); + + /** + * @param instance Text provider + */ + public static void setInstance(TextProvider instance) { + TextProviderFactory.instance = instance; + } + + public static TextProvider getInstance() { + return instance; + } + + public static TextProvider getInstance(Class clazz, LocaleProvider provider) { + if (instance instanceof TextProviderSupport) { + ((TextProviderSupport)instance).setClazz(clazz); + ((TextProviderSupport)instance).setLocaleProvider(provider); + } + return instance; + } + + public static TextProvider getInstance(ResourceBundle bundle, LocaleProvider provider) { + if (instance instanceof TextProviderSupport) { + ((TextProviderSupport)instance).setBundle(bundle); + ((TextProviderSupport)instance).setLocaleProvider(provider); + } + return instance; + } +} Index: C:/workspace/xwork/src/java/com/opensymphony/xwork2/TextProviderSupport.java =================================================================== --- C:/workspace/xwork/src/java/com/opensymphony/xwork2/TextProviderSupport.java (revision 1324) +++ C:/workspace/xwork/src/java/com/opensymphony/xwork2/TextProviderSupport.java (working copy) @@ -23,29 +23,35 @@ private ResourceBundle bundle; - /** - * 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; - } + /** + * Default constructor + */ + public TextProviderSupport() { + } + + /** + * @param bundle the resource bundle. + */ + public void setBundle(ResourceBundle bundle) { + this.bundle = bundle; + } - /** - * Constructor. - * - * @param bundle the resource bundle. - * @param provider a locale provider. - */ - public TextProviderSupport(ResourceBundle bundle, LocaleProvider provider) { - this.bundle = bundle; - this.localeProvider = provider; - } + /** + * @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; + } + /** * Get a text from the resource bundles associated with this action. * The resource bundles are searched, starting with the one associated Index: C:/workspace/xwork/src/java/com/opensymphony/xwork2/ActionSupport.java =================================================================== --- C:/workspace/xwork/src/java/com/opensymphony/xwork2/ActionSupport.java (revision 1324) +++ C:/workspace/xwork/src/java/com/opensymphony/xwork2/ActionSupport.java (working copy) @@ -21,7 +21,7 @@ protected transient static final Log LOG = LogFactory.getLog(ActionSupport.class); - private transient final TextProvider textProvider = new TextProviderSupport(getClass(), this); + private transient final TextProvider textProvider = TextProviderFactory.getInstance(getClass(), this); private final ValidationAwareSupport validationAware = new ValidationAwareSupport();