You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Stoeckel, Matthias" <Ma...@Dresdner-Bank.com> on 2003/04/17 15:42:15 UTC

ZipArchiveSerializer

We have a Use Case where a customer wants to get several PDF's in a zip
file. The problem is that the generation of one PDF can take several
minutes. Therefore we extended the ZipArchiveSerializer in order to work
with several threads. This speeds up the whole thing if you are working on
multiprocessor machines.

We added two additional attributes to the XML stream:
	usethreads=true|false
	maxthreads=maximum number of concurrent threads

An example XML stream could look as follows:

<?xml version="1.0" encoding="iso-8859-1"?>
<zip-archive:archive
    xmlns:zip-archive="http://apache.org/cocoon/zip-archive/1.0"
    usethreads="true"
    maxthreads="2">
  <zip-archive:entry  name="welcome.html" src="cocoon://"/>
  <zip-archive:entry  name="docs.html" src="cocoon://docs/index.html"/>
  <zip-archive:entry  name="sample.svg"
src="cocoon://samples/hello-world/hello.svg"/>
</zip-archive:archive>

If the 'usethreads' attribute is set to false, or not given, the serializer
will work as usual. A inner class is used for the thread. This class does
simply call CocoonComponentManager.getCurrentEnvironment().resolveURI() and
stores the result in a byte array.  The cached results will be put into the
archive as soon as all threads are finished.

The attached diff shows all modifications. Feel free to use this code as you
like or ask any questions.
A happy easter to all,
  Matthias