aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-08-16 07:33:05 +0000
committerJeremias Maerki <jeremias@apache.org>2005-08-16 07:33:05 +0000
commita01bd24f499c140d4f89cdc86a13031bd72b12aa (patch)
tree55c0faad7fb36b08ca05adce6f0fbadcd5693681
parentcdef475945e30620d029fcb91813b2d681077a17 (diff)
downloadxmlgraphics-fop-a01bd24f499c140d4f89cdc86a13031bd72b12aa.tar.gz
xmlgraphics-fop-a01bd24f499c140d4f89cdc86a13031bd72b12aa.zip
Notify image cache about the expiration of a user agent (i.e. processing run).
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@232950 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index ae0ee8a8f..0aa4f4758 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -34,6 +34,7 @@ import org.apache.fop.render.RendererFactory;
import org.apache.fop.util.Service;
import org.apache.fop.fo.ElementMapping.Maker;
import org.apache.fop.fo.pagination.Root;
+import org.apache.fop.image.ImageFactory;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@@ -88,6 +89,9 @@ public class FOTreeBuilder extends DefaultHandler {
/** The SAX locator object managing the line and column counters */
private Locator locator;
+ /** The user agent for this processing run. */
+ private FOUserAgent userAgent;
+
/**
* FOTreeBuilder constructor
* @param renderType output type as defined in Constants class
@@ -98,6 +102,8 @@ public class FOTreeBuilder extends DefaultHandler {
public FOTreeBuilder(int renderType, FOUserAgent foUserAgent,
OutputStream stream) throws FOPException {
+ this.userAgent = foUserAgent;
+
//This creates either an AreaTreeHandler and ultimately a Renderer, or
//one of the RTF-, MIF- etc. Handlers.
foEventHandler = RendererFactory.createFOEventHandler(foUserAgent, renderType, stream);
@@ -154,8 +160,8 @@ public class FOTreeBuilder extends DefaultHandler {
throws IllegalArgumentException {
try {
- ElementMapping mapping =
- (ElementMapping)Class.forName(mappingClassName).newInstance();
+ ElementMapping mapping
+ = (ElementMapping)Class.forName(mappingClassName).newInstance();
addElementMapping(mapping);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -220,6 +226,9 @@ public class FOTreeBuilder extends DefaultHandler {
log.debug("Parsing of document complete");
}
foEventHandler.endDocument();
+
+ //Notify the image factory that this user agent has expired.
+ ImageFactory.getInstance().removeContext(this.userAgent);
}
/**
@@ -311,8 +320,8 @@ public class FOTreeBuilder extends DefaultHandler {
if (fobjMaker == null) {
if (namespaces.contains(namespaceURI.intern())) {
- throw new FOPException(FONode.errorText(locator) +
- "No element mapping definition found for "
+ throw new FOPException(FONode.errorText(locator)
+ + "No element mapping definition found for "
+ FONode.getNodeString(namespaceURI, localName), locator);
} else {
log.warn("Unknown formatting object " + namespaceURI + "^" + localName);
@@ -322,23 +331,17 @@ public class FOTreeBuilder extends DefaultHandler {
return fobjMaker;
}
- /**
- * org.xml.sax.ErrorHandler#warning
- **/
+ /** @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException) */
public void warning(SAXParseException e) {
log.warn(e.toString());
}
- /**
- * org.xml.sax.ErrorHandler#error
- **/
+ /** @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException) */
public void error(SAXParseException e) {
log.error(e.toString());
}
- /**
- * org.xml.sax.ErrorHandler#fatalError
- **/
+ /** @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException) */
public void fatalError(SAXParseException e) throws SAXException {
log.error(e.toString());
throw e;