Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 28402 invoked by uid 500); 7 Apr 2002 18:48:14 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 28391 invoked by uid 500); 7 Apr 2002 18:48:13 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 7 Apr 2002 18:48:13 -0000 Message-ID: <20020407184813.84558.qmail@icarus.apache.org> From: sylvain@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/generation AbstractServerPage.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N sylvain 02/04/07 11:48:13 Modified: src/java/org/apache/cocoon/components/language/generator ProgramGeneratorImpl.java src/java/org/apache/cocoon/generation AbstractServerPage.java Log: Changed the CM handling in XSPs because of disposal of CMs in TreeProcessor : - they are composed with the root CM when created - they are recomposed with the generator's CM when loaded Revision Changes Path 1.15 +8 -3 xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java Index: ProgramGeneratorImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ProgramGeneratorImpl.java 29 Mar 2002 20:32:01 -0000 1.14 +++ ProgramGeneratorImpl.java 7 Apr 2002 18:48:12 -0000 1.15 @@ -55,6 +55,7 @@ import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentSelector; import org.apache.avalon.framework.component.ComponentException; +import org.apache.avalon.framework.component.Recomposable; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; @@ -85,7 +86,7 @@ * * @author Ricardo Rocha * @author Vadim Gritsenko - * @version CVS $Id: ProgramGeneratorImpl.java,v 1.14 2002/03/29 20:32:01 vgritsenko Exp $ + * @version CVS $Id: ProgramGeneratorImpl.java,v 1.15 2002/04/07 18:48:12 sylvain Exp $ */ public class ProgramGeneratorImpl extends AbstractLoggable implements ProgramGenerator, Contextualizable, Composable, Parameterizable, @@ -245,7 +246,7 @@ program = programmingLanguage.preload(normalizedName, this.workDir, markupLanguage.getEncoding()); - this.cache.addGenerator(newManager, normalizedName, program); + this.cache.addGenerator(this.manager, normalizedName, program); programInstance = (CompiledComponent)this.cache.select(normalizedName); } catch (Exception e) { getLogger().debug("The program was not preloaded"); @@ -288,11 +289,15 @@ markupLanguage = (MarkupLanguage)this.markupSelector.select(markupLanguageName); } - programInstance = this.createResource(newManager, + programInstance = this.createResource(this.manager, source, normalizedName, markupLanguage, programmingLanguage, resolver); } + // Recompose with the new manager if needed + if (programInstance instanceof Recomposable) { + ((Recomposable)programInstance).recompose(newManager); + } return programInstance; } finally { source.recycle(); 1.8 +140 -129 xml-cocoon2/src/java/org/apache/cocoon/generation/AbstractServerPage.java Index: AbstractServerPage.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/AbstractServerPage.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractServerPage.java 6 Apr 2002 05:51:22 -0000 1.7 +++ AbstractServerPage.java 7 Apr 2002 18:48:12 -0000 1.8 @@ -50,6 +50,10 @@ */ package org.apache.cocoon.generation; +import org.apache.avalon.framework.component.Recomposable; +import org.apache.avalon.framework.component.ComponentManager; +import org.apache.avalon.framework.component.ComponentException; + import org.apache.cocoon.caching.CacheValidity; import org.apache.cocoon.caching.Cacheable; import org.apache.cocoon.caching.NOPCacheValidity; @@ -65,138 +69,145 @@ * declares variables that must be explicitly initialized by code generators. * * @author Ricardo Rocha - * @version CVS $Id: AbstractServerPage.java,v 1.7 2002/04/06 05:51:22 vgritsenko Exp $ + * @version CVS $Id: AbstractServerPage.java,v 1.8 2002/04/07 18:48:12 sylvain Exp $ */ public abstract class AbstractServerPage - extends ServletGenerator implements CompiledComponent, Cacheable -{ - /** - * Code generators should produce a static - * block that initializes the generator's - * creation date and file dependency list. - * Example: - * - * static { - * dateCreated = 958058788948L; - * dependencies = new File[] { - * new File("source.xml"), - * }; - * } - * - */ - - /** The creation date */ - protected static long dateCreated = -1L; - /** The dependency file list */ - protected static File[] dependencies = null; - - /** - * Determines whether this generator's source files have changed - * - * @return Whether any of the files this generator depends on has changed - * since it was created - */ - public boolean modifiedSince(long date) { - if (dateCreated < date) { + extends ServletGenerator implements CompiledComponent, Cacheable, Recomposable { + /** + * Code generators should produce a static + * block that initializes the generator's + * creation date and file dependency list. + * Example: + * + * static { + * dateCreated = 958058788948L; + * dependencies = new File[] { + * new File("source.xml"), + * }; + * } + * + */ + + /** The creation date */ + protected static long dateCreated = -1L; + /** The dependency file list */ + protected static File[] dependencies = null; + + /** + * Recompose with the actual ComponentManager that should + * be used. + */ + public void recompose(ComponentManager manager) throws ComponentException { + this.manager = manager; + } + + /** + * Determines whether this generator's source files have changed + * + * @return Whether any of the files this generator depends on has changed + * since it was created + */ + public boolean modifiedSince(long date) { + if (dateCreated < date) { + return true; + } + + for (int i = 0; i < dependencies.length; i++) { + if (dateCreated < dependencies[i].lastModified()) { + return true; + } + } + + return false; + } + + /** + * Determines whether generated content has changed since + * last invocation. Users may override this method to take + * advantage of SAX event cacheing + * + * @param request The request whose data must be inspected to assert whether + * dynamically generated content has changed + * @return Whether content has changes for this request's data + */ + public boolean hasContentChanged(Request request) { return true; } - for (int i = 0; i < dependencies.length; i++) { - if (dateCreated < dependencies[i].lastModified()) { - return true; - } - } - - return false; - } - - /** - * Determines whether generated content has changed since - * last invocation. Users may override this method to take - * advantage of SAX event cacheing - * - * @param request The request whose data must be inspected to assert whether - * dynamically generated content has changed - * @return Whether content has changes for this request's data - */ - public boolean hasContentChanged(Request request) { - return true; - } - - /** - * Generates the unique key. - * This key must be unique inside the space of this component. - * Users may override this method to take - * advantage of SAX event cacheing - * - * @return A long representing the cache key (defaults to not cachable) - */ - public long generateKey() { - return 0; - } - - /** - * Generate the validity object. - * - * @return The generated validity object, NOPCacheValidity - * is the default if hasContentChange() gives false otherwise - * null will be returned. - */ - public CacheValidity generateValidity() { - if (hasContentChanged(request)) - return null; - else - return NOPCacheValidity.CACHE_VALIDITY; - } - - // FIXME: Add more methods! - /* SAX Utility Methods */ - /** - * Add an attribute - * - * @param attr The attribute list to add to - * @param name The attribute name - * @param value The attribute value - */ - protected void attribute(AttributesImpl attr, String name, String value) { - attr.addAttribute("", name, name, "CDATA", value); - } - - /** - * Start an element - * - * @param name The element name - * @param attr The element attributes - */ - protected void start(String name, AttributesImpl attr) throws SAXException { - this.contentHandler.startElement("", name, name, attr); - attr.clear(); - } - - /** - * End an element - * - * @param name The element name - */ - protected void end(String name) throws SAXException { - this.contentHandler.endElement("", name, name); - } - - /** - * Add character data - * - * @param data The character data - */ - protected void characters(String data) throws SAXException { - this.contentHandler.characters(data.toCharArray(), 0, data.length()); - } - - /** - * Add a comment - * - * @param data The comment data - */ - protected void comment(String data) throws SAXException { - this.lexicalHandler.comment(data.toCharArray(), 0, data.length()); - } + /** + * Generates the unique key. + * This key must be unique inside the space of this component. + * Users may override this method to take + * advantage of SAX event cacheing + * + * @return A long representing the cache key (defaults to not cachable) + */ + public long generateKey() { + return 0; + } + + /** + * Generate the validity object. + * + * @return The generated validity object, NOPCacheValidity + * is the default if hasContentChange() gives false otherwise + * null will be returned. + */ + public CacheValidity generateValidity() { + if (hasContentChanged(request)) + return null; + else + return NOPCacheValidity.CACHE_VALIDITY; + } + + // FIXME: Add more methods! + /* SAX Utility Methods */ + /** + * Add an attribute + * + * @param attr The attribute list to add to + * @param name The attribute name + * @param value The attribute value + */ + protected void attribute(AttributesImpl attr, String name, String value) { + attr.addAttribute("", name, name, "CDATA", value); + } + + /** + * Start an element + * + * @param name The element name + * @param attr The element attributes + */ + protected void start(String name, AttributesImpl attr) throws SAXException { + this.contentHandler.startElement("", name, name, attr); + attr.clear(); + } + + /** + * End an element + * + * @param name The element name + */ + protected void end(String name) throws SAXException { + this.contentHandler.endElement("", name, name); + } + + /** + * Add character data + * + * @param data The character data + */ + protected void characters(String data) throws SAXException { + this.contentHandler.characters(data.toCharArray(), 0, data.length()); + } + + /** + * Add a comment + * + * @param data The comment data + */ + protected void comment(String data) throws SAXException { + this.lexicalHandler.comment(data.toCharArray(), 0, data.length()); + } } ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org