cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Weinger <gwein...@itmedicine.net>
Subject [Donation] AsynchronousCIncludeTransformer
Date Sat, 07 Dec 2002 02:06:46 GMT
As promised, here is my first donation to the Cocoon community.

I've cleaned up this code somewhat and packaged it so that you can just
drop the code in transformation directory, and the sample in the 
webapp/mount directory.

I'm very willing to help refactor or improve the design based on your 
feedback.


What is it?
=====================
   The AsynchronousCIncludeTransformer processes a set of CInclude tags
   asynchronously, in its own thread pool, so that no more than a
   given number of CIncludes execute at a time.  This can improve
   performance by allowing you to manage the number of concurrent hits on
   a resource.

   To use, mark a block of XML containing CInclude tags with
   <c:asynchronousBlock/> tags.

   Here is some example usage of the markup:

   <c:asynchronousBlock poolSize="3">
      <randomMarkup>
       <p><c:include src="cocoon://slowResource?id=1"/></p>
       <p><c:include src="cocoon://slowResource?id=2"/></p>
       <p><c:include src="cocoon://slowResource?id=3"/></p>
       <p><c:include src="cocoon://slowResource?id=4"/></p>
      </randomMarkup>
   </c:asynchronousBlock>


   If this transformer encounters a CInclude outside of
   <c:asynchronousBlock> tags, it executes the CInclude as
   normal, serially, by passing it to the parent CInclude method.

   Note: duplicate URIs are discarded, so if your resource changes
   each time, make sure the URI is unique.


Some more details
======================

   As each CInclude is executed, it is byte-compiled directly to a file,
   using a modified XMLByteStreamCompiler.  In a previous version we were
   using the ByteStreamCompiler and saving to the persistent store, but
   tried this approach to avoid holding potentially extremely large
   files in memory.

   The current algorithm is for this transformer to proceed until it
   reaches the end </c:asynchronousBlock> and then block until
   all processes are complete.  Then it begins serializing the cached
   markup of the asynchronous block, substituting the stored results for
   the cinclude tag.

   This algorithm could be modified to begin writing the cincludes
   progressively, as they become available, to improve the perceived
   response time.


   This code works with the 2.0.3 branch, but needs minor tweaks to work
   with 2.1.

   Please, hammer away, and I hope some people find it useful.


--Greg



Mime
View raw message