cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [44/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PopEnvironmentChanger.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PopEnvironmentChanger.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PopEnvironmentChanger.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PopEnvironmentChanger.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,194 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.internal;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * This is an internal class, and it might change in an incompatible way over time.
+ * For developing your own components/applications based on Cocoon, you shouldn't 
+ * really need it.
+ *
+ * This class is an {@link XMLConsumer} that changes the current environment.
+ * When a pipeline calls an internal pipeline, two environments are
+ * established: one for the calling pipeline and one for the internal pipeline.
+ * Now, if SAX events are send from the internal pipeline, they are
+ * received by some component of the calling pipeline, so inbetween we
+ * have to change the environment forth and back.
+ *
+ * This environment changer pop the current environment from the
+ * environment stack before calling the embeded consumer and push it
+ * back afterwards. It should be placed after a sitemap component that
+ * is be executed in another environment.
+ *
+ * @version $Id: PopEnvironmentChanger.java 312659 2005-10-10 14:11:48Z cziegeler $
+ * @since 2.2
+ */
+final class PopEnvironmentChanger
+    implements XMLConsumer {
+
+    final XMLConsumer consumer;
+
+    PopEnvironmentChanger(XMLConsumer consumer) {
+        this.consumer = consumer;
+    }
+
+    private Environment leaveEnvironment() {
+        return EnvironmentHelper.leaveEnvironment();
+    }
+
+    private void enterEnvironment(Environment environment) throws SAXException {
+        try {
+            EnvironmentHelper.enterEnvironment(environment);
+        } catch (ProcessingException e) {
+            throw new SAXException("Unable to enter the environment: " + environment, e);
+        }
+    }
+
+    public void setDocumentLocator(Locator locator) {
+        Environment environment = leaveEnvironment();
+        this.consumer.setDocumentLocator(locator);
+        try {
+            enterEnvironment(environment);
+        } catch (SAXException e) {
+            throw new UnableToPopEnvironmentException("Unable to re-enter the environment: " + environment, e);
+        }
+    }
+
+    public void startDocument()
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.startDocument();
+        enterEnvironment(environment);
+    }
+
+    public void endDocument()
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.endDocument();
+        enterEnvironment(environment);
+    }
+
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.startPrefixMapping(prefix, uri);
+        enterEnvironment(environment);
+    }
+
+    public void endPrefixMapping(String prefix)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.endPrefixMapping(prefix);
+        enterEnvironment(environment);
+    }
+
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.startElement(uri, loc, raw, a);
+        enterEnvironment(environment);
+    }
+
+    public void endElement(String uri, String loc, String raw)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.endElement(uri, loc, raw);
+        enterEnvironment(environment);
+    }
+
+    public void characters(char c[], int start, int len)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.characters(c, start, len);
+        enterEnvironment(environment);
+    }
+
+    public void ignorableWhitespace(char c[], int start, int len)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.ignorableWhitespace(c, start, len);
+        enterEnvironment(environment);
+    }
+
+    public void processingInstruction(String target, String data)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.processingInstruction(target, data);
+        enterEnvironment(environment);
+    }
+
+    public void skippedEntity(String name)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.skippedEntity(name);
+        enterEnvironment(environment);
+    }
+
+    public void startDTD(String name, String publicId, String systemId)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.startDTD(name, publicId, systemId);
+        enterEnvironment(environment);
+    }
+
+    public void endDTD()
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.endDTD();
+        enterEnvironment(environment);
+    }
+
+    public void startEntity(String name)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.startEntity(name);
+        enterEnvironment(environment);
+    }
+
+    public void endEntity(String name)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.endEntity(name);
+        enterEnvironment(environment);
+    }
+
+    public void startCDATA()
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.startCDATA();
+        enterEnvironment(environment);
+    }
+
+    public void endCDATA()
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.endCDATA();
+        enterEnvironment(environment);
+    }
+
+    public void comment(char ch[], int start, int len)
+    throws SAXException {
+        Environment environment = leaveEnvironment();
+        this.consumer.comment(ch, start, len);
+        enterEnvironment(environment);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PopEnvironmentChanger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PushEnvironmentChanger.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PushEnvironmentChanger.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PushEnvironmentChanger.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PushEnvironmentChanger.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,196 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.internal;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * This is an internal class, and it might change in an incompatible way over time.
+ * For developing your own components/applications based on Cocoon, you shouldn't 
+ * really need it.
+ *
+ * This class is an {@link XMLConsumer} that changes the current environment.
+ * When a pipeline calls an internal pipeline, two environments are
+ * established: one for the calling pipeline and one for the internal pipeline.
+ * Now, if SAX events are send from the internal pipeline, they are
+ * received by some component of the calling pipeline, so inbetween we
+ * have to change the environment forth and back.
+ *
+ * This environment changer push a given environment on the
+ * environment stack before calling the embeded consumer and pops it
+ * afterwards. It should be placed before a sitemap component that
+ * should be executed in another environment.
+ *
+ * @version $Id: PushEnvironmentChanger.java 312659 2005-10-10 14:11:48Z cziegeler $
+ * @since 2.2
+ */
+final class PushEnvironmentChanger
+    implements XMLConsumer {
+
+    final XMLConsumer consumer;
+    final Environment environment;
+
+    PushEnvironmentChanger(XMLConsumer consumer, Environment environment) {
+        this.consumer = consumer;
+        this.environment = environment;
+    }
+
+    private void enterEnvironment() throws SAXException {
+        try {
+            EnvironmentHelper.enterEnvironment(this.environment);
+        } catch (ProcessingException e) {
+            throw new SAXException("PushEnvironmentChanger: ", e);
+        }
+    }
+
+    private void leaveEnvironment() {
+        EnvironmentHelper.leaveEnvironment();
+    }
+
+    public void setDocumentLocator(Locator locator) {
+        try {
+            enterEnvironment();
+        } catch (SAXException e) {
+            throw new UnableToPushEnvironmentException("Unable to push the environment", e);
+        }
+        this.consumer.setDocumentLocator(locator);
+        leaveEnvironment();
+    }
+
+    public void startDocument()
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.startDocument();
+        leaveEnvironment();
+    }
+
+    public void endDocument()
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.endDocument();
+        leaveEnvironment();
+    }
+
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.startPrefixMapping(prefix, uri);
+        leaveEnvironment();
+    }
+
+    public void endPrefixMapping(String prefix)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.endPrefixMapping(prefix);
+        leaveEnvironment();
+    }
+
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.startElement(uri, loc, raw, a);
+        leaveEnvironment();
+    }
+
+    public void endElement(String uri, String loc, String raw)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.endElement(uri, loc, raw);
+        leaveEnvironment();
+    }
+
+    public void characters(char c[], int start, int len)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.characters(c, start, len);
+        leaveEnvironment();
+    }
+
+    public void ignorableWhitespace(char c[], int start, int len)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.ignorableWhitespace(c, start, len);
+        leaveEnvironment();
+    }
+
+    public void processingInstruction(String target, String data)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.processingInstruction(target, data);
+        leaveEnvironment();
+    }
+
+    public void skippedEntity(String name)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.skippedEntity(name);
+        leaveEnvironment();
+    }
+
+    public void startDTD(String name, String publicId, String systemId)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.startDTD(name, publicId, systemId);
+        leaveEnvironment();
+    }
+
+    public void endDTD()
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.endDTD();
+        leaveEnvironment();
+    }
+
+    public void startEntity(String name)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.startEntity(name);
+        leaveEnvironment();
+    }
+
+    public void endEntity(String name)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.endEntity(name);
+        leaveEnvironment();
+    }
+
+    public void startCDATA()
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.startCDATA();
+        leaveEnvironment();
+    }
+
+    public void endCDATA()
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.endCDATA();
+        leaveEnvironment();
+    }
+
+    public void comment(char ch[], int start, int len)
+    throws SAXException {
+        enterEnvironment();
+        this.consumer.comment(ch, start, len);
+        leaveEnvironment();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/PushEnvironmentChanger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPopEnvironmentException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPopEnvironmentException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPopEnvironmentException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPopEnvironmentException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.internal;
+
+/**
+ * @version $Id$
+ * @since 2.2
+ */
+public final class UnableToPopEnvironmentException extends EnvironmentHelperException {
+
+    public UnableToPopEnvironmentException(String message) {
+        super(message, null);
+    }
+
+    public UnableToPopEnvironmentException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPopEnvironmentException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPushEnvironmentException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPushEnvironmentException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPushEnvironmentException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPushEnvironmentException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.internal;
+
+/**
+ * @version $Id$
+ * @since 2.2
+ */
+public final class UnableToPushEnvironmentException extends EnvironmentHelperException {
+
+    public UnableToPushEnvironmentException(String message) {
+        super(message, null);
+    }
+
+    public UnableToPushEnvironmentException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/UnableToPushEnvironmentException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,424 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.wrapper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.cocoon.environment.Cookie;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractRequest;
+
+
+/**
+ * This is a wrapper class for the <code>Request</code> object. It
+ * just forwards every methods. It is the base class for all wrapper
+ * implementations.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: AbstractRequestWrapper.java 232594 2005-08-14 10:20:29Z cziegeler $
+ * @since 2.2
+ */
+public abstract class AbstractRequestWrapper extends AbstractRequest {
+
+    /** The real {@link Request} object */
+    protected final Request req;
+
+    /**
+     * Constructor
+     */
+    public AbstractRequestWrapper(Request request) {
+        this.req = request;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#get(java.lang.String)
+     */
+    public Object get(String name) {
+        return this.req.get(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return this.req.getAttribute(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAttributeNames()
+     */
+    public Enumeration getAttributeNames() {
+        return this.req.getAttributeNames();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getCharacterEncoding()
+     */
+    public String getCharacterEncoding() {
+        return this.req.getCharacterEncoding();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#setCharacterEncoding(java.lang.String)
+     */
+    public void setCharacterEncoding(String enc)
+    throws java.io.UnsupportedEncodingException {
+        this.req.setCharacterEncoding(enc);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getContentLength()
+     */
+    public int getContentLength() {
+        return this.req.getContentLength();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getContentType()
+     */
+    public String getContentType() {
+        return this.req.getContentType();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getParameter(java.lang.String)
+     */
+    public String getParameter(String name) {
+        return this.req.getParameter(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getParameterNames()
+     */
+    public Enumeration getParameterNames() {
+        return this.req.getParameterNames();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getParameterValues(java.lang.String)
+     */
+    public String[] getParameterValues(String name) {
+        return this.req.getParameterValues(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getProtocol()
+     */
+    public String getProtocol() {
+        return this.req.getProtocol();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getScheme()
+     */
+    public String getScheme() {
+        return this.req.getScheme();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getServerName()
+     */
+    public String getServerName() {
+        return this.req.getServerName();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getServerPort()
+     */
+    public int getServerPort() {
+        return this.req.getServerPort();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getRemoteAddr()
+     */
+    public String getRemoteAddr() {
+        return this.req.getRemoteAddr();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getRemoteHost()
+     */
+    public String getRemoteHost() {
+        return this.req.getRemoteHost();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object o) {
+        this.req.setAttribute(name, o);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+        this.req.removeAttribute(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getLocale()
+     */
+    public Locale getLocale() {
+        return this.req.getLocale();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getLocales()
+     */
+    public Enumeration getLocales() {
+        return this.req.getLocales();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#isSecure()
+     */
+    public boolean isSecure() {
+        return this.req.isSecure();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getCookies()
+     */
+    public Cookie[] getCookies() {
+        return this.req.getCookies();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getCookieMap()
+     */
+    public Map getCookieMap() {
+        return this.req.getCookieMap();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getDateHeader(java.lang.String)
+     */
+    public long getDateHeader(String name) {
+        return this.req.getDateHeader(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getHeader(java.lang.String)
+     */
+    public String getHeader(String name) {
+        return this.req.getHeader(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getHeaders(java.lang.String)
+     */
+    public Enumeration getHeaders(String name) {
+        return this.req.getHeaders(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getHeaderNames()
+     */
+    public Enumeration getHeaderNames() {
+        return this.req.getHeaderNames();
+    }
+
+	/* (non-Javadoc)
+	 * @see org.apache.cocoon.environment.Request#getInputStream()
+	 */
+	public InputStream getInputStream() throws IOException, UnsupportedOperationException {
+		return this.req.getInputStream();
+	}
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getMethod()
+     */
+    public String getMethod() {
+        return this.req.getMethod();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getPathInfo()
+     */
+    public String getPathInfo() {
+        return this.req.getPathInfo();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getPathTranslated()
+     */
+    public String getPathTranslated() {
+        return this.req.getPathTranslated();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getContextPath()
+     */
+    public String getContextPath() {
+        return this.req.getContextPath();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getQueryString()
+     */
+    public String getQueryString() {
+        return this.req.getQueryString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getRemoteUser()
+     */
+    public String getRemoteUser() {
+        return this.req.getRemoteUser();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getRequestedSessionId()
+     */
+    public String getRequestedSessionId() {
+        return this.req.getRequestedSessionId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getRequestURI()
+     */
+    public String getRequestURI() {
+        return this.req.getRequestURI();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getSitemapURI()
+     */
+    public String getSitemapURI() {
+        return this.req.getSitemapURI();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getSitemapPath()
+     */
+    public String getSitemapPath() {
+        return this.req.getSitemapPath();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getServletPath()
+     */
+    public String getServletPath() {
+        return this.req.getServletPath();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getSession(boolean)
+     */
+    public Session getSession(boolean create) {
+        return this.req.getSession(create);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getSession()
+     */
+    public Session getSession() {
+        return this.req.getSession();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#isRequestedSessionIdValid()
+     */
+    public boolean isRequestedSessionIdValid() {
+        return this.req.isRequestedSessionIdValid();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#isRequestedSessionIdFromCookie()
+     */
+    public boolean isRequestedSessionIdFromCookie()  {
+        return this.req.isRequestedSessionIdFromCookie();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#isRequestedSessionIdFromURL()
+     */
+    public boolean isRequestedSessionIdFromURL() {
+        return this.req.isRequestedSessionIdFromURL();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getUserPrincipal()
+     */
+    public Principal getUserPrincipal() {
+        return this.req.getUserPrincipal();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#isUserInRole(java.lang.String)
+     */
+    public boolean isUserInRole(String role) {
+        return this.req.isUserInRole(role);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAuthType()
+     */
+    public String getAuthType() {
+        return this.req.getAuthType();
+    }       
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
+     */
+    public Object getAttribute(String name, int scope) {
+        return this.req.getAttribute(name, scope);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
+     */
+    public Enumeration getAttributeNames(int scope) {
+        return this.req.getAttributeNames(scope);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
+     */
+    public void removeAttribute(String name, int scope) {
+        this.req.removeAttribute(name,scope);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
+     */
+    public void setAttribute(String name, Object o, int scope) {
+        this.req.setAttribute(name, o, scope);
+    }
+
+    /**
+     * @see org.apache.cocoon.environment.Request#getSitemapURIPrefix()
+     */
+    public String getSitemapURIPrefix() {
+        return this.req.getSitemapURIPrefix();
+    }
+
+    /**
+     * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+     */
+    public Object searchAttribute(String name) {
+        return this.req.searchAttribute(name);
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,263 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.wrapper;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
+import org.apache.cocoon.environment.AbstractEnvironment;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.util.BufferedOutputStream;
+
+
+/**
+ * This is a wrapper class for the <code>Environment</code> object.
+ * It has the same properties except that the object model
+ * contains a <code>RequestWrapper</code> object.
+ *
+ * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: EnvironmentWrapper.java 165284 2005-04-29 09:24:28Z cziegeler $
+ */
+public class EnvironmentWrapper 
+    extends AbstractEnvironment {
+
+    /** The wrapped environment */
+    protected final Environment environment;
+
+    /** The redirect url */
+    protected String redirectURL;
+
+    /** The request object */
+    protected final Request request;
+
+    /** The stream to output to */
+    protected OutputStream outputStream;
+    
+    protected String contentType;
+
+    protected boolean internalRedirect = false;
+    
+    /**
+     * Construct a new environment.
+     * 
+     * @param env    The origial Environment
+     * @param info   A description of the uri for the new environment
+     * @param logger The logger to be used by this environment
+     */
+    public EnvironmentWrapper(Environment       env,
+                              SitemapSourceInfo info,
+                              Logger            logger) {
+        this(env, info, logger, true);
+    }
+
+    /**
+     * Construct a new environment.
+     * 
+     * @param env    The origial Environment
+     * @param info   A description of the uri for the new environment
+     * @param logger The logger to be used by this environment
+     * @param wrapResponse  Whether or not to wrap the Response object
+     */
+    public EnvironmentWrapper(Environment       env,
+                              SitemapSourceInfo info,
+                              Logger            logger,
+                              boolean           wrapResponse) {
+        super(env.getURI(), info.view, env.getAction());
+        
+        this.enableLogging(logger);
+        this.environment = env;
+
+        // create new object model and replace the request object
+        Map oldObjectModel = env.getObjectModel();
+        if (oldObjectModel instanceof HashMap) {
+            this.objectModel = (Map)((HashMap)oldObjectModel).clone();
+        } else {
+            this.objectModel = new HashMap(oldObjectModel.size()*2);
+            Iterator entries = oldObjectModel.entrySet().iterator();
+            Map.Entry entry;
+            while (entries.hasNext()) {
+                entry = (Map.Entry)entries.next();
+                this.objectModel.put(entry.getKey(), entry.getValue());
+            }
+        }
+        this.request = new RequestWrapper(ObjectModelHelper.getRequest(oldObjectModel),
+                                          info.requestURI,
+                                          info.queryString,
+                                          this,
+                                          info.rawMode);
+
+        this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request);
+        if (wrapResponse) {
+            Response response = new ResponseWrapper(ObjectModelHelper.getResponse(oldObjectModel));
+            this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, response);
+        }
+
+        this.setURI(info.prefix, info.uri);        
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#redirect(java.lang.String, boolean, boolean)
+     */
+    public void redirect(String newURL, boolean global, boolean permanent)
+    throws IOException {
+        if ( !global && !this.internalRedirect ) {
+            this.redirectURL = newURL;
+        } else {
+            this.environment.redirect(newURL, global, permanent);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getOutputStream(int)
+     */
+    public OutputStream getOutputStream(int bufferSize)
+    throws IOException {
+        return this.outputStream == null
+                ? this.environment.getOutputStream(bufferSize)
+                : this.outputStream;
+    }
+
+    /**
+     * Set the output stream for this environment. It hides the one of the
+     * wrapped environment.
+     */
+    public void setOutputStream(OutputStream stream) {
+        this.outputStream = stream;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#tryResetResponse()
+     */
+    public boolean tryResetResponse()
+    throws IOException {
+        final OutputStream os = this.getOutputStream(-1);
+        if (os != null
+            && os instanceof BufferedOutputStream) {
+            ((BufferedOutputStream)os).clearBuffer();
+            return true;
+        }
+        return super.tryResetResponse();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#commitResponse()
+     */
+    public void commitResponse() 
+    throws IOException {
+        final OutputStream os = this.getOutputStream(-1);
+        if (os != null
+            && os instanceof BufferedOutputStream) {
+            ((BufferedOutputStream)os).realFlush();
+        } else {
+            super.commitResponse();
+        }
+    }
+
+    /**
+     * if a redirect should happen this returns the url,
+     * otherwise <code>null</code> is returned
+     */
+    public String getRedirectURL() {
+        return this.redirectURL;
+    }
+    
+    public void reset() {
+        this.redirectURL = null;
+    }
+
+    /**
+     * Set the StatusCode
+     */
+    public void setStatus(int statusCode) {
+        // ignore this
+    }
+
+    public void setContentLength(int length) {
+        // ignore this
+    }
+
+    /**
+     * Set the ContentType
+     */
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    /**
+     * Get the ContentType
+     */
+    public String getContentType() {
+        return this.contentType;
+    }
+
+    /**
+     * Lookup an attribute in this instance, and if not found search it
+     * in the wrapped environment.
+     *
+     * @param name a <code>String</code>, the name of the attribute to
+     * look for
+     * @return an <code>Object</code>, the value of the attribute or
+     * null if no such attribute was found.
+     */
+    public Object getAttribute(String name) {
+        Object value = super.getAttribute(name);
+        if (value == null)
+            value = this.environment.getAttribute(name);
+
+        return value;
+    }
+
+    /**
+     * Remove attribute from the current instance, as well as from the
+     * wrapped environment.
+     *
+     * @param name a <code>String</code> value
+     */
+    public void removeAttribute(String name) {
+        super.removeAttribute(name);
+        this.environment.removeAttribute(name);
+    }
+
+    /**
+     * Always return <code>false</code>.
+     */
+    public boolean isExternal() {
+        return false;
+    }
+
+    public void setInternalRedirect(boolean flag) {
+        this.internalRedirect = flag;
+        if ( flag ) {
+            ((RequestWrapper)this.request).setRequestURI(this.prefix, this.uri);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#isInternRedirect()
+     */
+    public boolean isInternalRedirect() {
+        return this.internalRedirect;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,243 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.wrapper;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.apache.cocoon.components.treeprocessor.sitemap.MountNode;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ * Enviroment facade, whose delegate object can be changed. This class is
+ * required to handle internal redirects in sitemap sources ("cocoon:").
+ * This is because {@link org.apache.cocoon.components.source.impl.SitemapSource}
+ * keeps the environment in which the internal request should be processed.
+ * But internal redirects create a new processing environment and there's
+ * no way to change the one held by the <code>SitemapSource</code>. So the
+ * processing of internal redirects actually changes the delegate of this
+ * class, transparently for the <code>SitemapSource</code>.
+ *
+ * @see org.apache.cocoon.components.source.impl.SitemapSource
+ *
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version CVS $Id: MutableEnvironmentFacade.java 165642 2005-05-02 15:16:37Z sylvain $
+ */
+public class MutableEnvironmentFacade implements Environment {
+
+    private EnvironmentWrapper env;
+
+    public MutableEnvironmentFacade(EnvironmentWrapper env) {
+        this.env = env;
+        // Ensure we start with a false passthrough flag.
+        // FIXME: this should really be part of the Processor contract rather
+        // than an environment attribute
+        env.setAttribute(MountNode.COCOON_PASS_THROUGH, Boolean.FALSE);
+    }
+
+    public EnvironmentWrapper getDelegate() {
+        return this.env;
+    }
+
+    public void setDelegate(EnvironmentWrapper env) {
+        this.env = env;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setURI(java.lang.String, java.lang.String)
+     */
+    public void setURI(String prefix, String uri) {
+        this.env.setURI(prefix, uri);
+    }
+
+    public void setOutputStream(OutputStream os) {
+        this.env.setOutputStream(os);
+    }
+
+    // Move this to the Environment interface ?
+    public String getRedirectURL() {
+        return this.env.getRedirectURL();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getURI()
+     */
+    public String getURI() {
+        return env.getURI();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getURIPrefix()
+     */
+    public String getURIPrefix() {
+        return env.getURIPrefix();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getView()
+     */
+    public String getView() {
+        return env.getView();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getAction()
+     */
+    public String getAction() {
+        return env.getAction();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#redirect(String, boolean, boolean)
+     */
+    public void redirect(String url,
+                         boolean global,
+                         boolean permanent) throws IOException {
+        env.redirect(url, global, permanent);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setContentType(String)
+     */
+    public void setContentType(String mimeType) {
+        env.setContentType(mimeType);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getContentType()
+     */
+    public String getContentType() {
+        return env.getContentType();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setContentLength(int)
+     */
+    public void setContentLength(int length) {
+        env.setContentLength(length);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setStatus(int)
+     */
+    public void setStatus(int statusCode) {
+        env.setStatus(statusCode);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getOutputStream(int)
+     */
+    public OutputStream getOutputStream(int bufferSize) throws IOException {
+        return env.getOutputStream(bufferSize);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getObjectModel()
+     */
+    public Map getObjectModel() {
+        return env.getObjectModel();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#isResponseModified(long)
+     */
+    public boolean isResponseModified(long lastModified) {
+        return env.isResponseModified(lastModified);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setResponseIsNotModified()
+     */
+    public void setResponseIsNotModified() {
+        env.setResponseIsNotModified();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setAttribute(String, Object)
+     */
+    public void setAttribute(String name, Object value) {
+        env.setAttribute(name, value);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return env.getAttribute(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+        env.removeAttribute(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getAttributeNames()
+     */
+    public Enumeration getAttributeNames() {
+        return env.getAttributeNames();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#tryResetResponse()
+     */
+    public boolean tryResetResponse() throws IOException {
+        return env.tryResetResponse();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#commitResponse()
+     */
+    public void commitResponse() throws IOException {
+        env.commitResponse();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#startingProcessing()
+     */
+    public void startingProcessing() {
+        env.startingProcessing();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#finishingProcessing()
+     */
+    public void finishingProcessing() {
+        env.finishingProcessing();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#isExternal()
+     */
+    public boolean isExternal() {
+        return env.isExternal();
+    }
+
+    public void reset() {
+        this.env.reset();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#isInternRedirect()
+     */
+    public boolean isInternalRedirect() {
+        return env.isInternalRedirect();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestParameters.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestParameters.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestParameters.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestParameters.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,182 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.wrapper;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * This class is used by the <code>RequestWrapper</code>. It parses
+ * a query string and creates a parameter representation required
+ * for the <code>Request</code> object.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: RequestParameters.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public final class RequestParameters
+implements Serializable {
+
+    /** The parameter names are the keys and the value is a List object */
+    private Map names;
+
+    /**
+     * Decode the string
+     */
+    private String parseName(String s) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            switch (c) {
+                case '+':
+                    sb.append(' ');
+                    break;
+                case '%':
+                    try {
+                        sb.append((char) Integer.parseInt(s.substring(i+1, i+3),
+                              16));
+                        i += 2;
+                    } catch (NumberFormatException e) {
+                        throw new IllegalArgumentException();
+                    } catch (StringIndexOutOfBoundsException e) {
+                        String rest  = s.substring(i);
+                        sb.append(rest);
+                        if (rest.length()==2)
+                            i++;
+                    }
+
+                    break;
+                default:
+                    sb.append(c);
+                    break;
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Construct a new object from a queryString
+     */
+    public RequestParameters(String queryString) {
+        this.names = new HashMap(5);
+        if (queryString != null) {
+            StringTokenizer st = new StringTokenizer(queryString, "&");
+            while (st.hasMoreTokens()) {
+                String pair = st.nextToken();
+                int pos = pair.indexOf('=');
+                if (pos != -1) {
+                    this.setParameter(this.parseName(pair.substring(0, pos)),
+                                      this.parseName(pair.substring(pos+1, pair.length())));
+                }
+            }
+        }
+    }
+
+    /**
+     * Add a parameter.
+     * The parameter is added with the given value.
+     * @param name   The name of the parameter.
+     * @param value  The value of the parameter.
+     */
+    private void setParameter(String name, String value) {
+        ArrayList list;
+        if (names.containsKey(name)) {
+            list = (ArrayList)names.get(name);
+        } else {
+            list = new ArrayList(3);
+            names.put(name, list);
+        }
+        list.add(value);
+    }
+
+    /**
+     * Get the value of a parameter.
+     * @param name   The name of the parameter.
+     * @return       The value of the first parameter with the name
+     *               or <CODE>null</CODE>
+     */
+    public String getParameter(String name) {
+        if (names.containsKey(name)) {
+            return (String)((ArrayList)names.get(name)).get(0);
+        }
+        return null;
+    }
+
+    /**
+     * Get the value of a parameter.
+     * @param name   The name of the parameter.
+     * @param defaultValue The default value if the parameter does not exist.
+     * @return       The value of the first parameter with the name
+     *               or <CODE>defaultValue</CODE>
+     */
+    public String getParameter(String name, String defaultValue) {
+        if (names.containsKey(name)) {
+            return (String)((ArrayList)names.get(name)).get(0);
+        }
+        return defaultValue;
+    }
+
+    /**
+     * Get all values of a parameter.
+     * @param name   The name of the parameter.
+     * @return       Array of the (String) values or null if the parameter
+     *               is not defined.
+     */
+    public String[] getParameterValues(String name) {
+        if (names.containsKey(name)) {
+            String values[] = null;
+            ArrayList list = (ArrayList)names.get(name);
+            Iterator iter = list.iterator();
+            while (iter.hasNext()) {
+                if (values == null) {
+                    values = new String[1];
+                } else {
+                    String[] copy = new String[values.length+1];
+                    System.arraycopy(values, 0, copy, 0, values.length);
+                    values = copy;
+                }
+                values[values.length-1] = (String)iter.next();
+            }
+            return values;
+        }
+        return null;
+    }
+
+    /**
+     * Get all parameter names.
+     * @return  Enumeration for the (String) parameter names.
+     */
+    public Enumeration getParameterNames() {
+        return new EnumerationFromIterator(names.keySet().iterator());
+    }
+
+    final class EnumerationFromIterator implements Enumeration {
+        private Iterator iter;
+        EnumerationFromIterator(Iterator iter) {
+            this.iter = iter;
+        }
+
+        public boolean hasMoreElements() {
+            return iter.hasNext();
+        }
+        public Object nextElement() { return iter.next(); }
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,243 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.wrapper;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Request;
+import org.apache.commons.collections.IteratorUtils;
+
+/**
+ * This is a wrapper class for the <code>Request</code> object.
+ * It has the same properties except that the url and the parameters
+ * are different.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version $Id: RequestWrapper.java 202268 2005-06-28 19:03:15Z vgritsenko $
+ */
+public final class RequestWrapper extends AbstractRequestWrapper {
+
+    /** The query string */
+    private String queryString;
+
+    /** The request parameters */
+    private final RequestParameters parameters ;
+
+    /** The environment */
+    private final Environment environment;
+
+    /** raw mode? **/
+    private final boolean rawMode;
+
+    /** The request uri */
+    private String requestURI;
+
+    private final Map requestAttributes = new HashMap();
+    
+    /**
+     * Constructor
+     */
+    public RequestWrapper(Request request,
+                          String  requestURI,
+                          String  queryString,
+                          Environment env) {
+        this(request, requestURI, queryString, env, false);
+    }
+
+    /**
+     * Constructor
+     */
+    public RequestWrapper(Request request,
+                          String  requestURI,
+                          String  queryString,
+                          Environment env,
+                          boolean rawMode) {
+        super(request);
+        this.environment = env;
+        this.queryString = queryString;
+        this.parameters = new RequestParameters(queryString);
+        this.rawMode = rawMode;
+        if (this.req.getQueryString() != null && !this.rawMode) {
+            if (this.queryString == null)
+                this.queryString = this.req.getQueryString();
+            else
+                this.queryString += '&' + this.req.getQueryString();
+        }
+        this.requestURI = this.req.getRequestURI();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getParameter(java.lang.String)
+     */
+    public String getParameter(String name) {
+        String value = this.parameters.getParameter(name);
+        if (value == null && !this.rawMode) {
+            return this.req.getParameter(name);
+        }
+        return value;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getParameterNames()
+     */
+    public Enumeration getParameterNames() {
+        if ( !this.rawMode ) {
+            // put all parameter names into a set
+            Set parameterNames = new HashSet();
+            Enumeration names = this.parameters.getParameterNames();
+            while (names.hasMoreElements()) {
+                parameterNames.add(names.nextElement());
+            }
+            names = this.req.getParameterNames();
+            while (names.hasMoreElements()) {
+                parameterNames.add(names.nextElement());
+            }
+            return new EnumerationFromIterator(parameterNames.iterator());
+        }
+        return this.parameters.getParameterNames();
+    }
+
+    final class EnumerationFromIterator implements Enumeration {
+        private Iterator iter;
+        EnumerationFromIterator(Iterator iter) {
+            this.iter = iter;
+        }
+
+        public boolean hasMoreElements() {
+            return iter.hasNext();
+        }
+        public Object nextElement() { return iter.next(); }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getParameterValues(java.lang.String)
+     */
+    public String[] getParameterValues(String name) {
+        if ( !this.rawMode ) {
+            String[] values = this.parameters.getParameterValues(name);
+            String[] inherited = this.req.getParameterValues(name);
+            if (inherited == null) return values;
+            if (values == null) return inherited;
+            String[] allValues = new String[values.length + inherited.length];
+            System.arraycopy(values, 0, allValues, 0, values.length);
+            System.arraycopy(inherited, 0, allValues, values.length, inherited.length);
+            return allValues;
+        }
+        return this.parameters.getParameterValues(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getQueryString()
+     */
+    public String getQueryString() {
+        return this.queryString;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getRequestURI()
+     */
+    public String getRequestURI() {
+        return this.requestURI;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getSitemapURI()
+     */
+    public String getSitemapURI() {
+        return this.environment.getURI();
+    }
+
+    public String getSitemapURIPrefix() {
+        return this.environment.getURIPrefix();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getSitemapPath()
+     */
+    public String getSitemapPath() {
+        return this.environment.getURIPrefix();
+    }
+
+    public void setRequestURI(String prefix, String uri) {
+        StringBuffer buffer = new StringBuffer(this.getContextPath());
+        buffer.append('/');
+        buffer.append(prefix);
+        buffer.append(uri);
+        this.requestURI = buffer.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
+     */
+    public Object getAttribute(String name, int scope) {
+        if ( scope == Request.GLOBAL_SCOPE ) {
+            return super.getAttribute(name, scope);
+        }
+        return this.requestAttributes.get( name );
+    }
+        
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
+     */
+    public Enumeration getAttributeNames(int scope) {
+        if ( scope == Request.GLOBAL_SCOPE ) {
+            return super.getAttributeNames(scope);
+        }
+        return IteratorUtils.asEnumeration(this.requestAttributes.keySet().iterator());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
+     */
+    public void removeAttribute(String name, int scope) {
+        if ( scope == Request.GLOBAL_SCOPE ) {
+            super.removeAttribute(name, scope);
+        } else {
+            this.requestAttributes.remove( name );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
+     */
+    public void setAttribute(String name, Object o, int scope) {
+        if ( scope == Request.GLOBAL_SCOPE ) {
+            super.setAttribute(name, o, scope);
+        } else {
+            this.requestAttributes.put( name, o );
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+     */
+    public Object searchAttribute(String name) {
+        Object result = this.getAttribute(name, REQUEST_SCOPE);
+        if ( result == null ) {
+            result = this.getAttribute(name, GLOBAL_SCOPE);
+            if ( result == null ) {
+                result = this.req.getAttribute(name, REQUEST_SCOPE);
+            }
+        }
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.wrapper;
+
+import java.util.Locale;
+
+import org.apache.cocoon.environment.Cookie;
+import org.apache.cocoon.environment.Response;
+
+/**
+ * This is a wrapper class for the Response object.
+ * It contains the same properties as the wrapped instance
+ * but swallows calls that would modify response headers.
+ */
+public class ResponseWrapper implements Response {
+
+    private Response res;
+    
+    public ResponseWrapper(Response response) {
+        this.res = response;
+    }
+
+    public String getCharacterEncoding() {
+        return res.getCharacterEncoding();
+    }
+
+    public void setLocale(Locale loc) {
+        res.setLocale(loc);
+    }
+
+    public Locale getLocale() {
+        return res.getLocale();
+    }
+
+    public Cookie createCookie(String name, String value) {
+        return res.createCookie(name, value);
+    }
+
+    public void addCookie(Cookie cookie) {
+        res.addCookie(cookie);
+    }
+
+    public String encodeURL(String url) {
+        return res.encodeURL(url);
+    }
+
+    public boolean containsHeader(String name) {
+        return res.containsHeader(name);
+    }
+
+    public void setDateHeader(String name, long date) {
+    }
+
+    public void addDateHeader(String name, long date) {
+    }
+
+    public void setHeader(String name, String value) {
+    }
+
+    public void addHeader(String name, String value) {
+    }
+
+    public void setIntHeader(String name, int value) {
+    }
+
+    public void addIntHeader(String name, int value) {
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.generation;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.xml.AbstractXMLProducer;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * An abstract class that can be used to implement an own generator.
+ * If you need other components, use the {@link ServiceableGenerator}
+ * instead.
+ * 
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @version CVS $Id: AbstractGenerator.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public abstract class AbstractGenerator 
+    extends AbstractXMLProducer 
+    implements Generator {
+
+    /** The current <code>SourceResolver</code>. */
+    protected SourceResolver resolver;
+    /** The current <code>Map</code> objectModel. */
+    protected Map objectModel;
+    /** The current <code>Parameters</code>. */
+    protected Parameters parameters;
+    /** The source URI associated with the request or <b>null</b>. */
+    protected String source;
+
+    /**
+     * Set the <code>SourceResolver</code>, object model <code>Map</code>,
+     * the source and sitemap <code>Parameters</code> used to process the request.
+     */
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+        throws ProcessingException, SAXException, IOException {
+        this.resolver=resolver;
+        this.objectModel=objectModel;
+        this.source=src;
+        this.parameters=par;
+    }
+
+    /**
+     * Recycle the generator by removing references
+     */
+    public void recycle() {
+        super.recycle();
+        this.resolver = null;
+        this.objectModel = null;
+        this.source = null;
+        this.parameters = null;
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message