struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [07/16] struts git commit: Injects proper dependencies into tag
Date Fri, 24 Mar 2017 09:10:02 GMT
Injects proper dependencies into tag


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

Branch: refs/heads/master
Commit: 944b1a2303536023973456d6685f9ab86a775cb0
Parents: 16d1d60
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Fri Mar 17 07:59:50 2017 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Fri Mar 17 07:59:50 2017 +0100

----------------------------------------------------------------------
 .../org/apache/struts2/components/I18n.java     | 27 ++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/944b1a23/core/src/main/java/org/apache/struts2/components/I18n.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/I18n.java b/core/src/main/java/org/apache/struts2/components/I18n.java
index faacea4..497fff8 100644
--- a/core/src/main/java/org/apache/struts2/components/I18n.java
+++ b/core/src/main/java/org/apache/struts2/components/I18n.java
@@ -90,28 +90,35 @@ public class I18n extends Component {
 
     protected boolean pushed;
     protected String name;
-    protected Container container;
+
+    private LocalizedTextProvider localizedTextProvider;
     private TextProvider textProvider;
     private TextProvider defaultTextProvider;
-    private LocaleProvider localeProvider;
+    private LocaleProviderFactory localeProviderFactory;
+    private TextProviderFactory textProviderFactory;
 
     public I18n(ValueStack stack) {
         super(stack);
     }
-    
+
     @Inject
-    public void setContainer(Container container) {
-        this.container = container;
+    public void setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider) {
+        this.localizedTextProvider = localizedTextProvider;
     }
 
-    @Inject
+    @Inject("system")
     public void setTextProvider(TextProvider textProvider) {
         this.defaultTextProvider = textProvider;
     }
 
     @Inject
+    public void setTextProviderFactory(TextProviderFactory textProviderFactory) {
+        this.textProviderFactory = textProviderFactory;
+    }
+
+    @Inject
     public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory) {
-        this.localeProvider = localeProviderFactory.createLocaleProvider();
+        this.localeProviderFactory = localeProviderFactory;
     }
 
     public boolean start(Writer writer) {
@@ -122,12 +129,12 @@ public class I18n extends Component {
             ResourceBundle bundle = defaultTextProvider.getTexts(name);
 
             if (bundle == null) {
-                bundle = container.getInstance(LocalizedTextProvider.class).findResourceBundle(name,
localeProvider.getLocale());
+                LocaleProvider localeProvider = localeProviderFactory.createLocaleProvider();
+                bundle = localizedTextProvider.findResourceBundle(name, localeProvider.getLocale());
             }
 
             if (bundle != null) {
-                TextProviderFactory tpf = container.getInstance(TextProviderFactory.class);
-                textProvider = tpf.createInstance(bundle);
+                textProvider = textProviderFactory.createInstance(bundle);
                 getStack().push(textProvider);
                 pushed = true;
             }


Mime
View raw message