Hello,

I am investigating the possible caching of layout elements and as part of
the investigation I realized that I need to understand how fop instances
are managed in real life situations. In particular, I need to know if it is
possible to have two concurrent fop instances created from the same fop
factory.

This is a typical use case I am familiar with:
        FopFactoryBuilder builder = new FopConfParser(new
File(confFile)).getFopFactoryBuilder();
        FopFactory fopFactory = builder.build();
        foreach (Doc doc : listOfDocs) {
            File fo = doc.getFOFile();
            File pdf = doc.getPDFFile();
            generateOutput(fo, pdf, fopFactory);
        }

where:

    public static void generateOutput(File fo, File pdf, FopFactory
fopFactory) throws IOException, FOPException,
            TransformerException {
        OutputStream out = null;
        try {
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            out = new FileOutputStream(pdf);
            out = new BufferedOutputStream(out);
            Fop fop = fopFactory.newFop(mime, foUserAgent, out);
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer();
            Source src = new StreamSource(fo);
            Result res = new SAXResult(fop.getDefaultHandler());
            transformer.transform(src, res);
        } finally {
            out.close();
        }
    }

In this case, even though a fop factory can create many fop instances we
cannot have more than one in use at at given time.

Is anyone using a different approach where concurrent fop instances are
possible?

Thanks,
Luis

Reply via email to