struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4884) Allow define only TextProvider instead of providing the whole TextProviderFactory
Date Fri, 27 Oct 2017 12:34:01 GMT

    [ https://issues.apache.org/jira/browse/WW-4884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16222280#comment-16222280
] 

ASF GitHub Bot commented on WW-4884:
------------------------------------

lukaszlenart closed pull request #178: WW-4884: Allow define just a TextProvider
URL: https://github.com/apache/struts/pull/178
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/com/opensymphony/xwork2/StrutsTextProviderFactory.java b/core/src/main/java/com/opensymphony/xwork2/StrutsTextProviderFactory.java
index e7d22d99a..a2d2fa3a9 100644
--- a/core/src/main/java/com/opensymphony/xwork2/StrutsTextProviderFactory.java
+++ b/core/src/main/java/com/opensymphony/xwork2/StrutsTextProviderFactory.java
@@ -29,6 +29,7 @@
 
     protected LocaleProviderFactory localeProviderFactory;
     protected LocalizedTextProvider localizedTextProvider;
+    protected TextProvider defaultTextProvider;
 
     @Inject
     public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory) {
@@ -40,6 +41,11 @@ public void setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider
         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 TextProvider createInstance(ResourceBundle bundle) {
     }
 
     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);
     }
 
diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java
index 970f52b0b..6ee09ffb6 100644
--- a/core/src/main/java/org/apache/struts2/StrutsConstants.java
+++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java
@@ -202,7 +202,11 @@
 
     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 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";
diff --git a/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
b/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
index 8249a0667..fb780037b 100644
--- a/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
+++ b/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
@@ -395,6 +395,7 @@ public void register(ContainerBuilder builder, LocatableProperties props)
{
         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);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Allow define only TextProvider instead of providing the whole TextProviderFactory
> ---------------------------------------------------------------------------------
>
>                 Key: WW-4884
>                 URL: https://issues.apache.org/jira/browse/WW-4884
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 2.5.13
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Minor
>             Fix For: 2.5.14
>
>
> It isn't possible to define just a new instance of {{TextProvider}} and use, user must
define the whole stack - {{TextProvider}} and {{TextProviderFactory}} which can be overwhelming.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message