You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2004/02/04 15:39:58 UTC
cvs commit: cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization FOPSerializer.java
sylvain 2004/02/04 06:39:58
Modified: src/blocks/fop/java/org/apache/cocoon/serialization
FOPSerializer.java
Log:
Add support for all cocoon protocols for <svg:image xlink:href="..."/>
Revision Changes Path
1.7 +30 -18 cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java
Index: FOPSerializer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FOPSerializer.java 19 Jan 2004 09:27:26 -0000 1.6
+++ FOPSerializer.java 4 Feb 2004 14:39:58 -0000 1.7
@@ -50,18 +50,25 @@
*/
package org.apache.cocoon.serialization;
+import java.io.File;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.net.MalformedURLException;
+
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.component.Composable;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.components.renderer.ExtendableRendererFactory;
import org.apache.cocoon.components.renderer.RendererFactory;
import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.components.url.SourceProtocolHandler;
import org.apache.cocoon.util.ClassUtils;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
@@ -69,23 +76,19 @@
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.Options;
+import org.apache.fop.configuration.ConfigurationParser;
import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.render.Renderer;
-import org.apache.fop.configuration.ConfigurationParser;
-
-import java.io.OutputStream;
-import java.io.File;
-import java.io.Serializable;
-import java.net.MalformedURLException;
/**
* @author ?
* @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
* @version CVS $Id$
*/
-public class FOPSerializer
-extends AbstractSerializer
-implements Composable, Configurable, CacheableProcessingComponent {
+public class FOPSerializer extends AbstractSerializer implements
+ Configurable, CacheableProcessingComponent, Serviceable, Disposable {
+
+ protected SourceResolver resolver;
/**
* The Renderer Factory to use
@@ -130,14 +133,18 @@
/**
* Manager to get URLFactory from.
*/
- protected ComponentManager manager;
+ protected ServiceManager manager;
/**
* Set the component manager for this serializer.
*/
- public void compose(ComponentManager componentManager)
- throws ComponentException {
- this.manager = componentManager;
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+ }
+
+ public void dispose() {
+ this.manager.release(this.resolver);
}
/**
@@ -249,6 +256,10 @@
* Set the <code>OutputStream</code> where the XML should be serialized.
*/
public void setOutputStream(OutputStream out) {
+
+ // Give the source resolver to Batik which is used by FOP
+ SourceProtocolHandler.setup(this.resolver);
+
// load the fop driver
this.driver = new Driver();
this.driver.setLogger(this.logger);
@@ -308,4 +319,5 @@
public boolean shouldSetContentLength() {
return this.setContentLength;
}
+
}
Re: cvs commit: cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization
FOPSerializer.java
Posted by Joerg Heinicke <jo...@gmx.de>.
On 04.02.2004 23:28, Sylvain Wallez wrote:
> No, it's not that simple, as you have to include the image into a SVG. A
> colleague made some patches to FOP to avoid this, but this injects
> Cocoon-specific code deep into FOP.
So Fop and Batik have different source resolvers? What a pity! At least
a work around is now available.
>> This would be worth a mentioning in status.xml, Sylvain, as this
>> solves frequently asked questions on FOP/Batik.
>
> Done (I forgot to commit it this afternoon).
Thanks.
Joerg
Re: cvs commit: cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization
FOPSerializer.java
Posted by Sylvain Wallez <sy...@apache.org>.
Joerg Heinicke wrote:
> Does this mean we can now reference images using all Cocoon protocols?
> I mean also for <fo:external-graphic src=""/> and similar?
Yes, this is possible by including the image into an SVG image in the FO
document.
>> + SourceProtocolHandler.setup(this.resolver);
>
>
> And this by only such a simple change? Woah!!
No, it's not that simple, as you have to include the image into a SVG. A
colleague made some patches to FOP to avoid this, but this injects
Cocoon-specific code deep into FOP.
> This would be worth a mentioning in status.xml, Sylvain, as this
> solves frequently asked questions on FOP/Batik.
Done (I forgot to commit it this afternoon).
Sylvain
--
Sylvain Wallez Anyware Technologies
http://www.apache.org/~sylvain http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance - http://www.orixo.com
Re: cvs commit: cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization
FOPSerializer.java
Posted by Sylvain Wallez <sy...@apache.org>.
Vadim Gritsenko wrote:
> Joerg Heinicke wrote:
>
>> Does this mean we can now reference images using all Cocoon
>> protocols? I mean also for <fo:external-graphic src=""/> and similar?
>>
>> On 04.02.2004 15:39, sylvain@apache.org wrote:
>>
>>> sylvain 2004/02/04 06:39:58
>>>
>>> Modified: src/blocks/fop/java/org/apache/cocoon/serialization
>>> FOPSerializer.java
>>> Log:
>>> Add support for all cocoon protocols for <svg:image
>>> xlink:href="..."/>
>>
>> ...
>>
>>> + SourceProtocolHandler.setup(this.resolver);
>>
>>
>>
>> And this by only such a simple change? Woah!! This would be worth a
>> mentioning in status.xml, Sylvain, as this solves frequently asked
>> questions on FOP/Batik.
>
>
>
> I still wonder how this will fork in multithreading environment...
> This is static method call, and each sitemap have different resolver.
> Will this crash on 2 simulteneous requests?
This uses a ThreadLocal under the hood, so there should be no problem.
This trick is necessary because Batik's URL resolving mechanism doesn't
allow to pass the SourceResolver along the call chain.
Sylvain
--
Sylvain Wallez Anyware Technologies
http://www.apache.org/~sylvain http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance - http://www.orixo.com
Re: cvs commit: cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization
FOPSerializer.java
Posted by Vadim Gritsenko <va...@reverycodes.com>.
Joerg Heinicke wrote:
> Does this mean we can now reference images using all Cocoon protocols?
> I mean also for <fo:external-graphic src=""/> and similar?
>
> On 04.02.2004 15:39, sylvain@apache.org wrote:
>
>> sylvain 2004/02/04 06:39:58
>>
>> Modified: src/blocks/fop/java/org/apache/cocoon/serialization
>> FOPSerializer.java
>> Log:
>> Add support for all cocoon protocols for <svg:image xlink:href="..."/>
>>
>
>
> ...
>
>> + SourceProtocolHandler.setup(this.resolver);
>
>
> And this by only such a simple change? Woah!! This would be worth a
> mentioning in status.xml, Sylvain, as this solves frequently asked
> questions on FOP/Batik.
I still wonder how this will fork in multithreading environment... This
is static method call, and each sitemap have different resolver. Will
this crash on 2 simulteneous requests?
Vadim
Re: cvs commit: cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization
FOPSerializer.java
Posted by Joerg Heinicke <jo...@gmx.de>.
Does this mean we can now reference images using all Cocoon protocols? I
mean also for <fo:external-graphic src=""/> and similar?
On 04.02.2004 15:39, sylvain@apache.org wrote:
> sylvain 2004/02/04 06:39:58
>
> Modified: src/blocks/fop/java/org/apache/cocoon/serialization
> FOPSerializer.java
> Log:
> Add support for all cocoon protocols for <svg:image xlink:href="..."/>
>
...
> + SourceProtocolHandler.setup(this.resolver);
And this by only such a simple change? Woah!! This would be worth a
mentioning in status.xml, Sylvain, as this solves frequently asked
questions on FOP/Batik.
Joerg