|
|
@@ -1,240 +0,0 @@ |
|
|
|
Index: src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java |
|
|
|
=================================================================== |
|
|
|
RCS file: /home/cvspublic/xml-cocoon2/src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java,v |
|
|
|
retrieving revision 1.4 |
|
|
|
diff -u -r1.4 FOPSerializer.java |
|
|
|
--- src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java 21 Nov 2002 18:18:48 -0000 1.4 |
|
|
|
+++ src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java 5 Dec 2002 09:21:13 -0000 |
|
|
|
@@ -63,18 +63,28 @@ |
|
|
|
import org.apache.cocoon.components.url.URLFactory; |
|
|
|
import org.apache.cocoon.util.ClassUtils; |
|
|
|
import org.apache.cocoon.environment.URLFactorySourceResolver; |
|
|
|
-import org.apache.cocoon.environment.Source; |
|
|
|
+import org.apache.cocoon.environment.Environment; |
|
|
|
+import org.apache.excalibur.source.Source; |
|
|
|
+import org.apache.excalibur.source.SourceResolver; |
|
|
|
import org.apache.excalibur.source.SourceValidity; |
|
|
|
import org.apache.excalibur.source.impl.validity.NOPValidity; |
|
|
|
import org.apache.fop.apps.Driver; |
|
|
|
-import org.apache.fop.apps.Options; |
|
|
|
-import org.apache.fop.messaging.MessageHandler; |
|
|
|
import org.apache.fop.render.Renderer; |
|
|
|
-import org.apache.fop.configuration.ConfigurationParser; |
|
|
|
+import org.apache.fop.fo.FOUserAgent; |
|
|
|
+import org.apache.cocoon.components.RequestLifecycleComponent; |
|
|
|
+import org.apache.avalon.framework.component.Component; |
|
|
|
+import org.apache.cocoon.ProcessingException; |
|
|
|
+import org.xml.sax.SAXException; |
|
|
|
+import org.apache.cocoon.components.RequestLifecycleComponent; |
|
|
|
+ |
|
|
|
+import java.io.IOException; |
|
|
|
+import java.util.Map; |
|
|
|
|
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.Serializable; |
|
|
|
+import java.io.InputStream; |
|
|
|
+import java.net.URL; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -84,7 +94,7 @@ |
|
|
|
*/ |
|
|
|
public class FOPSerializer |
|
|
|
extends AbstractSerializer |
|
|
|
-implements Composable, Configurable, CacheableProcessingComponent { |
|
|
|
+implements Composable, Configurable, CacheableProcessingComponent, RequestLifecycleComponent { |
|
|
|
|
|
|
|
/** |
|
|
|
* The Renderer Factory to use |
|
|
|
@@ -97,6 +107,11 @@ |
|
|
|
protected Driver driver; |
|
|
|
|
|
|
|
/** |
|
|
|
+ * The current <code>FOUserAgent</code>. |
|
|
|
+ */ |
|
|
|
+ protected FOUserAgent userAgent; |
|
|
|
+ |
|
|
|
+ /** |
|
|
|
* The current <code>Renderer</code>. |
|
|
|
*/ |
|
|
|
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 <code>OutputStream</code> 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() |
|
|
|
); |
|
|
|
} |
|
|
|
|