cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdami...@apache.org
Subject svn commit: r1733441 - in /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n: XMLResourceBundle.java XMLResourceBundleFactory.java
Date Thu, 03 Mar 2016 10:56:24 GMT
Author: cdamioli
Date: Thu Mar  3 10:56:24 2016
New Revision: 1733441

URL: http://svn.apache.org/viewvc?rev=1733441&view=rev
Log:
COCOON-2349 XMLResourceBundles are not available outside a Request

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java?rev=1733441&r1=1733440&r2=1733441&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java Thu
Mar  3 10:56:24 2016
@@ -17,6 +17,7 @@
 package org.apache.cocoon.i18n;
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceResolver;
@@ -254,6 +255,16 @@ public class XMLResourceBundle extends A
      * @return true if reloaded successfully
      */
     protected boolean reload(SourceResolver resolver, long interval) {
+        return reload(null, resolver, interval);
+    }
+        
+        
+    /**
+     * (Re)Loads the XML bundle if necessary, based on the source URI.
+     * @return true if reloaded successfully
+     */
+    protected boolean reload(ServiceManager manager, SourceResolver resolver, long interval)
{
+
         Source newSource = null;
         Map newValues;
 
@@ -266,7 +277,11 @@ public class XMLResourceBundle extends A
 
                 if (valid == SourceValidity.INVALID || this.validity.isValid(newValidity)
!= SourceValidity.VALID) {
                     newValues = new HashMap();
-                    SourceUtil.toSAX(newSource, new SAXContentHandler(newValues));
+                    if (manager != null) {
+                        SourceUtil.toSAX(manager, newSource, null, new SAXContentHandler(newValues));
+                    } else {
+                        SourceUtil.toSAX(newSource, null, new SAXContentHandler(newValues));
+                    }
                     synchronized (this) {
                         // Update source validity and values
                         if (interval > 0 && newValidity != null) {

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java?rev=1733441&r1=1733440&r2=1733441&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
Thu Mar  3 10:56:24 2016
@@ -286,7 +286,7 @@ public class XMLResourceBundleFactory ex
 
         XMLResourceBundle bundle = new XMLResourceBundle(sourceURI, locale, parent);
         bundle.enableLogging(getLogger());
-        bundle.reload(this.resolver, this.interval);
+        bundle.reload(this.manager, this.resolver, this.interval);
         return bundle;
     }
 
@@ -411,7 +411,7 @@ public class XMLResourceBundleFactory ex
         if (bundle != null && this.interval != -1) {
             // Reload this bundle and all parent bundles, as necessary
             for (XMLResourceBundle b = bundle; b != null; b = (XMLResourceBundle) b.parent)
{
-                b.reload(this.resolver, this.interval);
+                b.reload(this.manager, this.resolver, this.interval);
             }
         }
 



Mime
View raw message