The lazily instantiated Map of portlet session scope
+ * attributes.
+ */
+ private Map 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;
+ }
+
+ /**
+ *
Return the {@link PortletRequest} for this context.
+ *
+ * @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 getHeader() {
+ if ((header == null) && (request != null)) {
+ header = new ReadOnlyEnumerationMap<>(new HeaderExtractor(request, null));
+ }
+ return (header);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Addable getResponseHeaders() {
+ if ((responseHeaders == null) && (request != null)) {
+ responseHeaders = new HeaderExtractor(null, response);
+ }
+ return (responseHeaders);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map getHeaderValues() {
+ if ((headerValues == null) && (request != null)) {
+ headerValues = new HeaderValuesMap(new HeaderExtractor(request, response));
+ }
+ return (headerValues);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map getRequestScope() {
+ if ((requestScope == null) && (request != null)) {
+ requestScope = new ScopeMap(new RequestScopeExtractor(request));
+ }
+ return (requestScope);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map getSessionScope() {
+ if ((sessionScope == null) && (request != null)) {
+ sessionScope = new ScopeMap(new SessionScopeExtractor(request,
+ PortletSession.APPLICATION_SCOPE));
+ }
+ return (sessionScope);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map getPortletSessionScope() {
+ if ((portletSessionScope == null) && (request != null)) {
+ portletSessionScope = new ScopeMap(new SessionScopeExtractor(
+ request, PortletSession.APPLICATION_SCOPE));
+ }
+ return (portletSessionScope);
+ }
+
+ @Override
+ public List getAvailableScopes() {
+ return SCOPES;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Locale getRequestLocale() {
+ return request.getLocale();
+ }
+
+ @Override
+ public Map getParam() {
+ return requestDelegate.getParam();
+ }
+
+ @Override
+ public Map 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 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 0000000000..ea22c38a2d
--- /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 0000000000..347873cf13
--- /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 0000000000..e5683d5a01
--- /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;
+
+ /**
+ *
The lazily instantiated Map of request
+ * parameter name-value.
+ */
+ private Map param = null;
+
+ /**
+ *
The lazily instantiated Map of request
+ * parameter name-values.
+ */
+ private Map paramValues = null;
+
+ /**
+ * Constructor.
+ *
+ * @param request The request.
+ */
+ public PortletRequestDelegate(PortletRequest request) {
+ this.request = request;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map getParam() {
+ if ((param == null) && (request != null)) {
+ param = new ReadOnlyEnumerationMap<>(new ParameterExtractor(request));
+ }
+ return (param);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map 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 0000000000..03846cc72d
--- /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 getParam();
+
+ /**
+ * The parameters, with values as array of strings.
+ *
+ * @return The parameters.
+ */
+ Map 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 0000000000..92f46cef63
--- /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 true if the response is committed.
+ */
+ boolean isResponseCommitted();
+}
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 0000000000..5080dc3e0e
--- /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 0000000000..590046cff1
--- /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 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 0000000000..0c94fa90f0
--- /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 getKeys() {
+ return request.getPropertyNames();
+ }
+
+ @Override
+ public String getValue(String key) {
+ return request.getProperty(key);
+ }
+
+ @Override
+ public Enumeration 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 0000000000..f27fdf4f11
--- /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 {
+
+ /**
+ * The portlet context.
+ */
+ private final PortletContext context;
+
+ /**
+ * Constructor.
+ *
+ * @param context The portlet context.
+ */
+ public InitParameterExtractor(PortletContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public Enumeration 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 0000000000..e412a84c69
--- /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 {
+
+ /**
+ * The portlet request.
+ */
+ private final PortletRequest request;
+
+ /**
+ * Constructor.
+ *
+ * @param request The portlet request.
+ */
+ public ParameterExtractor(PortletRequest request) {
+ this.request = request;
+ }
+
+ @Override
+ public Enumeration 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 0000000000..edc72bc9e3
--- /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 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 0000000000..9801454fa3
--- /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 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 0000000000..a14f53a7bc
--- /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 {
+
+ /**
+ * The portlet response.
+ */
+ private final 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 0000000000..a37ccbb9ef
--- /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 0000000000..b9eb0d1687
--- /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/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java
new file mode 100644
index 0000000000..53a6bf8560
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java
@@ -0,0 +1,424 @@
+/*
+ * 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.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.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletResponse;
+import javax.servlet.ServletOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link PortletRequest}.
+ */
+public class PortletRequestTest {
+
+ /**
+ * The application context.
+ */
+ private ApplicationContext applicationContext;
+
+ /**
+ * The portlet context.
+ */
+ private PortletContext portletContext;
+
+ /**
+ * The request.
+ */
+ private javax.portlet.PortletRequest request;
+
+ /**
+ * The response.
+ */
+ private PortletResponse response;
+
+ /**
+ * The request to test.
+ */
+ private PortletRequest req;
+
+ /**
+ * The request delegate.
+ */
+ private RequestDelegate requestDelegate;
+
+ /**
+ * The response delegate.
+ */
+ private ResponseDelegate responseDelegate;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ applicationContext = createMock(ApplicationContext.class);
+ portletContext = createMock(PortletContext.class);
+ request = createMock(javax.portlet.PortletRequest.class);
+ response = createMock(PortletResponse.class);
+ requestDelegate = createMock(RequestDelegate.class);
+ responseDelegate = createMock(ResponseDelegate.class);
+ req = new PortletRequest(applicationContext, portletContext, request,
+ response, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doForward(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ * @throws PortletException If something goes wrong.
+ */
+ @Test
+ public void testDoForward() throws PortletException, IOException {
+ PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class);
+
+ expect(responseDelegate.isResponseCommitted()).andReturn(false);
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd);
+ rd.forward(request, response);
+
+ replay(applicationContext, portletContext, request, response, rd);
+ req.doForward("/my/path");
+ verify(applicationContext, portletContext, request, response, rd);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doForward(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test(expected = IOException.class)
+ public void testDoForwardNoDispatcher() throws IOException {
+ expect(responseDelegate.isResponseCommitted()).andReturn(false);
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(null);
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ try {
+ req.doForward("/my/path");
+ } finally {
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doForward(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ * @throws PortletException If something goes wrong.
+ */
+ @Test(expected = IOException.class)
+ public void testDoForwardPortletException() throws PortletException, IOException {
+ PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class);
+
+ expect(responseDelegate.isResponseCommitted()).andReturn(false);
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd);
+ rd.forward(request, response);
+ expectLastCall().andThrow(new PortletException());
+
+ replay(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ try {
+ req.doForward("/my/path");
+ } finally {
+ verify(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ }
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doForward(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ * @throws PortletException If something goes wrong.
+ */
+ @Test
+ public void testDoForwardInclude() throws PortletException, IOException {
+ PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class);
+
+ expect(responseDelegate.isResponseCommitted()).andReturn(true);
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd);
+ rd.include(request, response);
+
+ replay(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ req.doForward("/my/path");
+ verify(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doInclude(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ * @throws PortletException If something goes wrong.
+ */
+ @Test
+ public void testDoInclude() throws IOException, PortletException {
+ PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class);
+
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd);
+ rd.include(request, response);
+
+ replay(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ req.doInclude("/my/path");
+ verify(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doInclude(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test(expected = IOException.class)
+ public void testDoIncludeNoDispatcher() throws IOException {
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(null);
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ try {
+ req.doInclude("/my/path");
+ } finally {
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+ }
+
+ /**
+ * Test method for {@link PortletRequest#doInclude(String)}.
+ *
+ * @throws IOException If something goes wrong.
+ * @throws PortletException If something goes wrong.
+ */
+ @Test(expected = IOException.class)
+ public void testDoIncludePortletException() throws IOException, PortletException {
+ PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class);
+
+ expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd);
+ rd.include(request, response);
+ expectLastCall().andThrow(new PortletException());
+
+ replay(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ try {
+ req.doInclude("/my/path");
+ } finally {
+ verify(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate);
+ }
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getHeader()}.
+ */
+ @Test
+ public void testGetHeader() {
+ assertTrue(req.getHeader() instanceof ReadOnlyEnumerationMap);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getResponseHeaders()}.
+ */
+ @Test
+ public void testGetResponseHeaders() {
+ assertTrue(req.getResponseHeaders() instanceof HeaderExtractor);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getHeaderValues()}.
+ */
+ @Test
+ public void testGetHeaderValues() {
+ assertTrue(req.getHeaderValues() instanceof HeaderValuesMap);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getParam()}.
+ */
+ @Test
+ public void testGetParam() {
+ Map map = createMock(Map.class);
+
+ expect(requestDelegate.getParam()).andReturn(map);
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ assertEquals(map, req.getParam());
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getParamValues()}.
+ */
+ @Test
+ public void testGetParamValues() {
+ Map paramMap = createMock(Map.class);
+
+ expect(requestDelegate.getParamValues()).andReturn(paramMap);
+
+ replay(applicationContext, request, response, paramMap, portletContext, requestDelegate, responseDelegate);
+ assertEquals(paramMap, req.getParamValues());
+ verify(applicationContext, request, response, paramMap, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getRequestScope()}.
+ */
+ @Test
+ public void testGetRequestScope() {
+ assertTrue(req.getRequestScope() instanceof ScopeMap);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getSessionScope()}.
+ */
+ @Test
+ public void testGetSessionScope() {
+ assertTrue(req.getSessionScope() instanceof ScopeMap);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getPortletSessionScope()}.
+ */
+ @Test
+ public void testGetPortletSessionScope() {
+ assertTrue(req.getPortletSessionScope() instanceof ScopeMap);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getOutputStream()}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetOutputStream() throws IOException {
+ ServletOutputStream os = createMock(ServletOutputStream.class);
+
+ expect(responseDelegate.getOutputStream()).andReturn(os);
+
+ replay(applicationContext, request, response, os, portletContext, requestDelegate, responseDelegate);
+ assertEquals(req.getOutputStream(), os);
+ verify(applicationContext, request, response, os, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getWriter()}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetWriter() throws IOException {
+ PrintWriter os = createMock(PrintWriter.class);
+
+ expect(responseDelegate.getWriter()).andReturn(os);
+
+ replay(applicationContext, request, response, os, portletContext, requestDelegate, responseDelegate);
+ assertEquals(req.getWriter(), os);
+ verify(applicationContext, request, response, os, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getPrintWriter()}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetPrintWriter() throws IOException {
+ PrintWriter os = createMock(PrintWriter.class);
+
+ expect(responseDelegate.getPrintWriter()).andReturn(os);
+
+ replay(applicationContext, request, response, os, portletContext, requestDelegate, responseDelegate);
+ assertEquals(req.getPrintWriter(), os);
+ verify(applicationContext, request, response, os, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#isResponseCommitted()}.
+ */
+ @Test
+ public void testIsResponseCommitted() {
+ expect(responseDelegate.isResponseCommitted()).andReturn(true);
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ assertTrue(req.isResponseCommitted());
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#setContentType(String)}.
+ */
+ @Test
+ public void testSetContentType() {
+ responseDelegate.setContentType("text/html");
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ req.setContentType("text/html");
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getRequestLocale()}.
+ */
+ @Test
+ public void testGetRequestLocale() {
+ Locale locale = Locale.ITALY;
+
+ expect(request.getLocale()).andReturn(locale);
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ assertEquals(locale, req.getRequestLocale());
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#getRequest()}.
+ */
+ @Test
+ public void testGetRequest() {
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ assertEquals(request, req.getRequest());
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+
+ /**
+ * Test method for {@link PortletRequest#isUserInRole(String)}.
+ */
+ @Test
+ public void testIsUserInRole() {
+ expect(request.isUserInRole("myrole")).andReturn(true);
+
+ replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ assertTrue(req.isUserInRole("myrole"));
+ verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/RenderPortletRequestTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/RenderPortletRequestTest.java
new file mode 100644
index 0000000000..5bba700fb9
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/RenderPortletRequestTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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 org.junit.Test;
+
+import javax.portlet.PortletContext;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.lang.reflect.Field;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link RenderPortletRequest}.
+ */
+public class RenderPortletRequestTest {
+
+ /**
+ * Test method for
+ * {@link RenderPortletRequest#RenderPortletRequest(ApplicationContext, PortletContext,
+ * RenderRequest, RenderResponse)}.
+ *
+ * @throws NoSuchFieldException If something goes wrong.
+ * @throws SecurityException If something goes wrong.
+ * @throws IllegalAccessException If something goes wrong.
+ * @throws IllegalArgumentException If something goes wrong.
+ */
+ @Test
+ public void testRenderPortletRequest() throws NoSuchFieldException, IllegalAccessException {
+ ApplicationContext applicationContext = createMock(ApplicationContext.class);
+ PortletContext portletContext = createMock(PortletContext.class);
+ RenderRequest request = createMock(RenderRequest.class);
+ RenderResponse response = createMock(RenderResponse.class);
+
+ replay(applicationContext, portletContext, request, response);
+ RenderPortletRequest req = new RenderPortletRequest(applicationContext,
+ portletContext, request, response);
+ Class extends RenderPortletRequest> clazz = req.getClass();
+ Field field = clazz.getSuperclass().getDeclaredField("requestDelegate");
+ assertTrue(field.get(req) instanceof PortletRequestDelegate);
+ field = clazz.getSuperclass().getDeclaredField("responseDelegate");
+ assertTrue(field.get(req) instanceof MimeResponseDelegate);
+ verify(applicationContext, portletContext, request, response);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/delegate/MimeResponseDelegateTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/delegate/MimeResponseDelegateTest.java
new file mode 100644
index 0000000000..25d6534566
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/delegate/MimeResponseDelegateTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.MimeResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link MimeResponseDelegate}.
+ */
+public class MimeResponseDelegateTest {
+
+ /**
+ * The response.
+ */
+ private MimeResponse response;
+
+ /**
+ * The delegate to test.
+ */
+ private MimeResponseDelegate delegate;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ response = createMock(MimeResponse.class);
+ delegate = new MimeResponseDelegate(response);
+ }
+
+ /**
+ * Test method for {@link MimeResponseDelegate#getOutputStream()}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetOutputStream() throws IOException {
+ OutputStream os = createMock(OutputStream.class);
+
+ expect(response.getPortletOutputStream()).andReturn(os);
+
+ replay(response, os);
+ assertEquals(os, delegate.getOutputStream());
+ verify(response, os);
+ }
+
+ /**
+ * Test method for {@link MimeResponseDelegate#getPrintWriter()}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetPrintWriter() throws IOException {
+ PrintWriter os = createMock(PrintWriter.class);
+
+ expect(response.getWriter()).andReturn(os);
+
+ replay(response, os);
+ assertEquals(os, delegate.getPrintWriter());
+ verify(response, os);
+ }
+
+ /**
+ * Test method for {@link MimeResponseDelegate#getWriter()}.
+ *
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetWriter() throws IOException {
+ PrintWriter os = createMock(PrintWriter.class);
+
+ expect(response.getWriter()).andReturn(os);
+
+ replay(response, os);
+ assertEquals(os, delegate.getWriter());
+ verify(response, os);
+ }
+
+ /**
+ * Test method for {@link MimeResponseDelegate#isResponseCommitted()}.
+ */
+ @Test
+ public void testIsResponseCommitted() {
+ expect(response.isCommitted()).andReturn(true);
+
+ replay(response);
+ assertTrue(delegate.isResponseCommitted());
+ verify(response);
+ }
+
+ /**
+ * Test method for {@link MimeResponseDelegate#setContentType(String)}.
+ */
+ @Test
+ public void testSetContentType() {
+ response.setContentType("text/html");
+
+ replay(response);
+ delegate.setContentType("text/html");
+ verify(response);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/delegate/PortletRequestDelegateTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/delegate/PortletRequestDelegateTest.java
new file mode 100644
index 0000000000..ce6d4e8494
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/delegate/PortletRequestDelegateTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletRequest;
+import java.util.Map;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link PortletRequestDelegate}.
+ */
+public class PortletRequestDelegateTest {
+
+ /**
+ * The request.
+ */
+ private PortletRequest request;
+
+ /**
+ * The delegate to test.
+ */
+ private PortletRequestDelegate delegate;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ request = createMock(PortletRequest.class);
+ delegate = new PortletRequestDelegate(request);
+ }
+
+ /**
+ * Test method for {@link PortletRequestDelegate#getParam()}.
+ */
+ @Test
+ public void testGetParam() {
+ replay(request);
+ assertTrue(delegate.getParam() instanceof ReadOnlyEnumerationMap);
+ verify(request);
+ }
+
+ /**
+ * Test method for {@link PortletRequestDelegate#getParamValues()}.
+ */
+ @Test
+ public void testGetParamValues() {
+ Map params = createMock(Map.class);
+
+ expect(request.getParameterMap()).andReturn(params);
+
+ replay(request, params);
+ assertEquals(params, delegate.getParamValues());
+ verify(request, params);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/ApplicationScopeExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/ApplicationScopeExtractorTest.java
new file mode 100644
index 0000000000..5ede84f691
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/ApplicationScopeExtractorTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.portlet.extractor.ApplicationScopeExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletContext;
+import java.util.Enumeration;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link ApplicationScopeExtractor}.
+ */
+public class ApplicationScopeExtractorTest {
+
+ /**
+ * The portlet context.
+ */
+ private PortletContext context;
+
+ /**
+ * The extractot to test.
+ */
+ private ApplicationScopeExtractor extractor;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ context = createMock(PortletContext.class);
+ extractor = new ApplicationScopeExtractor(context);
+ }
+
+ /**
+ * Test method for {@link ApplicationScopeExtractor#setValue(String, Object)}.
+ */
+ @Test
+ public void testSetValue() {
+ context.setAttribute("attribute", "value");
+
+ replay(context);
+ extractor.setValue("attribute", "value");
+ verify(context);
+ }
+
+ /**
+ * Test method for {@link ApplicationScopeExtractor#removeValue(String)}.
+ */
+ @Test
+ public void testRemoveValue() {
+ context.removeAttribute("attribute");
+
+ replay(context);
+ extractor.removeValue("attribute");
+ verify(context);
+ }
+
+ /**
+ * Test method for {@link ApplicationScopeExtractor#getKeys()}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetKeys() {
+ Enumeration keys = createMock(Enumeration.class);
+ expect(context.getAttributeNames()).andReturn(keys);
+
+ replay(context, keys);
+ assertEquals(keys, extractor.getKeys());
+ verify(context, keys);
+ }
+
+ /**
+ * Test method for {@link ApplicationScopeExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValue() {
+ expect(context.getAttribute("attribute")).andReturn("value");
+
+ replay(context);
+ assertEquals("value", extractor.getValue("attribute"));
+ verify(context);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/HeaderExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/HeaderExtractorTest.java
new file mode 100644
index 0000000000..7f5054c024
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/HeaderExtractorTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.portlet.extractor.HeaderExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import java.util.Enumeration;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link HeaderExtractor}.
+ */
+public class HeaderExtractorTest {
+
+ /**
+ * The request.
+ */
+ private PortletRequest request;
+
+ /**
+ * The response.
+ */
+ private PortletResponse response;
+
+ /**
+ * The extractor to test.
+ */
+ private HeaderExtractor extractor;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ request = createMock(PortletRequest.class);
+ response = createMock(PortletResponse.class);
+ extractor = new HeaderExtractor(request, response);
+ }
+
+ /**
+ * Test method for {@link HeaderExtractor#getKeys()}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetKeys() {
+ Enumeration keys = createMock(Enumeration.class);
+
+ expect(request.getPropertyNames()).andReturn(keys);
+
+ replay(request, response, keys);
+ assertEquals(keys, extractor.getKeys());
+ verify(request, response, keys);
+ }
+
+ /**
+ * Test method for {@link HeaderExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValue() {
+ expect(request.getProperty("name")).andReturn("value");
+
+ replay(request, response);
+ assertEquals("value", extractor.getValue("name"));
+ verify(request, response);
+ }
+
+ /**
+ * Test method for {@link HeaderExtractor#getValues(String)}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetValues() {
+ Enumeration keys = createMock(Enumeration.class);
+
+ expect(request.getProperties("name")).andReturn(keys);
+
+ replay(request, response, keys);
+ assertEquals(keys, extractor.getValues("name"));
+ verify(request, response, keys);
+ }
+
+ /**
+ * Test method for {@link HeaderExtractor#setValue(String, String)}.
+ */
+ @Test
+ public void testSetValue() {
+ response.setProperty("name", "value");
+
+ replay(request, response);
+ extractor.setValue("name", "value");
+ verify(request, response);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/InitParameterExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/InitParameterExtractorTest.java
new file mode 100644
index 0000000000..66a1f9ea79
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/InitParameterExtractorTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.portlet.extractor.InitParameterExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletContext;
+import java.util.Enumeration;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link InitParameterExtractor}.
+ */
+public class InitParameterExtractorTest {
+
+ /**
+ * The portlet context.
+ */
+ private PortletContext context;
+
+ /**
+ * The extractor to test.
+ */
+ private InitParameterExtractor extractor;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ context = createMock(PortletContext.class);
+ extractor = new InitParameterExtractor(context);
+ }
+
+ /**
+ * Test method for {@link InitParameterExtractor#getKeys()}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetKeys() {
+ Enumeration keys = createMock(Enumeration.class);
+
+ expect(context.getInitParameterNames()).andReturn(keys);
+
+ replay(context, keys);
+ assertEquals(keys, extractor.getKeys());
+ verify(context, keys);
+ }
+
+ /**
+ * Test method for {@link InitParameterExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValue() {
+ expect(context.getInitParameter("name")).andReturn("value");
+
+ replay(context);
+ assertEquals("value", extractor.getValue("name"));
+ verify(context);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/ParameterExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/ParameterExtractorTest.java
new file mode 100644
index 0000000000..0e80053250
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/ParameterExtractorTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.portlet.extractor.ParameterExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletRequest;
+import java.util.Enumeration;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link ParameterExtractor}.
+ */
+public class ParameterExtractorTest {
+
+ /**
+ * The request.
+ */
+ private PortletRequest request;
+
+ /**
+ * The extractor to test.
+ */
+ private ParameterExtractor extractor;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ request = createMock(PortletRequest.class);
+ extractor = new ParameterExtractor(request);
+ }
+
+ /**
+ * Test method for {@link ParameterExtractor#getKeys()}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetKeys() {
+ Enumeration keys = createMock(Enumeration.class);
+
+ expect(request.getParameterNames()).andReturn(keys);
+
+ replay(request, keys);
+ assertEquals(keys, extractor.getKeys());
+ verify(request, keys);
+ }
+
+ /**
+ * Test method for {@link ParameterExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValue() {
+ expect(request.getParameter("name")).andReturn("value");
+
+ replay(request);
+ assertEquals("value", extractor.getValue("name"));
+ verify(request);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/RequestScopeExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/RequestScopeExtractorTest.java
new file mode 100644
index 0000000000..df76a515e8
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/RequestScopeExtractorTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.portlet.extractor.RequestScopeExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletRequest;
+import java.util.Enumeration;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link RequestScopeExtractor}.
+ */
+public class RequestScopeExtractorTest {
+
+ /**
+ * The request to test.
+ */
+ private PortletRequest request;
+
+ /**
+ * The extractor to test.
+ */
+ private RequestScopeExtractor extractor;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ request = createMock(PortletRequest.class);
+ extractor = new RequestScopeExtractor(request);
+ }
+
+ /**
+ * Test method for {@link RequestScopeExtractor#setValue(String, Object)}.
+ */
+ @Test
+ public void testSetValue() {
+ request.setAttribute("name", "value");
+
+ replay(request);
+ extractor.setValue("name", "value");
+ verify(request);
+ }
+
+ /**
+ * Test method for {@link RequestScopeExtractor#removeValue(String)}.
+ */
+ @Test
+ public void testRemoveValue() {
+ request.removeAttribute("name");
+
+ replay(request);
+ extractor.removeValue("name");
+ verify(request);
+ }
+
+ /**
+ * Test method for {@link RequestScopeExtractor#getKeys()}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetKeys() {
+ Enumeration keys = createMock(Enumeration.class);
+
+ expect(request.getAttributeNames()).andReturn(keys);
+
+ replay(request, keys);
+ assertEquals(keys, extractor.getKeys());
+ verify(request, keys);
+ }
+
+ /**
+ * Test method for {@link RequestScopeExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValue() {
+ expect(request.getAttribute("name")).andReturn("value");
+
+ replay(request);
+ assertEquals("value", extractor.getValue("name"));
+ verify(request);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/SessionScopeExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/SessionScopeExtractorTest.java
new file mode 100644
index 0000000000..09010ff0c7
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/SessionScopeExtractorTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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.portlet.extractor.SessionScopeExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import java.util.Enumeration;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Tests {@link SessionScopeExtractor}.
+ */
+public class SessionScopeExtractorTest {
+
+ /**
+ * The request.
+ */
+ private PortletRequest request;
+
+ /**
+ * The session.
+ */
+ private PortletSession session;
+
+ /**
+ * The scope to test.
+ */
+ private SessionScopeExtractor extractor;
+
+ /**
+ * Sets up the test.
+ */
+ @Before
+ public void setUp() {
+ request = createMock(PortletRequest.class);
+ session = createMock(PortletSession.class);
+ extractor = new SessionScopeExtractor(request, PortletSession.PORTLET_SCOPE);
+ }
+
+
+ /**
+ * Tests {@link SessionScopeExtractor#SessionScopeExtractor(PortletRequest, int)}.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalScope() {
+ replay(request, session);
+ new SessionScopeExtractor(request, 0);
+ verify(request, session);
+ }
+
+ /**
+ * Test method for {@link SessionScopeExtractor#setValue(String, Object)}.
+ */
+ @Test
+ public void testSetValue() {
+ expect(request.getPortletSession()).andReturn(session);
+ session.setAttribute("name", "value", PortletSession.PORTLET_SCOPE);
+
+ replay(request, session);
+ extractor.setValue("name", "value");
+ verify(request, session);
+ }
+
+ /**
+ * Test method for {@link SessionScopeExtractor#removeValue(String)}.
+ */
+ @Test
+ public void testRemoveValue() {
+ expect(request.getPortletSession(false)).andReturn(session);
+ session.removeAttribute("name", PortletSession.PORTLET_SCOPE);
+
+ replay(request, session);
+ extractor.removeValue("name");
+ verify(request, session);
+ }
+
+ /**
+ * Test method for {@link SessionScopeExtractor#getKeys()}.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetKeys() {
+ Enumeration keys = createMock(Enumeration.class);
+
+ expect(request.getPortletSession(false)).andReturn(session);
+ expect(session.getAttributeNames(PortletSession.PORTLET_SCOPE)).andReturn(keys);
+
+ replay(request, session, keys);
+ assertEquals(keys, extractor.getKeys());
+ verify(request, session, keys);
+ }
+
+ /**
+ * Test method for {@link SessionScopeExtractor#getKeys()}.
+ */
+ @Test
+ public void testGetKeysNoSession() {
+ expect(request.getPortletSession(false)).andReturn(null);
+
+ replay(request, session);
+ assertNull(extractor.getKeys());
+ verify(request, session);
+ }
+
+ /**
+ * Test method for {@link SessionScopeExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValue() {
+ expect(request.getPortletSession(false)).andReturn(session);
+ expect(session.getAttribute("name", PortletSession.PORTLET_SCOPE)).andReturn("value");
+
+ replay(request, session);
+ assertEquals("value", extractor.getValue("name"));
+ verify(request, session);
+ }
+
+ /**
+ * Test method for {@link SessionScopeExtractor#getValue(String)}.
+ */
+ @Test
+ public void testGetValueNoSession() {
+ expect(request.getPortletSession(false)).andReturn(null);
+
+ replay(request, session);
+ assertNull(extractor.getValue("name"));
+ verify(request, session);
+ }
+
+}
diff --git a/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/StateAwareParameterExtractorTest.java b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/StateAwareParameterExtractorTest.java
new file mode 100644
index 0000000000..5157b6fe66
--- /dev/null
+++ b/plugins/portlet-tiles/src/test/java/org/apache/tiles/request/portlet/extractor/StateAwareParameterExtractorTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.portlet.extractor.StateAwareParameterExtractor;
+import org.junit.Test;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.StateAwareResponse;
+
+import static org.easymock.EasyMock.*;
+
+/**
+ * Tests {@link StateAwareParameterExtractor}.
+ */
+public class StateAwareParameterExtractorTest {
+
+ /**
+ * Test method for {@link StateAwareParameterExtractor#setValue(String, String)}.
+ */
+ @Test
+ public void testSetValue() {
+ PortletRequest request = createMock(PortletRequest.class);
+ StateAwareResponse response = createMock(StateAwareResponse.class);
+
+ response.setRenderParameter("name", "value");
+
+ replay(request, response);
+ StateAwareParameterExtractor extractor = new StateAwareParameterExtractor(request, response);
+ extractor.setValue("name", "value");
+ verify(request, response);
+ }
+
+}
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 0c0488dc01..9716e71980 100644
--- a/plugins/tiles/pom.xml
+++ b/plugins/tiles/pom.xml
@@ -31,59 +31,87 @@
jarStruts 2 Tiles Plugin
+
+
+
+ build-autotags
+
+ true
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.1.0
+
+
+ compile
+
+ java
+
+
+
+
+ org.apache.struts2.tiles.BuildAutotags
+
+
+ ${project.build.directory}
+
+
+
+
+
+
+
+
- org.apache.tiles
- tiles-api
-
-
- org.apache.tiles
- tiles-core
-
-
- org.apache.tiles
- tiles-servlet
-
-
- org.apache.tiles
- tiles-request-api
+ commons-digester
+ commons-digester
- org.apache.tiles
- tiles-request-jsp
+ org.glassfish
+ javax.el
+ true
- org.apache.tiles
- tiles-request-servlet
+ javax.servlet.jsp
+ jsp-api
+ provided
- org.apache.tiles
- tiles-jsp
+ org.apache.velocity
+ velocity-engine-core
+ true
- org.apache.tiles
- tiles-freemarker
+ org.apache.velocity.tools
+ velocity-tools-view
+ true
- org.apache.tiles
- tiles-ognl
+ org.apache.velocity.tools
+ velocity-tools-view-jsp
+ true
- org.apache.tiles
- tiles-el
+ com.thoughtworks.xstream
+ xstream
+ true
- org.glassfish
- javax.el
- true
+ org.easymock
+ easymock
+ test
- javax.servlet.jsp
- jsp-api
- provided
+ org.apache.logging.log4j
+ log4j-jcl
+ test
- UTF-8
+ UTF-8
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/BuildAutotags.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/BuildAutotags.java
new file mode 100644
index 0000000000..4e90bb7ba3
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/BuildAutotags.java
@@ -0,0 +1,229 @@
+/*
+ * 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.struts2.tiles;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.tiles.autotag.freemarker.FMTemplateGeneratorFactory;
+import org.apache.tiles.autotag.generate.TemplateGenerator;
+import org.apache.tiles.autotag.generate.TemplateGeneratorBuilder;
+import org.apache.tiles.autotag.jsp.JspTemplateGeneratorFactory;
+import org.apache.tiles.autotag.model.TemplateSuite;
+import org.apache.tiles.autotag.velocity.VelocityTemplateGeneratorFactory;
+import org.apache.velocity.app.VelocityEngine;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+
+/**
+ * Helper class for building/generating the classes and resources used in the
+ * plugin.
+ */
+public class BuildAutotags {
+
+ public BuildAutotags() {
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+
+ BuildAutotags me = new BuildAutotags();
+
+ // Jsp classes
+ me.buildJsp(args[0]);
+
+ // Freemarker classes
+ me.buildFreemarker(args[0]);
+
+ // Velocity classes
+ me.buildVelocity(args[0]);
+
+ }
+
+ /**
+ * Build JSP tag classes and .tld file.
+ *
+ * To build, change template-suite.xml as required and then run this program.
+ * Copy the classes and .tld from the target autotag folder into the packageName
+ * location, .tld to src/main/resources/META-INF/tld/tiles-jsp.tld
+ *
+ * @param outputDir the output dir
+ */
+ public void buildJsp(String outputDir) {
+
+ // Default values
+ String taglibURI = "http://tiles.apache.org/tags-tiles";
+ String packageName = "org.apache.tiles.web.jsp.taglib";
+ String requestClass = "org.apache.tiles.request.Request";
+ String runtime = "org.apache.tiles.request.jsp.autotag.JspAutotagRuntime";
+ // outputDir = "/target"
+
+ Map parameters = new HashMap();
+ parameters.put("taglibURI", taglibURI);
+
+ try {
+
+ TemplateSuite suite;
+
+ InputStream stream = getClass().getResourceAsStream("/META-INF/template-suite.xml");
+
+ try {
+ XStream xstream = new XStream(new DomDriver());
+ xstream.allowTypes(new Class[] { org.apache.tiles.autotag.model.TemplateClass.class,
+ org.apache.tiles.autotag.model.TemplateSuite.class,
+ org.apache.tiles.autotag.model.TemplateParameter.class });
+ suite = (TemplateSuite) xstream.fromXML(stream);
+ } finally {
+ stream.close();
+ }
+
+ Properties props = new Properties();
+ InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/velocity.properties");
+ props.load(propsStream);
+ propsStream.close();
+
+ File classesOutputDirectory = new File(outputDir + "/generated-sources/autotag/classes");
+ File resourcesOutputDirectory = new File(outputDir + "/generated-sources/autotag");
+
+ TemplateGenerator generator = new JspTemplateGeneratorFactory(classesOutputDirectory,
+ resourcesOutputDirectory, new VelocityEngine(props), TemplateGeneratorBuilder.createNewInstance())
+ .createTemplateGenerator();
+
+ generator.generate(packageName, suite, parameters, runtime, requestClass);
+
+ } catch (Exception e) {
+ // ignored
+ }
+
+ }
+
+ /**
+ * Builds the Freemarker classes.
+ *
+ * To build, change template-suite.xml as required and then run this program.
+ * Copy the classes from the target autotag folder into the packageName
+ * location.
+ *
+ * @param outputDir the output dir
+ */
+ public void buildFreemarker(String outputDir) {
+
+ // Default values
+ String packageName = "org.apache.tiles.freemarker.template";
+ String requestClass = "org.apache.tiles.request.Request";
+ String runtime = "org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime";
+ // outputDir = "/target"
+
+ try {
+
+ TemplateSuite suite;
+
+ InputStream stream = getClass().getResourceAsStream("/META-INF/template-suite.xml");
+
+ try {
+ XStream xstream = new XStream(new DomDriver());
+ xstream.allowTypes(new Class[] { org.apache.tiles.autotag.model.TemplateClass.class,
+ org.apache.tiles.autotag.model.TemplateSuite.class,
+ org.apache.tiles.autotag.model.TemplateParameter.class });
+ suite = (TemplateSuite) xstream.fromXML(stream);
+ } finally {
+ stream.close();
+ }
+
+ Properties props = new Properties();
+ InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/velocity.properties");
+ props.load(propsStream);
+ propsStream.close();
+
+ File classesOutputDirectory = new File(outputDir + "/generated-sources/autotag/classes");
+
+ TemplateGenerator generator = new FMTemplateGeneratorFactory(classesOutputDirectory,
+ new VelocityEngine(props), TemplateGeneratorBuilder.createNewInstance()).createTemplateGenerator();
+
+ generator.generate(packageName, suite, null, runtime, requestClass);
+
+ } catch (Exception e) {
+ // ignored
+ }
+
+ }
+
+ /**
+ * Builds the velocity classes and velocity.properties.
+ *
+ * To build, change template-suite.xml as required and then run this program.
+ * Copy the classes from the target autotag folder into the packageName
+ * location, and velocity.properties to
+ * src/main/resources/META-INF/velocity.properties
+ *
+ * @param outputDir the output dir
+ */
+ public void buildVelocity(String outputDir) {
+
+ // Default values
+ String packageName = "org.apache.tiles.velocity.template";
+ String requestClass = "org.apache.tiles.request.Request";
+ String runtime = "org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime";
+ // outputDir = "/target"
+
+ try {
+
+ TemplateSuite suite;
+
+ InputStream stream = getClass().getResourceAsStream("/META-INF/template-suite.xml");
+
+ try {
+ XStream xstream = new XStream(new DomDriver());
+ xstream.allowTypes(new Class[] { org.apache.tiles.autotag.model.TemplateClass.class,
+ org.apache.tiles.autotag.model.TemplateSuite.class,
+ org.apache.tiles.autotag.model.TemplateParameter.class });
+ suite = (TemplateSuite) xstream.fromXML(stream);
+ } finally {
+ stream.close();
+ }
+
+ Properties props = new Properties();
+ InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/velocity.properties");
+ props.load(propsStream);
+ propsStream.close();
+
+ File classesOutputDirectory = new File(outputDir + "/generated-sources/autotag/classes");
+ File resourcesOutputDirectory = new File(outputDir + "/generated-sources/autotag");
+
+ TemplateGenerator generator = new VelocityTemplateGeneratorFactory(classesOutputDirectory,
+ resourcesOutputDirectory, new VelocityEngine(props), TemplateGeneratorBuilder.createNewInstance())
+ .createTemplateGenerator();
+
+ generator.generate(packageName, suite, null, runtime, requestClass);
+
+ } catch (Exception e) {
+ // ignored
+ }
+
+ }
+
+}
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java
index 04673f294b..e566f57476 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java
@@ -25,7 +25,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
-import org.apache.tiles.evaluator.AbstractAttributeEvaluator;
+import org.apache.tiles.core.evaluator.AbstractAttributeEvaluator;
import org.apache.tiles.request.Request;
import org.apache.tiles.request.servlet.ServletUtil;
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java
index b0cdb95baa..7b3e7624f9 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java
@@ -25,8 +25,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
-import org.apache.tiles.evaluator.AbstractAttributeEvaluator;
-import org.apache.tiles.evaluator.EvaluationException;
+import org.apache.tiles.core.evaluator.AbstractAttributeEvaluator;
+import org.apache.tiles.core.evaluator.EvaluationException;
import org.apache.tiles.request.Request;
import org.apache.tiles.request.servlet.ServletUtil;
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
index cb6e0d403f..e39fed4c6f 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
@@ -33,9 +33,9 @@
import org.apache.struts2.views.freemarker.FreemarkerResult;
import org.apache.struts2.views.freemarker.StrutsBeanWrapper;
import org.apache.tiles.freemarker.template.TilesFMModelRepository;
-import org.apache.tiles.impl.InvalidTemplateException;
import org.apache.tiles.request.Request;
import org.apache.tiles.request.render.Renderer;
+import org.apache.tiles.core.impl.InvalidTemplateException;
import org.apache.tiles.request.servlet.ServletUtil;
import javax.servlet.ServletContext;
@@ -44,7 +44,7 @@
public class StrutsFreeMarkerAttributeRenderer implements Renderer {
- private static Logger LOG = LogManager.getLogger(StrutsFreeMarkerAttributeRenderer.class);
+ private static final Logger LOG = LogManager.getLogger(StrutsFreeMarkerAttributeRenderer.class);
@Override
public void render(String path, Request request) throws IOException {
@@ -75,7 +75,7 @@ public void render(String path, Request request) throws IOException {
}
/**
- * Depending how Tiles definition was defined, request can an instance of JspRequest (for JSPs)
+ * Depending on how Tiles definition was defined, request can an instance of JspRequest (for JSPs)
* or a ServletRequest (FreeMarker)
*/
protected ActionContext readActionContext(Request request) {
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsPreparerFactory.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsPreparerFactory.java
index e279adcb40..8630a061f6 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsPreparerFactory.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsPreparerFactory.java
@@ -23,8 +23,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.tiles.preparer.ViewPreparer;
-import org.apache.tiles.preparer.factory.BasicPreparerFactory;
+import org.apache.tiles.api.preparer.ViewPreparer;
+import org.apache.tiles.core.prepare.factory.BasicPreparerFactory;
/**
* This is a basic ViewPreparer factory that uses {@link ObjectFactory} to create the ViewPreparer
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
index e36b75d16c..8842578afc 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -25,10 +25,10 @@
import org.apache.struts2.tiles.annotation.TilesDefinitions;
import org.apache.struts2.tiles.annotation.TilesPutAttribute;
import org.apache.struts2.tiles.annotation.TilesPutListAttribute;
-import org.apache.tiles.Attribute;
-import org.apache.tiles.Definition;
-import org.apache.tiles.Expression;
-import org.apache.tiles.ListAttribute;
+import org.apache.tiles.api.Attribute;
+import org.apache.tiles.api.Definition;
+import org.apache.tiles.api.Expression;
+import org.apache.tiles.api.ListAttribute;
/**
* Processes tiles annotations to create {@link Definition}s and
@@ -123,7 +123,7 @@ protected Attribute buildTemplateAttribute(TilesDefinition tilesDef) {
String templateType = getValueOrNull(tilesDef.templateType());
if (templateType != null) {
attribute.setRenderer(templateType);
- } else if (getValueOrNull(tilesDef.extend()) != null && templateType == null) {
+ } else if (getValueOrNull(tilesDef.extend()) != null) {
attribute.setRenderer(null);
}
return attribute;
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
index 41b93a38fc..205476467d 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
@@ -24,25 +24,31 @@
import ognl.PropertyAccessor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.tiles.TilesContainer;
-import org.apache.tiles.definition.DefinitionsFactory;
-import org.apache.tiles.definition.pattern.DefinitionPatternMatcherFactory;
-import org.apache.tiles.definition.pattern.PatternDefinitionResolver;
-import org.apache.tiles.definition.pattern.PrefixedPatternDefinitionResolver;
-import org.apache.tiles.definition.pattern.regexp.RegexpDefinitionPatternMatcherFactory;
-import org.apache.tiles.definition.pattern.wildcard.WildcardDefinitionPatternMatcherFactory;
+import org.apache.tiles.api.TilesContainer;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.ApplicationResource;
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.render.BasicRendererFactory;
+import org.apache.tiles.request.render.ChainedDelegateRenderer;
+import org.apache.tiles.core.definition.DefinitionsFactory;
+import org.apache.tiles.core.definition.pattern.DefinitionPatternMatcherFactory;
+import org.apache.tiles.core.definition.pattern.PatternDefinitionResolver;
+import org.apache.tiles.core.definition.pattern.PrefixedPatternDefinitionResolver;
+import org.apache.tiles.core.definition.pattern.regexp.RegexpDefinitionPatternMatcherFactory;
+import org.apache.tiles.core.definition.pattern.wildcard.WildcardDefinitionPatternMatcherFactory;
+import org.apache.tiles.core.evaluator.AttributeEvaluatorFactory;
+import org.apache.tiles.core.evaluator.BasicAttributeEvaluatorFactory;
+import org.apache.tiles.core.evaluator.impl.DirectAttributeEvaluator;
+import org.apache.tiles.core.factory.BasicTilesContainerFactory;
+import org.apache.tiles.core.factory.TilesContainerFactoryException;
+import org.apache.tiles.core.impl.mgmt.CachingTilesContainer;
+import org.apache.tiles.core.locale.LocaleResolver;
+import org.apache.tiles.core.prepare.factory.PreparerFactory;
import org.apache.tiles.el.ELAttributeEvaluator;
import org.apache.tiles.el.JspExpressionFactoryFactory;
import org.apache.tiles.el.ScopeELResolver;
import org.apache.tiles.el.TilesContextBeanELResolver;
import org.apache.tiles.el.TilesContextELResolver;
-import org.apache.tiles.evaluator.AttributeEvaluatorFactory;
-import org.apache.tiles.evaluator.BasicAttributeEvaluatorFactory;
-import org.apache.tiles.evaluator.impl.DirectAttributeEvaluator;
-import org.apache.tiles.factory.BasicTilesContainerFactory;
-import org.apache.tiles.factory.TilesContainerFactoryException;
-import org.apache.tiles.impl.mgmt.CachingTilesContainer;
-import org.apache.tiles.locale.LocaleResolver;
import org.apache.tiles.ognl.AnyScopePropertyAccessor;
import org.apache.tiles.ognl.DelegatePropertyAccessor;
import org.apache.tiles.ognl.NestedObjectDelegatePropertyAccessor;
@@ -51,12 +57,6 @@
import org.apache.tiles.ognl.ScopePropertyAccessor;
import org.apache.tiles.ognl.TilesApplicationContextNestedObjectExtractor;
import org.apache.tiles.ognl.TilesContextPropertyAccessorDelegateFactory;
-import org.apache.tiles.preparer.factory.PreparerFactory;
-import org.apache.tiles.request.ApplicationContext;
-import org.apache.tiles.request.ApplicationResource;
-import org.apache.tiles.request.Request;
-import org.apache.tiles.request.render.BasicRendererFactory;
-import org.apache.tiles.request.render.ChainedDelegateRenderer;
import org.apache.tiles.request.render.Renderer;
import javax.el.ArrayELResolver;
@@ -81,7 +81,7 @@
* - S2 ro access Struts' ValueStack
* - OGNL
* - EL
- *
+ *
* If you need additional features create your own listener and factory,
* you can base on code from Tiles' CompleteAutoloadTilesContainerFactory
*/
@@ -270,4 +270,4 @@ protected OGNLAttributeEvaluator createOGNLEvaluator() {
}
}
-}
\ No newline at end of file
+}
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
index 5170003a40..cb471a1ab5 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
@@ -20,11 +20,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.tiles.definition.DefinitionsFactory;
-import org.apache.tiles.factory.AbstractTilesContainerFactory;
+import org.apache.tiles.core.definition.DefinitionsFactory;
+import org.apache.tiles.core.factory.AbstractTilesContainerFactory;
+import org.apache.tiles.core.startup.AbstractTilesInitializer;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.servlet.ServletApplicationContext;
-import org.apache.tiles.startup.AbstractTilesInitializer;
import javax.servlet.ServletContext;
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java
index 38e5065522..5ebe36237e 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java
@@ -20,7 +20,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.tiles.startup.TilesInitializer;
+import org.apache.tiles.core.startup.TilesInitializer;
import org.apache.tiles.web.startup.AbstractTilesListener;
/**
@@ -37,4 +37,4 @@ protected TilesInitializer createTilesInitializer() {
LOG.info("Starting Struts Tiles 3 integration ...");
return new StrutsTilesInitializer();
}
-}
\ No newline at end of file
+}
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesLocaleResolver.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesLocaleResolver.java
index 3e6524fa4b..0d3d3ec33e 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesLocaleResolver.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesLocaleResolver.java
@@ -24,7 +24,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
-import org.apache.tiles.locale.LocaleResolver;
+import org.apache.tiles.core.locale.LocaleResolver;
import org.apache.tiles.request.Request;
import org.apache.tiles.request.servlet.ServletUtil;
@@ -33,7 +33,7 @@
public class StrutsTilesLocaleResolver implements LocaleResolver {
- private static Logger LOG = LogManager.getLogger(StrutsTilesLocaleResolver.class);
+ private static final Logger LOG = LogManager.getLogger(StrutsTilesLocaleResolver.class);
@Override
public Locale resolveLocale(Request request) {
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
index 6a890d4a95..7af6069bba 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
@@ -24,7 +24,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tiles.request.ApplicationResource;
-import org.apache.tiles.request.locale.URLApplicationResource;
import org.apache.tiles.request.servlet.ServletApplicationContext;
import javax.servlet.ServletContext;
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index a1e1c69d75..3ca20e4c19 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -29,58 +29,41 @@
import org.apache.struts2.result.ServletDispatcherResult;
import org.apache.struts2.tiles.StrutsTilesAnnotationProcessor;
import org.apache.struts2.tiles.annotation.TilesDefinition;
-import org.apache.tiles.Definition;
-import org.apache.tiles.TilesContainer;
-import org.apache.tiles.TilesException;
+import org.apache.tiles.api.Definition;
+import org.apache.tiles.api.TilesContainer;
+import org.apache.tiles.api.TilesException;
import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.mgmt.MutableTilesContainer;
+import org.apache.tiles.api.access.TilesAccess;
+import org.apache.tiles.api.mgmt.MutableTilesContainer;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.Request;
import org.apache.tiles.request.servlet.ServletRequest;
import org.apache.tiles.request.servlet.ServletUtil;
/**
- *
- * Renders a view using struts-tiles.
- *
- *
- *
- * In your web.xml file, you need to add a TilesListener.
- *
+ * Renders a view using struts-tiles. In your web.xml file, you need to add a TilesListener.
+ *