stephan 2002/08/22 06:47:14 Modified: src/scratchpad/src/org/apache/cocoon/generation SourceDescriptionGenerator.java Log: Recycle Hashtable. Revision Changes Path 1.14 +15 -11 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java Index: SourceDescriptionGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- SourceDescriptionGenerator.java 21 Aug 2002 15:35:47 -0000 1.13 +++ SourceDescriptionGenerator.java 22 Aug 2002 13:47:14 -0000 1.14 @@ -165,7 +165,7 @@ private int deep = 1; /** Traversed source for the keys and validities */ - private Hashtable cachedsources = null; + private Hashtable cachedsources = new Hashtable(); /** * Set the <code>SourceResolver</code>, objectModel <code>Map</code>, @@ -173,6 +173,7 @@ */ public void setup(SourceResolver resolver, Map objectModel, String location, Parameters parameters) throws ProcessingException, SAXException, IOException { + super.setup(resolver, objectModel, location, parameters); this.properties = parameters.getParameterAsBoolean("properties", true); @@ -180,7 +181,6 @@ this.locks = parameters.getParameterAsBoolean("locks", true); this.version = parameters.getParameterAsBoolean("version", true); - this.cachedsources = new Hashtable(); collectSources(this.cachedsources, this.source, this.deep); } @@ -191,6 +191,7 @@ * @return The generated key hashes the src */ public Serializable generateKey() { + StringBuffer key = new StringBuffer(); key.append("SDG("); @@ -204,6 +205,7 @@ } key.append(")"); + return key.toString(); } @@ -214,6 +216,7 @@ * component is currently not cacheable. */ public SourceValidity generateValidity() { + AggregatedValidity validity = new AggregatedValidity(); Source source; @@ -233,8 +236,8 @@ Source source = null; try { source = this.resolver.resolveURI(uri); - } catch (Exception urle) { - // ignore + } catch (Exception e) { + getLogger().warn("Could not retrieve source with the id '"+uri+"'", e); return; } @@ -248,7 +251,7 @@ for(int i=0; i<traversablesource.getChildSourceCount(); i++) collectSources(sources, traversablesource.getChildSource(i), deep-1); } catch (SourceException se) { - // ignore + getLogger().warn("Could not traverse source", se); } } } @@ -495,11 +498,12 @@ * All instance variables are set to <code>null</code>. */ public void recycle() { - if (cachedsources!=null) { - for (Enumeration e = cachedsources.elements(); e.hasMoreElements();) { - this.resolver.release((Source)e.nextElement()); - } - cachedsources = null; + + Object uri; + for (Enumeration e = cachedsources.keys(); e.hasMoreElements();) { + uri = e.nextElement(); + this.resolver.release((Source)cachedsources.get(uri)); + cachedsources.remove(uri); } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]