struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [02/17] struts git commit: Uses the new injectable factory to obtain TextProvider
Date Mon, 13 Mar 2017 17:46:11 GMT
Uses the new injectable factory to obtain TextProvider


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/db8ebe71
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/db8ebe71
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/db8ebe71

Branch: refs/heads/master
Commit: db8ebe710d1aaa815006d070b9dda4930a9d152a
Parents: da5da67
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Fri Mar 10 08:39:55 2017 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Fri Mar 10 08:39:55 2017 +0100

----------------------------------------------------------------------
 .../validator/DelegatingValidatorContext.java   | 30 +++++---------------
 1 file changed, 7 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/db8ebe71/core/src/main/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java
b/core/src/main/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java
index abaa761..a9a8b04 100644
--- a/core/src/main/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java
+++ b/core/src/main/java/com/opensymphony/xwork2/validator/DelegatingValidatorContext.java
@@ -57,10 +57,10 @@ public class DelegatingValidatorContext implements ValidatorContext {
      *
      * @param object the object to use for validation (usually an Action).
      */
-    public DelegatingValidatorContext(Object object) {
+    public DelegatingValidatorContext(Object object, TextProviderFactory textProviderFactory)
{
         this.localeProvider = makeLocaleProvider(object);
         this.validationAware = makeValidationAware(object);
-        this.textProvider = makeTextProvider(object, localeProvider);
+        this.textProvider = makeTextProvider(object, textProviderFactory);
     }
 
     /**
@@ -71,7 +71,7 @@ public class DelegatingValidatorContext implements ValidatorContext {
      */
     public DelegatingValidatorContext(Class clazz) {
         localeProvider = new ActionContextLocaleProvider();
-        textProvider = new TextProviderFactory().createInstance(clazz, localeProvider);
+        textProvider = new TextProviderFactory().createInstance(clazz);
         validationAware = new LoggingValidationAware(clazz);
     }
 
@@ -193,18 +193,11 @@ public class DelegatingValidatorContext implements ValidatorContext
{
         return validationAware.hasFieldErrors();
     }
 
-    public static TextProvider makeTextProvider(Object object, LocaleProvider localeProvider)
{
+    public static TextProvider makeTextProvider(Object object, TextProviderFactory textProviderFactory)
{
         // the object argument passed through here will most probably be an ActionSupport
descendant which does
         // implements TextProvider.
         if (object != null && object instanceof DelegatingValidatorContext) {
             return ((DelegatingValidatorContext) object).getTextProvider();
-        } else if (object != null && localeProvider != null && localeProvider
instanceof DelegatingValidatorContext) {
-            return new CompositeTextProvider(new TextProvider[]{
-                    new TextProviderFactory().createInstance(object.getClass(), localeProvider),
-                    ((DelegatingValidatorContext)localeProvider).getTextProvider()
-            });
-        } else if (localeProvider != null && localeProvider instanceof DelegatingValidatorContext)
{
-            return ((DelegatingValidatorContext)localeProvider).getTextProvider();
         }
 
         if ((object != null) && (object instanceof TextProvider)) {
@@ -213,20 +206,11 @@ public class DelegatingValidatorContext implements ValidatorContext
{
             }
             return new CompositeTextProvider(new TextProvider[]{
                     ((TextProvider) object),
-                    new TextProviderSupport(object.getClass(), localeProvider)
-            });
-        } else if (localeProvider != null && localeProvider instanceof TextProvider)
{
-            if (localeProvider instanceof CompositeTextProvider) {
-                return (CompositeTextProvider) localeProvider;
-            }
-            return new CompositeTextProvider(new TextProvider[]{
-                    ((TextProvider) localeProvider),
-                    new TextProviderSupport(localeProvider.getClass(), localeProvider)
+                    textProviderFactory.createInstance(object.getClass())
             });
         } else {
-            return new TextProviderFactory().createInstance(
-                    object != null ? object.getClass() : DelegatingValidatorContext.class,
-                    localeProvider);
+            return textProviderFactory.createInstance(
+                    object != null ? object.getClass() : DelegatingValidatorContext.class);
         }
     }
 


Mime
View raw message