cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 35598 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n
Date Mon, 02 Aug 2004 18:37:58 GMT
Author: vgritsenko
Date: Mon Aug  2 11:37:57 2004
New Revision: 35598

Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/BundleFactory.java
   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
Log:
Sync with 2.2: Remove BundleFactory "extends ComponentSelector"


Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/BundleFactory.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/BundleFactory.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/BundleFactory.java	Mon Aug
 2 11:37:57 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,8 +17,8 @@
 
 import java.util.Locale;
 
+import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentSelector;
 
 /**
  * Bundle Factory implementations are responsible for loading and providing
@@ -26,9 +26,9 @@
  *
  * @author <a href="mailto:kpiroumian@apache.org">Konstantin Piroumian</a>
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id: BundleFactory.java,v 1.8 2004/03/05 13:02:56 bdelacretaz Exp $
+ * @version CVS $Id$
  */
-public interface BundleFactory extends ComponentSelector {
+public interface BundleFactory extends Component {
 
     /**
      * Bundle factory ROLE name
@@ -100,4 +100,6 @@
      * @exception     ComponentException if a bundle is not found
      */
     Bundle select(String bundleName, Locale locale) throws ComponentException;
+
+    void release(Bundle bundle);
 }

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/XMLResourceBundle.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java	Mon
Aug  2 11:37:57 2004
@@ -57,7 +57,7 @@
  * are instances of the {@link ParamSaxBuffer} class.
  * 
  * @author <a href="mailto:dev@cocoon.apache.org">Apache Cocoon Team</a>
- * @version CVS $Id: XMLResourceBundle.java,v 1.7 2004/03/05 13:02:56 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class XMLResourceBundle extends AbstractLogEnabled
                                implements Bundle, Serviceable {
@@ -116,7 +116,7 @@
     /**
      * Processes XML bundle file and creates map of values
      */
-    private class SAXContentHandler implements ContentHandler {
+    private static class SAXContentHandler implements ContentHandler {
         private Map values;
         private int state;
         private String namespace;

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
==============================================================================
--- 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
Mon Aug  2 11:37:57 2004
@@ -16,6 +16,7 @@
 package org.apache.cocoon.i18n;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
@@ -23,9 +24,7 @@
 
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.DefaultComponentSelector;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -35,10 +34,10 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.ResourceNotFoundException;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceResolver;
-import org.apache.cocoon.ResourceNotFoundException;
 import org.xml.sax.SAXParseException;
 
 /**
@@ -49,11 +48,13 @@
  * @author <a href="mailto:neeme@one.lv">Neeme Praks</a>
  * @author <a href="mailto:oleg@one.lv">Oleg Podolsky</a>
  * @author <a href="mailto:kpiroumian@apache.org">Konstantin Piroumian</a>
- * @version CVS $Id: XMLResourceBundleFactory.java,v 1.14 2004/04/29 01:00:43 crossley Exp
$
+ * @version CVS $Id$
  */
-public class XMLResourceBundleFactory extends DefaultComponentSelector
-        implements BundleFactory, Serviceable, Configurable, Disposable, ThreadSafe, LogEnabled
{
+public class XMLResourceBundleFactory
+       implements BundleFactory, Serviceable, Configurable, Disposable, ThreadSafe, LogEnabled
{
 
+    protected Map cache = Collections.synchronizedMap(new HashMap());
+    
     /**
      * Should we load bundles to cache on startup or not?
      */
@@ -108,7 +109,7 @@
     }
 
     public void dispose() {
-        Iterator i = getComponentMap().values().iterator();
+        Iterator i = this.cache.values().iterator();
         while (i.hasNext()) {
             Object bundle = i.next();
             if (bundle instanceof Disposable) {
@@ -321,7 +322,7 @@
         return null;
     }
 
-    public void release(Component component) {
+    public void release(Bundle bundle) {
         // Do nothing
     }
 
@@ -406,17 +407,18 @@
      */
     protected XMLResourceBundle selectCached(String fileName) {
         XMLResourceBundle bundle = null;
-        try {
-            bundle = (XMLResourceBundle)super.select(fileName);
+        bundle = (XMLResourceBundle)cache.get(fileName);
+        if (bundle != null) {
             bundle.update(fileName);
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Returning from cache: " + fileName);
             }
-        } catch (ComponentException e) {
+        } else {
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Not found in cache: " + fileName);
             }
         }
+
         return bundle;
     }
 
@@ -456,7 +458,7 @@
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Updating cache: " + fileName);
             }
-            super.put(fileName, bundle);
+            this.cache.put(fileName, bundle);
         }
     }
 }

Mime
View raw message