mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Merge pull request #178 from lukaszlenart/text-provider-resurection
WW-4884: Allow define just a TextProvider
This commit is contained in:
@@ -29,6 +29,7 @@ public class StrutsTextProviderFactory implements TextProviderFactory {
|
||||
|
||||
protected LocaleProviderFactory localeProviderFactory;
|
||||
protected LocalizedTextProvider localizedTextProvider;
|
||||
protected TextProvider defaultTextProvider;
|
||||
|
||||
@Inject
|
||||
public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory) {
|
||||
@@ -40,6 +41,11 @@ public class StrutsTextProviderFactory implements TextProviderFactory {
|
||||
this.localizedTextProvider = localizedTextProvider;
|
||||
}
|
||||
|
||||
@Inject(required = false)
|
||||
public void setDefaultTextProvider(TextProvider defaultTextProvider) {
|
||||
this.defaultTextProvider = defaultTextProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextProvider createInstance(Class clazz) {
|
||||
TextProvider instance = getTextProvider(clazz);
|
||||
@@ -61,10 +67,18 @@ public class StrutsTextProviderFactory implements TextProviderFactory {
|
||||
}
|
||||
|
||||
protected TextProvider getTextProvider(Class clazz) {
|
||||
if (defaultTextProvider != null) {
|
||||
return defaultTextProvider;
|
||||
}
|
||||
|
||||
return new TextProviderSupport(clazz, localeProviderFactory.createLocaleProvider(), localizedTextProvider);
|
||||
}
|
||||
|
||||
protected TextProvider getTextProvider(ResourceBundle bundle) {
|
||||
if (defaultTextProvider != null) {
|
||||
return defaultTextProvider;
|
||||
}
|
||||
|
||||
return new TextProviderSupport(bundle, localeProviderFactory.createLocaleProvider(), localizedTextProvider);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,11 @@ public final class StrutsConstants {
|
||||
|
||||
public static final String STRUTS_ALWAYS_SELECT_FULL_NAMESPACE = "struts.mapper.alwaysSelectFullNamespace";
|
||||
|
||||
/** XWork default text provider */
|
||||
/**
|
||||
* XWork default text provider
|
||||
* @deprecated use {@link #STRUTS_TEXT_PROVIDER} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String STRUTS_XWORKTEXTPROVIDER = "struts.xworkTextProvider";
|
||||
|
||||
/**
|
||||
@@ -319,8 +323,8 @@ public final class StrutsConstants {
|
||||
|
||||
public static final String STRUTS_SMI_METHOD_REGEX = "struts.strictMethodInvocation.methodRegex";
|
||||
|
||||
public static final String STRUTS_TEXT_PROVIDER = "struts.textProvider";
|
||||
public static final String STRUTS_TEXT_PROVIDER_FACTORY = "struts.textProviderFactory";
|
||||
|
||||
public static final String STRUTS_LOCALIZED_TEXT_PROVIDER = "struts.localizedTextProvider";
|
||||
|
||||
public static final String STRUTS_DISALLOW_PROXY_MEMBER_ACCESS = "struts.disallowProxyMemberAccess";
|
||||
|
||||
@@ -395,6 +395,7 @@ public class DefaultBeanSelectionProvider extends AbstractBeanSelectionProvider
|
||||
alias(TypeConverterHolder.class, StrutsConstants.STRUTS_CONVERTER_HOLDER, builder, props);
|
||||
|
||||
alias(TextProvider.class, StrutsConstants.STRUTS_XWORKTEXTPROVIDER, builder, props, Scope.PROTOTYPE);
|
||||
alias(TextProvider.class, StrutsConstants.STRUTS_TEXT_PROVIDER, builder, props, Scope.PROTOTYPE);
|
||||
alias(TextProviderFactory.class, StrutsConstants.STRUTS_TEXT_PROVIDER_FACTORY, builder, props, Scope.PROTOTYPE);
|
||||
alias(LocaleProviderFactory.class, StrutsConstants.STRUTS_LOCALE_PROVIDER_FACTORY, builder, props);
|
||||
alias(LocalizedTextProvider.class, StrutsConstants.STRUTS_LOCALIZED_TEXT_PROVIDER, builder, props);
|
||||
|
||||
Reference in New Issue
Block a user