From: Adrian Cumiskey FOUserAgent
.
-+ */
-+ protected FOUserAgent userAgent;
-+
-+ /**
- * The current Renderer
.
- */
- protected Renderer renderer;
-@@ -145,24 +160,6 @@
- public void configure(Configuration conf) throws ConfigurationException {
-
- this.logger = getLogger().getChildLogger("fop");
-- MessageHandler.setScreenLogger(this.logger);
--
-- // FIXME: VG: Initialize static FOP configuration with defaults, only once.
-- // FOP has static config, but that's going to change in the near future.
-- // Then this code should be reviewed.
-- synchronized (FOPSerializer.class) {
-- if (!configured) {
-- try {
-- if (getLogger().isDebugEnabled()) {
-- getLogger().debug("Loading default configuration");
-- }
-- new Options();
-- } catch (Exception e) {
-- getLogger().error("Cannot load default configuration. Proceeding.", e);
-- }
-- configured = true;
-- }
-- }
-
- this.setContentLength = conf.getChild("set-content-length").getValueAsBoolean(true);
-
-@@ -180,28 +177,6 @@
- // New syntax: Element user-config contains URL
- configUrl = conf.getChild("user-config").getValue(null);
- }
-- if(configUrl != null) {
-- URLFactory urlFactory = null;
-- Source configSource = null;
-- try {
-- // FIXME: How to do without URLFactory but relative to context?
-- urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
-- URLFactorySourceResolver urlResolver = new URLFactorySourceResolver(urlFactory, manager);
-- configSource = urlResolver.resolve(configUrl);
-- if (getLogger().isDebugEnabled()) {
-- getLogger().debug("Loading configuration from " + configSource.getSystemId());
-- }
-- configSource.toSAX(new ConfigurationParser());
-- } catch (Exception e) {
-- getLogger().warn("Cannot load configuration from " + configUrl);
-- throw new ConfigurationException("Cannot load configuration from " + configUrl, e);
-- } finally {
-- manager.release(urlFactory);
-- if (configSource != null) {
-- configSource.recycle();
-- }
-- }
-- }
-
- // Get the mime type.
- this.mimetype = conf.getAttribute("mime-type");
-@@ -233,6 +208,22 @@
- + "no renderer was specified in the sitemap configuration."
- );
- }
-+ this.renderer.setCreator("Cocoon");
-+
-+ userAgent = new FOUserAgent();
-+ userAgent.enableLogging(this.logger);
-+ //userAgent.setBaseURL(source.getSystemId());
-+
-+ // load the fop driver
-+ this.driver = new Driver();
-+ driver.enableLogging(this.logger);
-+ driver.setUserAgent(userAgent);
-+
-+ driver.setRenderer(this.renderer);
-+
-+ //driver.configure(conf);
-+ driver.initialize();
-+
- }
-
- /**
-@@ -242,27 +233,39 @@
- return mimetype;
- }
-
-+ public void setup(final org.apache.cocoon.environment.SourceResolver resolver, Map objectModel)
-+ throws ProcessingException, SAXException, IOException {
-+
-+ userAgent = new FOUserAgent() {
-+ public InputStream getStream(String uri) {
-+ try {
-+ Environment env = (Environment) resolver;
-+ org.apache.cocoon.environment.Source source = null;
-+ org.apache.cocoon.components.source.CocoonSourceFactory ccf;
-+ ccf = new org.apache.cocoon.components.source.CocoonSourceFactory(null, manager);
-+ ccf.enableLogging(logger);
-+ source = ccf.getSource(env, "/" + uri);
-+ getLogger().debug("Loading image from " + source.getSystemId());
-+ InputStream is = source.getInputStream();
-+ getLogger().debug("input stream: " + is + ":" + is.available());
-+ return is;
-+ } catch (Exception e) {
-+ getLogger().error("Cannot load source", e);
-+ }
-+ return null;
-+ }
-+ };
-+ userAgent.enableLogging(this.logger);
-+ //userAgent.setBaseURL(source.getSystemId());
-+
-+ driver.setUserAgent(userAgent);
-+ }
-+
- /**
- * Create the FOP driver
- * Set the OutputStream
where the XML should be serialized.
- */
- public void setOutputStream(OutputStream out) {
-- // load the fop driver
-- this.driver = new Driver();
-- this.driver.setLogger(this.logger);
-- if (this.rendererName == null) {
-- this.renderer = factory.createRenderer(mimetype);
-- } else {
-- try {
-- this.renderer = (Renderer)ClassUtils.newInstance(this.rendererName);
-- } catch (Exception e) {
-- if (getLogger().isWarnEnabled()) {
-- getLogger().warn("Cannot load class " + this.rendererName, e);
-- }
-- throw new CascadingRuntimeException("Cannot load class " + this.rendererName, e);
-- }
-- }
-- this.driver.setRenderer(this.renderer);
- this.driver.setOutputStream(out);
- setContentHandler(this.driver.getContentHandler());
- }
-@@ -296,8 +299,7 @@
- */
- public void recycle() {
- super.recycle();
-- this.driver = null;
-- this.renderer = null;
-+ this.driver.reset();
- }
-
- /**
-@@ -307,3 +309,4 @@
- return this.setContentLength;
- }
- }
-+
-Index: src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
-===================================================================
-RCS file: /home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
-retrieving revision 1.24
-diff -u -r1.24 AbstractProcessingPipeline.java
---- src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java 11 Oct 2002 08:36:30 -0000 1.24
-+++ src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java 5 Dec 2002 09:21:13 -0000
-@@ -62,6 +62,7 @@
- import org.apache.cocoon.ConnectionResetException;
- import org.apache.cocoon.ProcessingException;
- import org.apache.cocoon.components.CocoonComponentManager;
-+import org.apache.cocoon.components.RequestLifecycleComponent;
- import org.apache.cocoon.components.treeprocessor.ProcessingNode;
- import org.apache.cocoon.environment.Environment;
- import org.apache.cocoon.environment.ObjectModelHelper;
-@@ -392,6 +393,15 @@
- environment.getObjectModel(),
- (String)transformerSourceItt.next(),
- (Parameters)transformerParamItt.next()
-+ );
-+ }
-+
-+ // WARNING: quick hack
-+ // setup the serializer
-+ if(this.serializer instanceof RequestLifecycleComponent) {
-+ ((RequestLifecycleComponent)this.serializer).setup(
-+ environment,
-+ environment.getObjectModel()
- );
- }
-
diff --git a/src/documentation/content/xdocs/0.95/graphics.xml b/src/documentation/content/xdocs/0.95/graphics.xml
index dce05aa47..5ecca1ea8 100644
--- a/src/documentation/content/xdocs/0.95/graphics.xml
+++ b/src/documentation/content/xdocs/0.95/graphics.xml
@@ -554,10 +554,14 @@
changing dummy parameter on the URI to avoid caching.
- The image cache has been improved considerably in the redesigned code. Therefore, a - resetCache() method like in earlier versions of FOP has become unnecessary. If you + The image cache has been improved considerably in the redesigned code. Therefore, + resetting the image cache should be a thing of the past. If you still experience OutOfMemoryErrors, please notify us.
+
+ If all else fails, the image cache can be cleared like this:
+ fopFactory.getImageManager().getCache().clearCache();
+