struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [01/17] struts git commit: Makes factory fully injectable
Date Mon, 13 Mar 2017 17:46:10 GMT
Repository: struts
Updated Branches:
  refs/heads/master 6b8272ce4 -> 8852e3d11


Makes factory fully injectable


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

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

----------------------------------------------------------------------
 .../xwork2/TextProviderFactory.java             | 29 ++++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/da5da67d/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java b/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
index 331d534..b00f451 100644
--- a/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
+++ b/core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java
@@ -28,44 +28,49 @@ import java.util.ResourceBundle;
 public class TextProviderFactory {
 
     private TextProvider textProvider;
+    private LocaleProvider localeProvider;
 
     @Inject
     public void setTextProvider(TextProvider textProvider) {
         this.textProvider = textProvider;
     }
 
-    public TextProvider createInstance(Class clazz, LocaleProvider provider) {
-        TextProvider instance = getTextProvider(clazz, provider);
+    @Inject
+    public void setLocaleProvider(LocaleProvider localeProvider) {
+        this.localeProvider = localeProvider;
+    }
+
+    public TextProvider createInstance(Class clazz) {
+        TextProvider instance = getTextProvider(clazz);
         if (instance instanceof ResourceBundleTextProvider) {
             ((ResourceBundleTextProvider) instance).setClazz(clazz);
-            ((ResourceBundleTextProvider) instance).setLocaleProvider(provider);
+            ((ResourceBundleTextProvider) instance).setLocaleProvider(localeProvider);
         }
         return instance;
     }
 
-    public TextProvider createInstance(ResourceBundle bundle, LocaleProvider provider) {
-        TextProvider instance = getTextProvider(bundle, provider);
+    public TextProvider createInstance(ResourceBundle bundle) {
+        TextProvider instance = getTextProvider(bundle);
         if (instance instanceof ResourceBundleTextProvider) {
             ((ResourceBundleTextProvider) instance).setBundle(bundle);
-            ((ResourceBundleTextProvider) instance).setLocaleProvider(provider);
+            ((ResourceBundleTextProvider) instance).setLocaleProvider(localeProvider);
         }
         return instance;
     }
 
-    protected TextProvider getTextProvider(Class clazz, LocaleProvider provider) {
+    protected TextProvider getTextProvider(Class clazz) {
         if (this.textProvider == null) {
-            return new TextProviderSupport(clazz, provider);
+            return new TextProviderSupport(clazz, localeProvider);
         } else {
             return textProvider;
         }
     }
 
-    private TextProvider getTextProvider(ResourceBundle bundle, LocaleProvider provider)
{
+    private TextProvider getTextProvider(ResourceBundle bundle) {
         if (this.textProvider == null) {
-            return new TextProviderSupport(bundle, provider);
-        } else {
-            return textProvider;
+            textProvider = new TextProviderSupport(bundle, localeProvider);
         }
+        return textProvider;
     }
 
 }


Mime
View raw message