cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Hartmann <andr...@apache.org>
Subject IncludeTransformer: Caching for non-existing includes
Date Thu, 07 Feb 2008 17:28:11 GMT
Hi Cocoon devs,

I'd be glad to hear your opinions about the following thoughts.

About the context: In Lenya, we have a couple of modules, which are 
basically directories. A module directory can include an optional 
menu.xml file. The Lenya GUI menubar is an aggregation of all these 
menu.xml files, with some postprocessing. The same mechanism is used for 
the i18n catalogue - modules can provide i18n catalogues for their GUIs.

We use the IncludeTransformer to assemble the menu XML, ignoring the 
non-existing menus using <i:fallback/>. It looks basically like this:

   <xsl:forEach select="lenya:module">
     <i:include src="cocoon:/menu-xml/module/{@name}.xml">
       <i:fallback/>
     </i:include>
   </xsl:forEach>


This is extremely fast if all modules contain menu.xml files, because 
the aggregated XML is cached. But if some of the includes can't be 
resolved, nothing is cached. This causes up to 50% more request 
processing time, so it has quite a big impact on the Lenya GUI 
performance :)

I tracked the source of the behaviour down to the MultiSourceValidity 
class. As soon as one of the sources has no validity (IIUC this happens 
if a FileSource doesn't exist), the whole MultiSourceValidity becomes 
invalid:

   public void addSource(Source src) {
       if (this.uris != null) {
           SourceValidity validity = src.getValidity();
           if (validity == null) {
               /* The source has no validity: this will be
                  always be invalid. */
               this.uris = null;


 From my POV it would be better to ignore the non-existing sources, and 
check their existence when the validity is computed the next time. I.e. 
MultiSourceValidity.isValid() would return UNKNOWN, and 
isValid(newValidity) -> computeStatus() would check if newValidity 
provides a validity for the formerly missing source.

Do you think this behaviour would be reasonable? If yes, I'd try to 
implement it, preferrably with test cases to avoid regressions.

TIA for any comments!

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


Mime
View raw message