vgritsenko 2003/09/23 15:46:44
Modified: src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
src/java/org/apache/cocoon/components/language/markup/xsp
XSPUtil.java
src/java/org/apache/cocoon/generation
XPathDirectoryGenerator.java
src/java/org/apache/cocoon/transformation
XIncludeTransformer.java
src/java/org/apache/cocoon/transformation/pagination
Paginator.java
src/java/org/apache/cocoon/xml XMLBaseSupport.java
Log:
release sources
Revision Changes Path
1.8 +7 -9
cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
Index: FOM_JavaScriptInterpreter.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FOM_JavaScriptInterpreter.java 14 Aug 2003 21:48:40 -0000 1.7
+++ FOM_JavaScriptInterpreter.java 23 Sep 2003 22:46:44 -0000 1.8
@@ -154,7 +154,7 @@
}
public Script getScript(Context context, Scriptable scope,
- boolean refresh)
+ boolean refresh)
throws Exception {
if (refresh) {
source.refresh();
@@ -166,14 +166,15 @@
return script;
}
}
+
/**
* Mapping of String objects (source uri's) to ScriptSourceEntry's
- *
*/
Map compiledScripts = new HashMap();
JSErrorReporter errorReporter;
boolean enableDebugger = false;
+
/**
* JavaScript debugger: there's only one of these: it can debug multiple
* threads executing JS code.
@@ -244,8 +245,7 @@
// Access to Cocoon internal objects
FOM_Cocoon.init(scope);
errorReporter = new JSErrorReporter(getLogger());
- }
- catch (Exception e) {
+ } catch (Exception e) {
Context.exit();
e.printStackTrace();
throw e;
@@ -323,14 +323,12 @@
return "ThreadScope";
}
- public void put(String name, Scriptable start,
- Object value) {
+ public void put(String name, Scriptable start, Object value) {
useSession = true;
super.put(name, start, value);
}
- public void put(int index, Scriptable start,
- Object value) {
+ public void put(int index, Scriptable start, Object value) {
useSession = true;
super.put(index, start, value);
}
1.7 +2 -4
cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java
Index: XSPUtil.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSPUtil.java 11 Jun 2003 23:15:56 -0000 1.6
+++ XSPUtil.java 23 Sep 2003 22:46:44 -0000 1.7
@@ -256,9 +256,7 @@
try {
return getContents(source.getInputStream());
} finally {
- if (source != null) {
- resolver.release(source);
- }
+ resolver.release(source);
}
}
1.4 +18 -14
cocoon-2.1/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
Index: XPathDirectoryGenerator.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XPathDirectoryGenerator.java 3 Sep 2003 15:00:56 -0000 1.3
+++ XPathDirectoryGenerator.java 23 Sep 2003 22:46:44 -0000 1.4
@@ -143,17 +143,17 @@
// See if an XPath was specified
this.xpath = par.getParameter("xpath", null);
this.cacheKeyParList.add(this.xpath);
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Applying XPath: " + this.xpath
- + " to directory " + this.source);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Applying XPath: " + this.xpath +
+ " to directory " + this.source);
}
String xmlFilesPattern = null;
try {
xmlFilesPattern = par.getParameter("xmlFiles", "\\.xml$");
this.cacheKeyParList.add(xmlFilesPattern);
this.xmlRE = new RE(xmlFilesPattern);
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("pattern for XML files: " +
xmlFilesPattern);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("pattern for XML files: " +
xmlFilesPattern);
}
} catch (RESyntaxException rese) {
throw new ProcessingException("Syntax error in regexp pattern '"
@@ -189,7 +189,7 @@
protected void startNode(String nodeName, File path) throws SAXException
{
super.startNode(nodeName, path);
if (this.xpath != null && path.isFile() && this.isXML(path)) {
- this.performXPathQuery(path);
+ performXPathQuery(path);
}
}
@@ -210,19 +210,23 @@
*/
protected void performXPathQuery(File xmlFile) throws SAXException {
this.doc = null;
+ Source source = null;
try {
- Source source =
resolver.resolveURI(xmlFile.toURL().toExternalForm());
+ source = resolver.resolveURI(xmlFile.toURL().toExternalForm());
this.doc =
this.parser.parseDocument(SourceUtil.getInputSource(source));
} catch (SAXException e) {
- this.getLogger().error("Warning:" + xmlFile.getName()
- + " is not a valid XML file. Ignoring.",
e);
+ getLogger().error("Warning:" + xmlFile.getName() +
+ " is not a valid XML file. Ignoring.", e);
} catch (ProcessingException e) {
- this.getLogger().error("Warning: Problem while reading the file "
- + xmlFile.getName() + ". Ignoring.", e);
+ getLogger().error("Warning: Problem while reading the file " +
+ xmlFile.getName() + ". Ignoring.", e);
} catch (IOException e) {
- this.getLogger().error("Warning: Problem while reading the file "
- + xmlFile.getName() + ". Ignoring.", e);
+ getLogger().error("Warning: Problem while reading the file " +
+ xmlFile.getName() + ". Ignoring.", e);
+ } finally {
+ resolver.release(source);
}
+
if (doc != null) {
NodeList nl =
this.processor.selectNodeList(this.doc.getDocumentElement(), this.xpath);
AttributesImpl attributes = new AttributesImpl();
1.9 +7 -4
cocoon-2.1/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
Index: XIncludeTransformer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XIncludeTransformer.java 22 Sep 2003 20:10:47 -0000 1.8
+++ XIncludeTransformer.java 23 Sep 2003 22:46:44 -0000 1.9
@@ -442,19 +442,22 @@
} catch (SourceException se) {
throw SourceUtil.handle(se);
} finally {
- if (url != null)
+ if (url != null) {
resolver.release(url);
+ }
}
}
public boolean isLoopInclusion(String uri) {
- if (uri.equals(this.href))
+ if (uri.equals(this.href)) {
return true;
+ }
XIncludePipe parent = getParent();
while (parent != null) {
- if (uri.equals(parent.getHref()))
+ if (uri.equals(parent.getHref())) {
return true;
+ }
parent = parent.getParent();
}
return false;
1.2 +15 -4
cocoon-2.1/src/java/org/apache/cocoon/transformation/pagination/Paginator.java
Index: Paginator.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/pagination/Paginator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Paginator.java 27 Jun 2003 20:10:42 -0000 1.1
+++ Paginator.java 23 Sep 2003 22:46:44 -0000 1.2
@@ -95,6 +95,7 @@
private ComponentManager manager;
private SAXParser parser;
private Store store;
+ private SourceResolver resolver;
private Source inputSource;
private int page;
private int item;
@@ -147,13 +148,14 @@
throws ProcessingException, SAXException,
IOException {
- if (src==null) {
+ if (src == null) {
throw new ProcessingException("I need the paginate instructions
(pagesheet) to continue. Set the 'src' attribute.");
}
try {
this.level = 0;
this.prefixMapping = false;
+ this.resolver = resolver;
this.inputSource = resolver.resolveURI(src);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Using pagesheet: '"+
@@ -195,9 +197,18 @@
// implementation is not reentrant.
this.pagesheet = (Pagesheet) this.pagesheet.clone();
} catch (SourceException se) {
- throw new ProcessingException("Could not retrieve source '"+src+
- "'", se);
+ throw new ProcessingException("Could not retrieve source '" +
+ src + "'", se);
}
+ }
+
+ public void recycle() {
+ if (null != this.inputSource) {
+ this.resolver.release(this.inputSource);
+ this.inputSource = null;
+ }
+ this.resolver = null;
+ super.recycle();
}
/**
1.4 +6 -3
cocoon-2.1/src/java/org/apache/cocoon/xml/XMLBaseSupport.java
Index: XMLBaseSupport.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/xml/XMLBaseSupport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XMLBaseSupport.java 4 Jul 2003 13:55:10 -0000 1.3
+++ XMLBaseSupport.java 23 Sep 2003 22:46:44 -0000 1.4
@@ -107,8 +107,9 @@
baseSource = resolve(getCurrentBase(), base);
baseUrl = baseSource.getURI();
} finally {
- if (baseSource != null)
+ if (baseSource != null) {
resolver.release(baseSource);
+ }
}
bases.push(new BaseInfo(baseUrl, level));
}
@@ -131,8 +132,10 @@
} else {
source = resolver.resolveURI(location);
}
- if (logger.isDebugEnabled())
- logger.debug("XMLBaseSupport: resolved location " + location
+ " against base URI " + baseURI + " to " + source.getURI());
+ if (logger.isDebugEnabled()) {
+ logger.debug("XMLBaseSupport: resolved location " + location
+
+ " against base URI " + baseURI + " to " +
source.getURI());
+ }
return source;
} catch (IOException e) {
throw new SAXException("XMLBaseSupport: problem resolving uri.",
e);