You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Te...@itsolicom.fi on 2002/02/05 15:18:40 UTC

Reusing Driver object instances

Hi,

I am trying to make my code more efficient, so I was reading FOP
documentation to 
find out what is said there about optimizing. the following is said about
reusing objects 
in file http://xml.apache.org/fop/embedding.html :

***
> If FOP is going to be used multiple times within your application it may
be useful to reuse certain 
> objects to save time.  The renderers and the driver can both be reused. A
renderer is reusable once 
>the previous render has been completed. The driver is reuseable after the
rendering is complete and 
> the reset method is called. You will need to setup the driver again with a
new OutputStream, 
> InputStream and renderer.
***

How can I know in my Java code that the Driver.render method is done?
When is Driver.reset method called?

I am dynamically generating the XSL-FO document from XML and XSL documents.
I am thinking that 
I could have a single class variable for each of my XSL stylesheets, and
always use the same object 
instance when generating XSL-FO documents. Should I have the code that is
calling method Driver.render 
inside a synchronized block to be thread-safe? I am not actually sure if I
want to always have only one PDF 
document rendered at a time... has anyone found a good solution for this?

( in other words: does someone understand what the text i cited from FOP
documentation means at 
practical (Java) level? :) )

Thanks,
- Teemu