This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5233-tiles
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/WW-5233-tiles by this push:
     new 017a2e30b WW-5233 Copies Portlet related Tiles code base
017a2e30b is described below

commit 017a2e30b1752864a0c9fc6ab162b05182d4b5c8
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sat Oct 1 17:51:38 2022 +0200

    WW-5233 Copies Portlet related Tiles code base
---
 .../tiles/request/portlet/PortletRequest.java      | 344 +++++++++++++++++++++
 .../request/portlet/RenderPortletRequest.java      |  47 +++
 .../portlet/delegate/MimeResponseDelegate.java     |  72 +++++
 .../portlet/delegate/PortletRequestDelegate.java   |  79 +++++
 .../request/portlet/delegate/RequestDelegate.java  |  43 +++
 .../request/portlet/delegate/ResponseDelegate.java |  70 +++++
 .../portlet/delegate/StateAwareParameterMap.java   | 112 +++++++
 .../delegate/StateAwareRequestDelegate.java        |  83 +++++
 .../delegate/StateAwareResponseDelegate.java       |  57 ++++
 .../request/portlet/delegate/package-info.java     |  24 ++
 .../extractor/ApplicationScopeExtractor.java       |  66 ++++
 .../request/portlet/extractor/HeaderExtractor.java |  74 +++++
 .../portlet/extractor/InitParameterExtractor.java  |  57 ++++
 .../portlet/extractor/ParameterExtractor.java      |  56 ++++
 .../portlet/extractor/RequestScopeExtractor.java   |  66 ++++
 .../portlet/extractor/SessionScopeExtractor.java   |  88 ++++++
 .../extractor/StateAwareParameterExtractor.java    |  53 ++++
 .../request/portlet/extractor/package-info.java    |  24 ++
 .../apache/tiles/request/portlet/package-info.java |  24 ++
 .../request/collection/AddableParameterMap.java    |  95 ++++++
 20 files changed, 1534 insertions(+)

diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java
new file mode 100644
index 000000000..6946776e4
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java
@@ -0,0 +1,344 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet;
+
+import org.apache.tiles.request.AbstractClientRequest;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.attribute.Addable;
+import org.apache.tiles.request.collection.HeaderValuesMap;
+import org.apache.tiles.request.collection.ReadOnlyEnumerationMap;
+import org.apache.tiles.request.collection.ScopeMap;
+import org.apache.tiles.request.portlet.delegate.RequestDelegate;
+import org.apache.tiles.request.portlet.delegate.ResponseDelegate;
+import org.apache.tiles.request.portlet.extractor.HeaderExtractor;
+import org.apache.tiles.request.portlet.extractor.RequestScopeExtractor;
+import org.apache.tiles.request.portlet.extractor.SessionScopeExtractor;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Portlet-based TilesApplicationContext implementation.
+ */
+public class PortletRequest extends AbstractClientRequest {
+
+    /**
+     * The native available scopes.
+     */
+    private static final List<String> SCOPES = 
Collections.unmodifiableList(Arrays.asList(REQUEST_SCOPE, "portletSession", 
"session", APPLICATION_SCOPE));
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of header name-value
+     * combinations (immutable).</p>
+     */
+    private Map<String, String> header = null;
+
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of header name-value
+     * combinations (write-only).</p>
+     */
+    private Addable<String> responseHeaders = null;
+
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of header name-values
+     * combinations (immutable).</p>
+     */
+    private Map<String, String[]> headerValues = null;
+
+    /**
+     * The <code>PortletContext</code> for this application.
+     */
+    protected PortletContext context;
+
+    /**
+     * <p>The <code>PortletRequest</code> for this request.</p>
+     */
+    protected javax.portlet.PortletRequest request;
+
+    /**
+     * The delegate to get information about parameters.
+     */
+    protected RequestDelegate requestDelegate;
+
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of request scope
+     * attributes.</p>
+     */
+    private Map<String, Object> requestScope = null;
+
+
+    /**
+     * <p>The <code>PortletResponse</code> for this request.</p>
+     */
+    protected PortletResponse response;
+
+    /**
+     * The delegate to get information from a response (output stream, writer, 
etc.).
+     */
+    protected ResponseDelegate responseDelegate;
+
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of session scope
+     * attributes.</p>
+     */
+    private Map<String, Object> sessionScope = null;
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of portlet session scope
+     * attributes.</p>
+     */
+    private Map<String, Object> portletSessionScope = null;
+
+
+    /**
+     * Creates a new instance of PortletTilesRequestContext.
+     *
+     * @param applicationContext The Tiles application context.
+     * @param context            The portlet context to use.
+     * @param request            The request object to use.
+     * @param response           The response object to use.
+     * @param requestDelegate    The request delegate.
+     * @param responseDelegate   The response delegate.
+     */
+    public PortletRequest(ApplicationContext applicationContext,
+                          PortletContext context, javax.portlet.PortletRequest 
request,
+                          PortletResponse response, RequestDelegate 
requestDelegate, ResponseDelegate responseDelegate) {
+        super(applicationContext);
+
+        // Save the specified Portlet API object references
+        this.context = context;
+        this.request = request;
+        this.response = response;
+        this.requestDelegate = requestDelegate;
+        this.responseDelegate = responseDelegate;
+    }
+
+    /**
+     * <p>Return the {@link PortletRequest} for this context.</p>
+     *
+     * @return The used portlet request.
+     */
+    public javax.portlet.PortletRequest getRequest() {
+        return (this.request);
+    }
+
+    /**
+     * Returns the portlet context.
+     *
+     * @return The portlet context.
+     */
+    public PortletContext getPortletContext() {
+        return context;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, String> getHeader() {
+        if ((header == null) && (request != null)) {
+            header = new ReadOnlyEnumerationMap<>(new HeaderExtractor(request, 
null));
+        }
+        return (header);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Addable<String> getResponseHeaders() {
+        if ((responseHeaders == null) && (request != null)) {
+            responseHeaders = new HeaderExtractor(null, response);
+        }
+        return (responseHeaders);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, String[]> getHeaderValues() {
+        if ((headerValues == null) && (request != null)) {
+            headerValues = new HeaderValuesMap(new HeaderExtractor(request, 
response));
+        }
+        return (headerValues);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, Object> getRequestScope() {
+        if ((requestScope == null) && (request != null)) {
+            requestScope = new ScopeMap(new RequestScopeExtractor(request));
+        }
+        return (requestScope);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, Object> getSessionScope() {
+        if ((sessionScope == null) && (request != null)) {
+            sessionScope = new ScopeMap(new SessionScopeExtractor(request,
+                PortletSession.APPLICATION_SCOPE));
+        }
+        return (sessionScope);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, Object> getPortletSessionScope() {
+        if ((portletSessionScope == null) && (request != null)) {
+            portletSessionScope = new ScopeMap(new SessionScopeExtractor(
+                request, PortletSession.APPLICATION_SCOPE));
+        }
+        return (portletSessionScope);
+    }
+
+    @Override
+    public List<String> getAvailableScopes() {
+        return SCOPES;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Locale getRequestLocale() {
+        return request.getLocale();
+    }
+
+    @Override
+    public Map<String, String> getParam() {
+        return requestDelegate.getParam();
+    }
+
+    @Override
+    public Map<String, String[]> getParamValues() {
+        return requestDelegate.getParamValues();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isUserInRole(String role) {
+        return request.isUserInRole(role);
+    }
+
+    @Override
+    public OutputStream getOutputStream() throws IOException {
+        return responseDelegate.getOutputStream();
+    }
+
+    @Override
+    public PrintWriter getPrintWriter() throws IOException {
+        return responseDelegate.getPrintWriter();
+    }
+
+    @Override
+    public Writer getWriter() throws IOException {
+        return responseDelegate.getWriter();
+    }
+
+    @Override
+    public boolean isResponseCommitted() {
+        return responseDelegate.isResponseCommitted();
+    }
+
+    @Override
+    public void setContentType(String contentType) {
+        responseDelegate.setContentType(contentType);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void doForward(String path) throws IOException {
+        if (responseDelegate.isResponseCommitted()) {
+            doInclude(path);
+            return;
+        }
+
+        try {
+            PortletRequestDispatcher rd = getPortletContext()
+                .getRequestDispatcher(path);
+
+            if (rd == null) {
+                throw new IOException(
+                    "No portlet request dispatcher returned for path '"
+                        + path + "'");
+            }
+
+            rd.forward(request, response);
+        } catch (PortletException e) {
+            throw new IOException("PortletException while including path '"
+                + path + "'.", e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void doInclude(String path) throws IOException {
+        try {
+            PortletRequestDispatcher rd = getPortletContext()
+                .getRequestDispatcher(path);
+
+            if (rd == null) {
+                throw new IOException(
+                    "No portlet request dispatcher returned for path '"
+                        + path + "'");
+            }
+
+            rd.include(request, response);
+        } catch (PortletException e) {
+            throw new IOException("PortletException while including path '"
+                + path + "'.", e);
+        }
+    }
+
+    @Override
+    public Map<String, Object> getContext(String scope) {
+        if (REQUEST_SCOPE.equals(scope)) {
+            return getRequestScope();
+        } else if ("session".equals(scope)) {
+            return getSessionScope();
+        } else if ("portletSession".equals(scope)) {
+            return getPortletSessionScope();
+        } else if (APPLICATION_SCOPE.equals(scope)) {
+            return getApplicationScope();
+        }
+        throw new IllegalArgumentException(scope + " does not exist. Call 
getAvailableScopes() first to check.");
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/RenderPortletRequest.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/RenderPortletRequest.java
new file mode 100644
index 000000000..ea22c38a2
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/RenderPortletRequest.java
@@ -0,0 +1,47 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet;
+
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.portlet.delegate.MimeResponseDelegate;
+import org.apache.tiles.request.portlet.delegate.PortletRequestDelegate;
+
+import javax.portlet.PortletContext;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+/**
+ * Portlet request for a {@link RenderRequest}.
+ */
+public class RenderPortletRequest extends PortletRequest {
+
+    /**
+     * Constructor.
+     *
+     * @param applicationContext The application context.
+     * @param context            The portlet context.
+     * @param request            The portlet request.
+     * @param response           The portlet response.
+     */
+    public RenderPortletRequest(ApplicationContext applicationContext, 
PortletContext context, RenderRequest request, RenderResponse response) {
+        super(applicationContext, context, request, response, new 
PortletRequestDelegate(request), new MimeResponseDelegate(response));
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/MimeResponseDelegate.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/MimeResponseDelegate.java
new file mode 100644
index 000000000..347873cf1
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/MimeResponseDelegate.java
@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import javax.portlet.MimeResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+/**
+ * Response delegate in case of {@link MimeResponse}.
+ */
+public class MimeResponseDelegate implements ResponseDelegate {
+
+    /**
+     * The response.
+     */
+    private final MimeResponse response;
+
+    /**
+     * Constructor.
+     *
+     * @param response The response.
+     */
+    public MimeResponseDelegate(MimeResponse response) {
+        this.response = response;
+    }
+
+    /** {@inheritDoc} */
+    public OutputStream getOutputStream() throws IOException {
+        return response.getPortletOutputStream();
+    }
+
+    /** {@inheritDoc} */
+    public PrintWriter getPrintWriter() throws IOException {
+        return response.getWriter();
+    }
+
+    /** {@inheritDoc} */
+    public Writer getWriter() throws IOException {
+        return response.getWriter();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isResponseCommitted() {
+        return response.isCommitted();
+    }
+
+    /** {@inheritDoc} */
+    public void setContentType(String contentType) {
+        response.setContentType(contentType);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/PortletRequestDelegate.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/PortletRequestDelegate.java
new file mode 100644
index 000000000..e5683d5a0
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/PortletRequestDelegate.java
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import org.apache.tiles.request.collection.ReadOnlyEnumerationMap;
+import org.apache.tiles.request.portlet.extractor.ParameterExtractor;
+
+import javax.portlet.PortletRequest;
+import java.util.Map;
+
+/**
+ * Request delegate in case of simple Portlet request.
+ */
+public class PortletRequestDelegate implements RequestDelegate {
+
+    /**
+     * The request.
+     */
+    private final PortletRequest request;
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of request
+     * parameter name-value.</p>
+     */
+    private Map<String, String> param = null;
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of request
+     * parameter name-values.</p>
+     */
+    private Map<String, String[]> paramValues = null;
+
+    /**
+     * Constructor.
+     *
+     * @param request The request.
+     */
+    public PortletRequestDelegate(PortletRequest request) {
+        this.request = request;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, String> getParam() {
+        if ((param == null) && (request != null)) {
+            param = new ReadOnlyEnumerationMap<>(new 
ParameterExtractor(request));
+        }
+        return (param);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, String[]> getParamValues() {
+        if ((paramValues == null) && (request != null)) {
+            paramValues = request.getParameterMap();
+        }
+        return (paramValues);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/RequestDelegate.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/RequestDelegate.java
new file mode 100644
index 000000000..03846cc72
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/RequestDelegate.java
@@ -0,0 +1,43 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import java.util.Map;
+
+/**
+ * Exposes the parameters of a portlet request, if available.
+ */
+public interface RequestDelegate {
+
+    /**
+     * The parameters, as single values.
+     *
+     * @return The parameters.
+     */
+    Map<String, String> getParam();
+
+    /**
+     * The parameters, with values as array of strings.
+     *
+     * @return The parameters.
+     */
+    Map<String, String[]> getParamValues();
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/ResponseDelegate.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/ResponseDelegate.java
new file mode 100644
index 000000000..92f46cef6
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/ResponseDelegate.java
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+/**
+ * Exposes features of a response, if they are available.
+ */
+public interface ResponseDelegate {
+
+    /**
+     * Returns the output stream.
+     *
+     * @return The output stream.
+     * @throws IOException If the underlying response causes a problem.
+     */
+    OutputStream getOutputStream() throws IOException;
+
+    /**
+     * Returns the print writer.
+     *
+     * @return The print writer.
+     * @throws IOException If the underlying response causes a problem.
+     */
+    PrintWriter getPrintWriter() throws IOException;
+
+    /**
+     * Returns the writer.
+     *
+     * @return The writer.
+     * @throws IOException If the underlying response causes a problem.
+     */
+    Writer getWriter() throws IOException;
+
+    /**
+     * Sets the content type of the response.
+     *
+     * @param contentType The content type.
+     */
+    void setContentType(String contentType);
+
+    /**
+     * Checks if the response is committed.
+     *
+     * @return <code>true</code> if the response is committed.
+     */
+    boolean isResponseCommitted();
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareParameterMap.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareParameterMap.java
new file mode 100644
index 000000000..34e36bb31
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareParameterMap.java
@@ -0,0 +1,112 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Parameter map to be used when the response is a {@link 
javax.portlet.StateAwareResponse}.
+ */
+public class StateAwareParameterMap implements Map<String, String[]> {
+
+    /**
+     * The request parameter map.
+     */
+    private final Map<String, String[]> requestMap;
+
+    /**
+     * The response parameter map.
+     */
+    private final Map<String, String[]> responseMap;
+
+    /**
+     * Constructor.
+     *
+     * @param requestMap The request parameter map.
+     * @param responseMap The response parameter map.
+     */
+    public StateAwareParameterMap(Map<String, String[]> requestMap, 
Map<String, String[]> responseMap) {
+        this.requestMap = requestMap;
+        this.responseMap = responseMap;
+    }
+
+    @Override
+    public void clear() {
+        responseMap.clear();
+    }
+
+    @Override
+    public boolean containsKey(Object key) {
+        return requestMap.containsKey(key);
+    }
+
+    @Override
+    public boolean containsValue(Object value) {
+        return requestMap.containsValue(value);
+    }
+
+    @Override
+    public Set<Entry<String, String[]>> entrySet() {
+        return requestMap.entrySet();
+    }
+
+    @Override
+    public String[] get(Object key) {
+        return requestMap.get(key);
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return requestMap.isEmpty();
+    }
+
+    @Override
+    public Set<String> keySet() {
+        return requestMap.keySet();
+    }
+
+    @Override
+    public String[] put(String key, String[] value) {
+        return responseMap.put(key, value);
+    }
+
+    @Override
+    public void putAll(Map<? extends String, ? extends String[]> m) {
+        responseMap.putAll(m);
+    }
+
+    @Override
+    public String[] remove(Object key) {
+        return responseMap.remove(key);
+    }
+
+    @Override
+    public int size() {
+        return requestMap.size();
+    }
+
+    @Override
+    public Collection<String[]> values() {
+        return requestMap.values();
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareRequestDelegate.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareRequestDelegate.java
new file mode 100644
index 000000000..ede98a745
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareRequestDelegate.java
@@ -0,0 +1,83 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import org.apache.tiles.request.collection.AddableParameterMap;
+import org.apache.tiles.request.portlet.extractor.StateAwareParameterExtractor;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.StateAwareResponse;
+import java.util.Map;
+
+/**
+ * Exposes parameters getting them from a portlet reques and allowing to be 
put into a {@link StateAwareResponse}.
+ */
+public class StateAwareRequestDelegate implements RequestDelegate {
+
+    /**
+     * The request.
+     */
+    private final PortletRequest request;
+
+    /**
+     * The response.
+     */
+    private final StateAwareResponse response;
+
+    /**
+     * Constructor.
+     *
+     * @param request The request.
+     * @param response The response.
+     */
+    public StateAwareRequestDelegate(PortletRequest request, 
StateAwareResponse response) {
+        this.request = request;
+        this.response = response;
+    }
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of request
+     * parameter name-value.</p>
+     */
+    private Map<String, String> param = null;
+
+    /**
+     * <p>The lazily instantiated <code>Map</code> of request
+     * parameter name-values.</p>
+     */
+    private Map<String, String[]> paramValues = null;
+
+    /** {@inheritDoc} */
+    public Map<String, String> getParam() {
+        if ((param == null) && (request != null)) {
+            param = new AddableParameterMap(new 
StateAwareParameterExtractor(request, response));
+        }
+        return (param);
+    }
+
+    /** {@inheritDoc} */
+    public Map<String, String[]> getParamValues() {
+        if ((paramValues == null) && (request != null)) {
+            paramValues = new 
StateAwareParameterMap(request.getParameterMap(), 
response.getRenderParameterMap());
+        }
+        return (paramValues);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareResponseDelegate.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareResponseDelegate.java
new file mode 100644
index 000000000..20e05cbcb
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/StateAwareResponseDelegate.java
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.delegate;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+/**
+ * A state aware response does not allow to access to the output stream and 
similar, so it is, essentially,
+ * a feature blocker.
+ */
+public class StateAwareResponseDelegate implements ResponseDelegate {
+
+    @Override
+    public OutputStream getOutputStream() {
+        throw new UnsupportedOperationException("No outputstream available for 
state-aware response");
+    }
+
+    @Override
+    public PrintWriter getPrintWriter() {
+        throw new UnsupportedOperationException("No outputstream available for 
state-aware response");
+    }
+
+    @Override
+    public Writer getWriter() {
+        throw new UnsupportedOperationException("No outputstream available for 
state-aware response");
+    }
+
+    @Override
+    public boolean isResponseCommitted() {
+        return false;
+    }
+
+    @Override
+    public void setContentType(String contentType) {
+        throw new UnsupportedOperationException("No outputstream available for 
state-aware response");
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/package-info.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/package-info.java
new file mode 100644
index 000000000..5080dc3e0
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/delegate/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * $Id: package-info.java 1049711 2010-12-15 21:12:00Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+/**
+ * Delegations to map all the different types of request and responses.
+ */
+package org.apache.tiles.request.portlet.delegate;
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/ApplicationScopeExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/ApplicationScopeExtractor.java
new file mode 100644
index 000000000..590046cff
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/ApplicationScopeExtractor.java
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.AttributeExtractor;
+
+import javax.portlet.PortletContext;
+import java.util.Enumeration;
+
+/**
+ * Extracts attributes from portlet application scope.
+ */
+public class ApplicationScopeExtractor implements AttributeExtractor {
+
+    /**
+     * The portlet context.
+     */
+    private final PortletContext context;
+
+    /**
+     * Constructor.
+     *
+     * @param context The portlet context.
+     */
+    public ApplicationScopeExtractor(PortletContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public void setValue(String name, Object value) {
+        context.setAttribute(name, value);
+    }
+
+    @Override
+    public void removeValue(String name) {
+        context.removeAttribute(name);
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        return context.getAttributeNames();
+    }
+
+    @Override
+    public Object getValue(String key) {
+        return context.getAttribute(key);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/HeaderExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/HeaderExtractor.java
new file mode 100644
index 000000000..0c94fa90f
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/HeaderExtractor.java
@@ -0,0 +1,74 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.EnumeratedValuesExtractor;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import java.util.Enumeration;
+
+/**
+ * Extracts and puts headers in portlet requests and responses.
+ */
+public class HeaderExtractor implements EnumeratedValuesExtractor {
+
+    /**
+     * The request.
+     */
+    private final PortletRequest request;
+
+    /**
+     * The response.
+     */
+    private final PortletResponse response;
+
+    /**
+     * Constructor.
+     *
+     * @param request The request.
+     * @param response The response.
+     */
+    public HeaderExtractor(PortletRequest request, PortletResponse response) {
+        this.request = request;
+        this.response = response;
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        return request.getPropertyNames();
+   }
+
+    @Override
+    public String getValue(String key) {
+        return request.getProperty(key);
+    }
+
+    @Override
+    public Enumeration<String> getValues(String key) {
+        return request.getProperties(key);
+    }
+
+    @Override
+    public void setValue(String key, String value) {
+        response.setProperty(key, value);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/InitParameterExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/InitParameterExtractor.java
new file mode 100644
index 000000000..f27fdf4f1
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/InitParameterExtractor.java
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.HasKeys;
+
+import javax.portlet.PortletContext;
+import java.util.Enumeration;
+
+/**
+ * Extracts init parameters from a portlet context.
+ */
+public class InitParameterExtractor implements HasKeys<String> {
+
+    /**
+     * The portlet context.
+     */
+    private final PortletContext context;
+
+    /**
+     * Constructor.
+     *
+     * @param context The portlet context.
+     */
+    public InitParameterExtractor(PortletContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        return context.getInitParameterNames();
+    }
+
+    @Override
+    public String getValue(String key) {
+        return context.getInitParameter(key);
+    }
+
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/ParameterExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/ParameterExtractor.java
new file mode 100644
index 000000000..e412a84c6
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/ParameterExtractor.java
@@ -0,0 +1,56 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.HasKeys;
+
+import javax.portlet.PortletRequest;
+import java.util.Enumeration;
+
+/**
+ * Extracts parameters from a portlet request.
+ */
+public class ParameterExtractor implements HasKeys<String> {
+
+    /**
+     * The portlet request.
+     */
+    private final PortletRequest request;
+
+    /**
+     * Constructor.
+     *
+     * @param request The portlet request.
+     */
+    public ParameterExtractor(PortletRequest request) {
+        this.request = request;
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        return request.getParameterNames();
+    }
+
+    @Override
+    public String getValue(String key) {
+        return request.getParameter(key);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/RequestScopeExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/RequestScopeExtractor.java
new file mode 100644
index 000000000..edc72bc9e
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/RequestScopeExtractor.java
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.AttributeExtractor;
+
+import javax.portlet.PortletRequest;
+import java.util.Enumeration;
+
+/**
+ * Extracts attributes from request scope of a portlet request.
+ */
+public class RequestScopeExtractor implements AttributeExtractor {
+
+    /**
+     * The portlet request.
+     */
+    private final PortletRequest request;
+
+    /**
+     * Constructor.
+     *
+     * @param request The portlet request.
+     */
+    public RequestScopeExtractor(PortletRequest request) {
+        this.request = request;
+    }
+
+    @Override
+    public void setValue(String name, Object value) {
+        request.setAttribute(name, value);
+    }
+
+    @Override
+    public void removeValue(String name) {
+        request.removeAttribute(name);
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        return request.getAttributeNames();
+    }
+
+    @Override
+    public Object getValue(String key) {
+        return request.getAttribute(key);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/SessionScopeExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/SessionScopeExtractor.java
new file mode 100644
index 000000000..9801454fa
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/SessionScopeExtractor.java
@@ -0,0 +1,88 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.AttributeExtractor;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import java.util.Enumeration;
+
+/**
+ * Extracts attributes from the session scope of a portlet request.
+ */
+public class SessionScopeExtractor implements AttributeExtractor {
+
+    /**
+     * The portlet request.
+     */
+    private final PortletRequest request;
+
+    /**
+     * The subscope (application or portlet).
+     */
+    private final int scope;
+
+    /**
+     * Constructor.
+     *
+     * @param request The request.
+     * @param scope The subscope (application or portlet).
+     */
+    public SessionScopeExtractor(PortletRequest request, int scope) {
+        this.request = request;
+        if (scope != PortletSession.APPLICATION_SCOPE && scope != 
PortletSession.PORTLET_SCOPE) {
+            throw new IllegalArgumentException("The scope must be either 
APPLICATION_SCOPE or PORTLET_SCOPE");
+        }
+        this.scope = scope;
+    }
+
+    @Override
+    public void setValue(String name, Object value) {
+        request.getPortletSession().setAttribute(name, value, scope);
+    }
+
+    @Override
+    public void removeValue(String name) {
+        PortletSession session = request.getPortletSession(false);
+        if (session != null) {
+            session.removeAttribute(name, scope);
+        }
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        PortletSession session = request.getPortletSession(false);
+        if (session != null) {
+            return session.getAttributeNames(scope);
+        }
+        return null;
+    }
+
+    @Override
+    public Object getValue(String key) {
+        PortletSession session = request.getPortletSession(false);
+        if (session != null) {
+            return session.getAttribute(key, scope);
+        }
+        return null;
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/StateAwareParameterExtractor.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/StateAwareParameterExtractor.java
new file mode 100644
index 000000000..3b18b7343
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/StateAwareParameterExtractor.java
@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.portlet.extractor;
+
+import org.apache.tiles.request.attribute.HasAddableKeys;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.StateAwareResponse;
+
+/**
+ * Extracts parameters from a request and allows putting render parameters in 
a state aware response.
+ */
+public class StateAwareParameterExtractor extends ParameterExtractor 
implements HasAddableKeys<String> {
+
+    /**
+     * The portlet response.
+     */
+    private StateAwareResponse response;
+
+    /**
+     * Constructor.
+     *
+     * @param request The portlet request.
+     * @param response The portlet response.
+     */
+    public StateAwareParameterExtractor(PortletRequest request, 
StateAwareResponse response) {
+        super(request);
+        this.response = response;
+    }
+
+    @Override
+    public void setValue(String key, String value) {
+        response.setRenderParameter(key, value);
+    }
+}
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/package-info.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/package-info.java
new file mode 100644
index 000000000..a37ccbb9e
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/extractor/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * $Id: package-info.java 1049711 2010-12-15 21:12:00Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+/**
+ * Extractors to get scopes from Portlet requests.
+ */
+package org.apache.tiles.request.portlet.extractor;
diff --git 
a/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/package-info.java
 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/package-info.java
new file mode 100644
index 000000000..b9eb0d168
--- /dev/null
+++ 
b/plugins/portlet-tiles/src/main/java/org/apache/tiles/request/portlet/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * $Id: package-info.java 1049711 2010-12-15 21:12:00Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+/**
+ * Support of Tiles requests to portlets.
+ */
+package org.apache.tiles.request.portlet;
diff --git 
a/plugins/tiles/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java
 
b/plugins/tiles/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java
new file mode 100644
index 000000000..d88b90503
--- /dev/null
+++ 
b/plugins/tiles/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tiles.request.collection;
+
+import org.apache.tiles.request.attribute.HasAddableKeys;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Exposes an {@link HasAddableKeys} object as a put/get (no remove) map.
+ */
+public class AddableParameterMap extends ReadOnlyEnumerationMap<String> {
+
+    /**
+     * The request.
+     */
+    private final HasAddableKeys<String> request;
+
+    /**
+     * Constructor.
+     *
+     * @param request The request object to use.
+     */
+    public AddableParameterMap(HasAddableKeys<String> request) {
+        super(request);
+        this.request = request;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<Entry<String, String>> entrySet() {
+        return new AddableParameterEntrySet();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String put(String key, String value) {
+        String oldValue = request.getValue(key);
+        request.setValue(key, value);
+        return oldValue;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void putAll(Map<? extends String, ? extends String> map) {
+        for (Entry<? extends String, ? extends String> entry : map
+            .entrySet()) {
+            request.setValue(entry.getKey(), entry.getValue());
+        }
+    }
+
+
+    /**
+     * Entry set implementation for {@link AddableParameterMap}.
+     */
+    private class AddableParameterEntrySet extends 
ReadOnlyEnumerationMap<String>.ReadOnlyEnumerationMapEntrySet {
+
+        @Override
+        public boolean add(Entry<String, String> e) {
+            request.setValue(e.getKey(), e.getValue());
+            return true;
+        }
+
+        @Override
+        public boolean addAll(
+            Collection<? extends Entry<String, String>> c) {
+            for (Entry<String, String> entry : c) {
+                request.setValue(entry.getKey(), entry.getValue());
+            }
+            return true;
+        }
+    }
+}

Reply via email to