cziegeler 01/08/16 04:25:22 Modified: . Tag: cocoon_20_branch changes.xml todo.xml src/org/apache/cocoon/components/source Tag: cocoon_20_branch CocoonSourceFactory.java SitemapSource.java src/org/apache/cocoon/environment Tag: cocoon_20_branch AbstractEnvironment.java Environment.java src/org/apache/cocoon/environment/wrapper Tag: cocoon_20_branch EnvironmentWrapper.java RequestWrapper.java Log: Redesigned the handling of the cocoon: protocol. Removed the pushURI and popURI methods. It is now possible to load cocoon: resources parallel in several tasks. Revision Changes Path No revision No revision 1.2.2.29 +6 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.2.2.28 retrieving revision 1.2.2.29 diff -u -r1.2.2.28 -r1.2.2.29 --- changes.xml 2001/08/11 17:29:02 1.2.2.28 +++ changes.xml 2001/08/16 11:25:21 1.2.2.29 @@ -4,7 +4,7 @@ <!-- History of Cocoon changes - $Id: changes.xml,v 1.2.2.28 2001/08/11 17:29:02 vgritsenko Exp $ + $Id: changes.xml,v 1.2.2.29 2001/08/16 11:25:21 cziegeler Exp $ --> <changes title="History of Changes"> @@ -26,6 +26,11 @@ </devs> <release version="2.0b2-dev" date="@date@"> + <action dev="CZ" type="add"> + Redesigned the handling of the cocoon: protocol. Removed the pushURI + and popURI methods. It is now possible to load cocoon: resources + parallel in several tasks. + </action> <action dev="VG" type="fix" fixes-bug="2737"> Fixed package name generation for subsitemap components and external components. </action> 1.1.1.1.2.8 +1 -5 xml-cocoon2/todo.xml Index: todo.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/todo.xml,v retrieving revision 1.1.1.1.2.7 retrieving revision 1.1.1.1.2.8 diff -u -r1.1.1.1.2.7 -r1.1.1.1.2.8 --- todo.xml 2001/07/23 12:16:14 1.1.1.1.2.7 +++ todo.xml 2001/08/16 11:25:21 1.1.1.1.2.8 @@ -4,7 +4,7 @@ <!-- History of Cocoon changes - $Id: todo.xml,v 1.1.1.1.2.7 2001/07/23 12:16:14 cziegeler Exp $ + $Id: todo.xml,v 1.1.1.1.2.8 2001/08/16 11:25:21 cziegeler Exp $ --> @@ -54,10 +54,6 @@ <action context="code"> Complete/write documentation in general. - </action> - - <action context="code"> - Remove the pushURI and popURI methods from the environment. </action> <action context="code"> No revision No revision 1.1.2.3 +4 -3 xml-cocoon2/src/org/apache/cocoon/components/source/CocoonSourceFactory.java Index: CocoonSourceFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/CocoonSourceFactory.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- CocoonSourceFactory.java 2001/07/04 10:10:53 1.1.2.2 +++ CocoonSourceFactory.java 2001/08/16 11:25:21 1.1.2.3 @@ -24,7 +24,7 @@ * as it needs the current <code>Sitemap</code> as input. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/07/04 10:10:53 $ + * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/08/16 11:25:21 $ */ public final class CocoonSourceFactory @@ -53,7 +53,8 @@ return new SitemapSource(environment, this.manager, this.sitemap, - location); + location, + this.getLogger()); } /** @@ -65,4 +66,4 @@ throw new ProcessingException("CocoonSourceFactory: environment is required."); return this.getSource(environment, base.toExternalForm() + location); } -} \ No newline at end of file +} 1.1.2.13 +9 -20 xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -r1.1.2.12 -r1.1.2.13 --- SitemapSource.java 2001/08/15 03:55:22 1.1.2.12 +++ SitemapSource.java 2001/08/16 11:25:21 1.1.2.13 @@ -42,6 +42,7 @@ import org.apache.cocoon.xml.ContentHandlerWrapper; import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.XMLProducer; +import org.apache.log.Logger; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -50,7 +51,7 @@ * Description of a source which is defined by a pipeline. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.1.2.12 $ $Date: 2001/08/15 03:55:22 $ + * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/08/16 11:25:21 $ */ public final class SitemapSource @@ -96,7 +97,8 @@ public SitemapSource(Environment env, ComponentManager manager, Sitemap sitemap, - String uri) + String uri, + Logger logger) throws IOException, ProcessingException { this.manager = manager; @@ -139,12 +141,13 @@ request.getServerName() + (isDefaultPort ? "" : ":" + request.getServerPort()) + request.getContextPath() + '/' + requestURI; - this.environment = new EnvironmentWrapper(env, requestURI, queryString); + this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger); queryStringPos = uri.indexOf('?'); if (queryStringPos != -1) { uri = uri.substring(0, queryStringPos); } this.uri = uri; + this.environment.setURI(this.prefix, this.uri); this.refresh(); } @@ -236,19 +239,12 @@ // set dummy consumer ((XMLProducer)eventPipeline).setConsumer(this); - try { - this.environment.pushURI(this.prefix, this.uri); + this.environment.setURI(this.prefix, this.uri); this.processor.process(this.environment, pipeline, eventPipeline); - } finally { - this.environment.popURI(); - } - // Do push again as process() resets sourceHandler in environment - try { - this.environment.pushURI(this.prefix, this.uri); - String redirectURL = this.environment.getRedirectURL(); if (redirectURL == null) { if (this.eventPipeline instanceof CacheableEventPipeline) { + this.environment.setURI(this.prefix, this.uri); CacheableEventPipeline cep = (CacheableEventPipeline)this.eventPipeline; PipelineCacheKey pck = cep.generateKey(this.environment); Map validity = null; @@ -269,9 +265,6 @@ this.redirectSource = this.environment.resolve(redirectURL); this.lastModificationDate = this.redirectSource.getLastModified(); } - } finally { - this.environment.popURI(); - } } catch (ProcessingException e) { reset(); this.exception = e; @@ -304,13 +297,9 @@ if (this.redirectSource != null) { this.redirectSource.stream(consumer); } else { - try { - this.environment.pushURI(this.prefix, this.uri); + this.environment.setURI(this.prefix, this.uri); ((XMLProducer)eventPipeline).setConsumer(consumer); eventPipeline.process(this.environment); - } finally { - this.environment.popURI(); - } } } catch (ComponentException cme) { throw new ProcessingException("could not lookup pipeline components", cme); No revision No revision 1.6.2.8 +13 -38 xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java Index: AbstractEnvironment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java,v retrieving revision 1.6.2.7 retrieving revision 1.6.2.8 diff -u -r1.6.2.7 -r1.6.2.8 --- AbstractEnvironment.java 2001/08/14 15:54:53 1.6.2.7 +++ AbstractEnvironment.java 2001/08/16 11:25:22 1.6.2.8 @@ -25,12 +25,12 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.6.2.7 $ $Date: 2001/08/14 15:54:53 $ + * @version CVS $Revision: 1.6.2.8 $ $Date: 2001/08/16 11:25:22 $ */ public abstract class AbstractEnvironment extends AbstractLoggable implements Environment { /** The current uri in progress */ - protected ArrayList uris = new ArrayList(); + protected String uris; /** The current prefix to strip off from the request uri */ protected StringBuffer prefix = new StringBuffer(); @@ -90,7 +90,7 @@ */ public AbstractEnvironment(String uri, String view, URL context, String action) throws MalformedURLException { - this.pushURI(null, uri); + this.uris = uri; this.view = view; this.context = context; this.action = action; @@ -119,10 +119,17 @@ * Returns the uri in progress. The prefix is stripped off */ public String getURI() { - return (String)this.uris.get(this.uris.size()-1); + return this.uris; } /** + * Get the Root Context + */ + public URL getRootContext() { + return this.rootContext; + } + + /** * Get the prefix of the URI in progress */ public String getURIPrefix() { @@ -134,7 +141,7 @@ */ public void changeContext(String prefix, String context) throws MalformedURLException { - String uri = (String)this.uris.get(this.uris.size()-1); + String uri = this.uris; getLogger().debug("Changing Cocoon context(" + context + ") to prefix(" + prefix + ")"); getLogger().debug("\tfrom context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")"); getLogger().debug("\tat URI " + uri); @@ -181,7 +188,7 @@ } } getLogger().debug("New context is " + this.context.toExternalForm()); - this.uris.set(this.uris.size()-1, uri); + this.uris = uri; } /** @@ -245,38 +252,6 @@ } this.getLogger().debug("Resolved to '"+source.getSystemId()+"'"); return source; - } - - /** - * Push a new URI for processing. If the prefix is null the - * new URI is inside the current context. - * If the prefix is not null the context is changed to the root - * context and the prefix is set. - */ - public void pushURI(String prefix, String uri) { - this.uris.add(this.sourceHandler); - this.uris.add(this.prefix); - this.uris.add(this.context); - this.uris.add(uri); - if (prefix != null) { - this.context = this.rootContext; - this.prefix = new StringBuffer(prefix); - } - } - - /** - * Pop last pushed URI - */ - public String popURI() { - String uri = (String)this.uris.get(this.uris.size()-1); - this.uris.remove(this.uris.size()-1); - this.context = (URL)this.uris.get(this.uris.size()-1); - this.uris.remove(this.uris.size()-1); - this.prefix = (StringBuffer)this.uris.get(this.uris.size()-1); - this.uris.remove(this.uris.size()-1); - this.sourceHandler = (SourceHandler)this.uris.get(this.uris.size()-1); - this.uris.remove(this.uris.size()-1); - return uri; } /** 1.2.2.5 +7 -14 xml-cocoon2/src/org/apache/cocoon/environment/Environment.java Index: Environment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Environment.java,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- Environment.java 2001/08/14 15:54:53 1.2.2.4 +++ Environment.java 2001/08/16 11:25:22 1.2.2.5 @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URL; import java.util.Map; import org.apache.cocoon.components.source.SourceHandler; import org.xml.sax.SAXException; @@ -20,7 +21,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.2.2.4 $ $Date: 2001/08/14 15:54:53 $ + * @version CVS $Revision: 1.2.2.5 $ $Date: 2001/08/16 11:25:22 $ */ public interface Environment extends SourceResolver { @@ -46,6 +47,11 @@ String getURIPrefix(); /** + * Get the Root Context + */ + URL getRootContext(); + + /** * Get the view to process */ String getView(); @@ -94,19 +100,6 @@ * Get the underlying object model */ Map getObjectModel(); - - /** - * Push a new URI for processing. If the prefix is null the - * new URI is inside the current context. - * If the prefix is not null the context is changed to the root - * context and the prefix is set. - */ - void pushURI(String prefix, String uri); - - /** - * Pop last pushed URI - */ - String popURI(); /** * Check if the response has been modified since the same No revision No revision 1.1.2.4 +26 -105 xml-cocoon2/src/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Index: EnvironmentWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- EnvironmentWrapper.java 2001/08/14 15:54:54 1.1.2.3 +++ EnvironmentWrapper.java 2001/08/16 11:25:22 1.1.2.4 @@ -10,6 +10,8 @@ import java.io.IOException; import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -21,11 +23,13 @@ import org.apache.cocoon.Constants; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.components.source.SourceHandler; +import org.apache.cocoon.environment.AbstractEnvironment; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Response; import org.apache.cocoon.environment.Session; import org.apache.cocoon.environment.Source; +import org.apache.log.Logger; /** @@ -34,9 +38,10 @@ * contains a <code>RequestWrapper</code> object. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version $Id: EnvironmentWrapper.java,v 1.1.2.3 2001/08/14 15:54:54 vgritsenko Exp $ + * @version $Id: EnvironmentWrapper.java,v 1.1.2.4 2001/08/16 11:25:22 cziegeler Exp $ */ public final class EnvironmentWrapper +extends AbstractEnvironment implements Environment { /** The wrapped environment */ @@ -57,8 +62,14 @@ */ public EnvironmentWrapper(Environment env, String requestURI, - String queryString) { + String queryString, + Logger logger) + throws MalformedURLException { + super(env.getURI(), env.getView(), env.getRootContext(), env.getAction()); + this.setURI(env.getURIPrefix(), env.getURI()); + this.setLogger(logger); this.environment = env; + this.setSourceHandler(env.getSourceHandler()); // create new object model and replace the request object this.objectModel = new HashMap(4); Map oldObjectModel = env.getObjectModel(); @@ -69,17 +80,10 @@ this.objectModel.put(key, oldObjectModel.get(key)); } this.request = new RequestWrapper((Request)oldObjectModel.get(Constants.REQUEST_OBJECT), - requestURI, queryString); + requestURI, queryString, this); this.objectModel.put(Constants.REQUEST_OBJECT, this.request); } - - /** - * Get the OutputStream - */ - public OutputStream getOutputStream() throws IOException { - return this.environment.getOutputStream(); - } /** * Redirect the client to a new URL is not allowed */ @@ -97,6 +101,14 @@ } /** + * Get the output stream + */ + public OutputStream getOutputStream() + throws IOException { + return this.environment.getOutputStream(); + } + + /** * if a redirect should happen this returns the url, * otherwise <code>null</code> is returned */ @@ -135,108 +147,17 @@ } /** - * Get the <code>SourceHandler</code> for the current request - */ - public SourceHandler getSourceHandler() { - return this.environment.getSourceHandler(); - } - - /** - * Set the <code>SourceHandler</code> for the current request - */ - public void setSourceHandler(SourceHandler sourceHandler) { - this.environment.setSourceHandler(sourceHandler); - } - - /** - * Get the URI to process. The prefix is stripped off. - */ - public String getURI() { - return this.environment.getURI(); - } - - /** - * Get the prefix of the URI in progress. - */ - public String getURIPrefix() { - return this.environment.getURIPrefix(); - } - - /** - * Get the view to process - */ - public String getView() { - return this.environment.getView(); - } - - /** - * Get the action to process - */ - public String getAction() { - return this.environment.getAction(); - } - - /** - * Change the context from uriprefix to context - */ - public void changeContext(String uriprefix, String context) - throws Exception { - this.environment.changeContext(uriprefix, context); - } - - /** * Get the underlying object model */ public Map getObjectModel() { return this.objectModel; } - /** - * Push a new URI for processing. If the prefix is null the - * new URI is inside the current context. - * If the prefix is not null the context is changed to the root - * context and the prefix is set. - */ - public void pushURI(String prefix, String uri) { - this.environment.pushURI(prefix, uri); + public void setURI(String prefix, String uri) { + this.context = this.rootContext; + this.prefix = new StringBuffer((prefix == null ? "" : prefix)); + this.uris = uri; } - - /** - * Pop last pushed URI - */ - public String popURI() { - return this.environment.popURI(); - } - - /** - * Check if the response has been modified since the same - * "resource" was requested. - * The caller has to test if it is really the same "resource" - * which is requested. - * @result true if the response is modified or if the - * environment is not able to test it - */ - public boolean isResponseModified(long lastModified) { - return true; - } - - /** - * Mark the response as not modified. - */ - public void setResponseIsNotModified() { - // ignore - } - - /** - * Resolve the source. - * @param systemID This is either a system identifier - * (<code>java.net.URL</code> or a local file. - */ - public Source resolve(String systemID) - throws ProcessingException, SAXException, IOException { - return this.environment.resolve(systemID); - } - } 1.1.2.6 +9 -3 xml-cocoon2/src/org/apache/cocoon/environment/wrapper/RequestWrapper.java Index: RequestWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/wrapper/RequestWrapper.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- RequestWrapper.java 2001/07/13 13:39:02 1.1.2.5 +++ RequestWrapper.java 2001/08/16 11:25:22 1.1.2.6 @@ -13,6 +13,7 @@ import java.util.*; import org.apache.cocoon.environment.Cookie; +import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Session; @@ -23,7 +24,7 @@ * are different. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version $Id: RequestWrapper.java,v 1.1.2.5 2001/07/13 13:39:02 dims Exp $ + * @version $Id: RequestWrapper.java,v 1.1.2.6 2001/08/16 11:25:22 cziegeler Exp $ */ public final class RequestWrapper implements Request { @@ -39,12 +40,17 @@ /** The request parameters */ private RequestParameters parameters ; + /** The environment */ + private Environment environment; + /** * Constructor */ public RequestWrapper(Request request, String requestURI, - String queryString) { + String queryString, + Environment env) { + this.environment = env; this.req = request; this.requestURI = requestURI; this.queryString = queryString; @@ -230,7 +236,7 @@ } public String getSitemapURI() { - return this.req.getSitemapURI(); + return this.environment.getURI(); } public String getServletPath() { ---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]