WW-4584 Upgrades Tiles plugin to Tiles 3

Also drops existing Tiles 3 plugin
This commit is contained in:
Lukasz Lenart
2016-01-18 15:55:59 +01:00
24 changed files with 779 additions and 869 deletions
-5
View File
@@ -171,11 +171,6 @@
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.0</version>
</dependency>
<!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher.
This is only necessary in tests-->
@@ -350,6 +350,7 @@ public class FreemarkerManager {
servletContext.setAttribute(ATTR_APPLICATION_MODEL, servletContextModel);
}
TaglibFactory taglibs = new TaglibFactory(servletContext);
taglibs.setObjectWrapper(wrapper);
servletContext.setAttribute(ATTR_JSP_TAGLIBS_MODEL, taglibs);
}
model.put(KEY_APPLICATION, servletContextModel);
-1
View File
@@ -58,7 +58,6 @@
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
-1
View File
@@ -59,7 +59,6 @@
<module>spring</module>
<module>testng</module>
<module>tiles</module>
<module>tiles3</module>
</modules>
<dependencies>
+4
View File
@@ -42,6 +42,10 @@
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-portlet</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
@@ -1,29 +1,51 @@
/*
* $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.struts2.views.tiles;
import com.opensymphony.xwork2.ActionInvocation;
import freemarker.template.TemplateException;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.result.ServletDispatcherResult;
import org.apache.struts2.portlet.PortletConstants;
import org.apache.struts2.portlet.context.PortletActionContext;
import org.apache.struts2.result.ServletDispatcherResult;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.TilesException;
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.Request;
import org.apache.tiles.request.portlet.RenderPortletRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.portlet.PortletContext;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import java.util.Map;
/**
* JIRA WW-2749 (STRUTS).
* Dedicated Tile result to be used in Portlet environment
*
* WW-2749
*/
public class PortletTilesResult extends ServletDispatcherResult {
private static final long serialVersionUID = -3806939435493086244L;
public static final String TILES_ACTION_NAME = "tilesDirect";
public PortletTilesResult() {
super();
@@ -33,10 +55,7 @@ public class PortletTilesResult extends ServletDispatcherResult {
super(location);
}
// FIXME PATCH du JIRA WW-2749 (STRUTS)
public void doExecute(String location, ActionInvocation invocation)
throws IOException, TemplateException, PortletException, TilesException {
public void doExecute(String location, ActionInvocation invocation) throws Exception {
if (PortletActionContext.getPhase().isAction() || PortletActionContext.getPhase().isEvent()) {
executeActionResult(location, invocation);
} else {
@@ -44,30 +63,24 @@ public class PortletTilesResult extends ServletDispatcherResult {
}
}
/**
* @param location
* @throws TilesException
*/
protected void executeRenderResult(String location) throws TilesException {
setLocation(location);
ServletContext servletContext = ServletActionContext.getServletContext();
TilesContainer container = TilesAccess.getContainer(servletContext);
PortletContext portletContext = PortletActionContext.getPortletContext();
RenderRequest request = PortletActionContext.getRenderRequest();
RenderResponse response = PortletActionContext.getRenderResponse();
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
TilesContainer container = getCurrentContainer(request, portletContext);
ApplicationContext applicationContext = container.getApplicationContext();
Request currentRequest = new RenderPortletRequest(applicationContext, portletContext, request, response);
container.render(location, request, response);
container.render(location, currentRequest);
}
/**
* @param location
* @param invocation
*/
protected void executeActionResult(String location, ActionInvocation invocation) {
ActionResponse res = PortletActionContext.getActionResponse();
res.setRenderParameter(PortletConstants.ACTION_PARAM, "tilesDirect");
res.setRenderParameter(PortletConstants.ACTION_PARAM, TILES_ACTION_NAME);
Map<String, Object> sessionMap = invocation.getInvocationContext().getSession();
sessionMap.put(PortletConstants.RENDER_DIRECT_LOCATION, location);
@@ -75,4 +88,27 @@ public class PortletTilesResult extends ServletDispatcherResult {
res.setRenderParameter(PortletConstants.MODE_PARAM, PortletActionContext.getRequest().getPortletMode().toString());
}
protected TilesContainer getCurrentContainer(javax.portlet.PortletRequest request, PortletContext context) {
TilesContainer container = (TilesContainer) request.getAttribute(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME);
if (container == null) {
container = getContainer(context);
request.setAttribute(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
}
return container;
}
protected TilesContainer getContainer(PortletContext context) {
return getContainer(context, TilesAccess.CONTAINER_ATTRIBUTE);
}
protected TilesContainer getContainer(PortletContext context, String key) {
if (key == null) {
key = TilesAccess.CONTAINER_ATTRIBUTE;
}
return (TilesContainer) context.getAttribute(key);
}
}
+37 -2
View File
@@ -34,21 +34,56 @@
<name>Struts 2 Tiles Plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-jsp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-ognl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-el</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -1,187 +0,0 @@
/*
* $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.struts2.tiles;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
/**
* ServletContext implementation which allows Struts
* to inject initialization parameters into the context
* in order to reduce the amount of configuration required
* within web.xml for using Tiles.
*
* The specified init parameters are only utilized if
* they are not explicitaly defined in the web.xml
*
* @version $Rev$
* @since Struts 2.0.1
*/
@SuppressWarnings("deprecation")
public class ConfiguredServletContext implements ServletContext {
private ServletContext rootContext;
private Map<String, String> initParameters;
public ConfiguredServletContext(ServletContext context, Map<String, String> initParameters) {
this.rootContext = context;
this.initParameters = initParameters;
}
public ServletContext getContext(String string) {
return rootContext.getContext(string);
}
public int getMajorVersion() {
return rootContext.getMajorVersion();
}
public int getMinorVersion() {
return rootContext.getMinorVersion();
}
public String getMimeType(String string) {
return rootContext.getMimeType(string);
}
public Set getResourcePaths(String string) {
return rootContext.getResourcePaths(string);
}
public URL getResource(String string) throws MalformedURLException {
return rootContext.getResource(string);
}
public InputStream getResourceAsStream(String string) {
return rootContext.getResourceAsStream(string);
}
public RequestDispatcher getRequestDispatcher(String string) {
return rootContext.getRequestDispatcher(string);
}
public RequestDispatcher getNamedDispatcher(String string) {
return rootContext.getNamedDispatcher(string);
}
@SuppressWarnings("deprecation")
public Servlet getServlet(String string) throws ServletException {
return rootContext.getServlet(string);
}
@SuppressWarnings("deprecation")
public Enumeration getServlets() {
return rootContext.getServlets(); //To change body of implemented methods use File | Settings | File Templates.
}
@SuppressWarnings("deprecation")
public Enumeration getServletNames() {
return rootContext.getServletNames();
}
public void log(String string) {
rootContext.log(string);
}
@SuppressWarnings("deprecation")
public void log(Exception exception, String string) {
rootContext.log(exception, string);
}
public void log(String string, Throwable throwable) {
rootContext.log(string, throwable);
}
public String getRealPath(String string) {
return rootContext.getRealPath(string);
}
public String getServerInfo() {
return rootContext.getServerInfo();
}
public String getInitParameter(String string) {
String parm = rootContext.getInitParameter(string);
if (parm == null) {
return initParameters.get(string);
}
return parm;
}
public Enumeration getInitParameterNames() {
return new CompositeEnumeration(
rootContext.getInitParameterNames(),
initParameters.keySet().iterator());
}
public Object getAttribute(String string) {
return rootContext.getAttribute(string);
}
public Enumeration getAttributeNames() {
return rootContext.getAttributeNames();
}
public void setAttribute(String string, Object object) {
rootContext.setAttribute(string, object);
}
public void removeAttribute(String string) {
rootContext.removeAttribute(string);
}
public String getServletContextName() {
return rootContext.getServletContextName();
}
class CompositeEnumeration implements Enumeration {
private Enumeration first;
private Iterator second;
public CompositeEnumeration(Enumeration first, Iterator second) {
this.first = first;
this.second = second;
}
public boolean hasMoreElements() {
return first.hasMoreElements() || second.hasNext();
}
public Object nextElement() {
if (first.hasMoreElements()) {
return first.nextElement();
}
return second.next();
}
}
}
@@ -0,0 +1,55 @@
/*
* 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 org.apache.tiles.request.locale.PostfixedApplicationResource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class StrutsApplicationResource extends PostfixedApplicationResource {
private final URL url;
public StrutsApplicationResource(URL url) {
super(url.getPath());
this.url = url;
}
@Override
public InputStream getInputStream() throws IOException {
if (new File(url.getPath()).exists()) {
return url.openStream();
}
return null;
}
@Override
public long getLastModified() throws IOException {
File file = new File(url.getPath());
if (file.exists()) {
return file.lastModified();
}
return 0;
}
}
@@ -0,0 +1,118 @@
/*
* 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 com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Container;
import freemarker.ext.beans.BeanModel;
import freemarker.template.Configuration;
import freemarker.template.TemplateException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.views.JspSupportServlet;
import org.apache.struts2.views.freemarker.FreemarkerManager;
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.request.servlet.ServletUtil;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
public class StrutsFreeMarkerAttributeRenderer implements Renderer {
private static Logger LOG = LogManager.getLogger(StrutsFreeMarkerAttributeRenderer.class);
@Override
public void render(String path, Request request) throws IOException {
if (path != null) {
LOG.trace("Rendering freemarker tile [{}]", path);
ActionContext ctx = readActionContext(request);
registerTilesBeanModel(ctx);
FreemarkerResult result = new FreemarkerResult(path);
result.setWriter(request.getWriter());
Container container = ctx.getContainer();
container.inject(result);
try {
ActionInvocation invocation = ctx.getActionInvocation();
result.doExecute(path, invocation);
} catch (TemplateException e) {
LOG.error("Exception was thrown during rendering value {}: {}", path, e.getMessage());
throw new InvalidTemplateException(e);
}
} else {
LOG.error("Path is null, cannot render template!");
throw new InvalidTemplateException("Cannot render a null template");
}
}
/**
* Depending how Tiles definition was defined, request can an instance of JspRequest (for JSPs)
* or a ServletRequest (FreeMarker)
*/
protected ActionContext readActionContext(Request request) {
LOG.debug("Obtaining HttpServletRequest based on [{}]", request.getClass().getName());
HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
if (ctx == null) {
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
throw new ConfigurationException("There is no ActionContext for current request!");
}
return ctx;
}
@Override
public boolean isRenderable(String path, Request request) {
LOG.trace("Checking if path [{}] can be rendered", path);
return path != null && path.startsWith("/") && path.endsWith(".ftl");
}
/**
* This register dedicated BeanModel to support tiles tags.
* It requires {@link org.apache.struts2.views.JspSupportServlet} to be registered in web.xml
*/
protected void registerTilesBeanModel(ActionContext ctx) {
ServletContext servletContext = ServletActionContext.getServletContext();
Configuration configuration = ctx.getInstance(FreemarkerManager.class).getConfiguration(servletContext);
StrutsBeanWrapper wrapper = (StrutsBeanWrapper) ctx.getInstance(FreemarkerManager.class).getWrapper();
LOG.trace("Adding support for Tiles tags, please remember to register {} in web.xml!", JspSupportServlet.class.getName());
BeanModel tilesBeanModel = new BeanModel(new TilesFMModelRepository(), wrapper);
configuration.setSharedVariable("tiles", tilesBeanModel);
}
}
@@ -1,6 +1,4 @@
/*
* $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
@@ -21,73 +19,213 @@
package org.apache.struts2.tiles;
import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.TilesException;
import org.apache.tiles.context.TilesContextFactory;
import org.apache.tiles.context.TilesRequestContext;
import ognl.OgnlException;
import ognl.OgnlRuntime;
import ognl.PropertyAccessor;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.definition.DefinitionsFactory;
import org.apache.tiles.factory.TilesContainerFactory;
import org.apache.tiles.impl.BasicTilesContainer;
import org.apache.tiles.preparer.PreparerFactory;
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.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;
import org.apache.tiles.ognl.OGNLAttributeEvaluator;
import org.apache.tiles.ognl.PropertyAccessorDelegateFactory;
import org.apache.tiles.ognl.ScopePropertyAccessor;
import org.apache.tiles.ognl.TilesApplicationContextNestedObjectExtractor;
import org.apache.tiles.ognl.TilesContextPropertyAccessorDelegateFactory;
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;
import javax.el.BeanELResolver;
import javax.el.CompositeELResolver;
import javax.el.ELResolver;
import javax.el.ListELResolver;
import javax.el.MapELResolver;
import javax.el.ResourceBundleELResolver;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class StrutsTilesContainerFactory extends TilesContainerFactory {
@Override
protected void storeContainerDependencies(Object context, Map<String, String> initParameters, Map<String, String> configuration, BasicTilesContainer container) throws TilesException {
TilesContextFactory contextFactory =
(TilesContextFactory) createFactory(configuration,
CONTEXT_FACTORY_INIT_PARAM);
contextFactory = new StrutsTilesContextFactory(contextFactory);
DefinitionsFactory defsFactory =
(DefinitionsFactory) createFactory(configuration,
DEFINITIONS_FACTORY_INIT_PARAM);
PreparerFactory prepFactory =
(PreparerFactory) createFactory(configuration,
PREPARER_FACTORY_INIT_PARAM);
contextFactory.init(configuration);
TilesApplicationContext tilesContext =
contextFactory.createApplicationContext(context);
container.setDefinitionsFactory(defsFactory);
container.setContextFactory(contextFactory);
container.setPreparerFactory(prepFactory);
container.setApplicationContext(tilesContext);
}
/**
* Dedicated Struts factory to build Tiles container with support for:
* - Freemarker
* - OGNL (as default)
* - EL
* - Wildcards
*
* If you need additional features create your own listener and factory,
* you can base on code from Tiles' CompleteAutoloadTilesContainerFactory
*/
public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
/**
* Wrapper factory, used to decorate the TilesRequestContext with a
* FreemarkerResult aware version.
*
* The freemarker renderer name.
*/
class StrutsTilesContextFactory implements TilesContextFactory {
public static final String FREEMARKER_RENDERER_NAME = "freemarker";
private TilesContextFactory factory;
/**
* Supported pattern types
*/
public static final String PATTERN_WILDCARD = "WILDCARD";
public static final String PATTERN_REGEXP = "REGEXP";
public StrutsTilesContextFactory(TilesContextFactory factory) {
this.factory = factory;
/**
* Default pattern to be used to collect Tiles definitions if user didn't configure any
*/
public static final String TILES_DEFAULT_PATTERN = "tiles*.xml";
/**
* Supported expression languages
*/
public static final String OGNL = "OGNL";
public static final String EL = "EL";
@Override
public TilesContainer createDecoratedContainer(TilesContainer originalContainer, ApplicationContext applicationContext) {
return new CachingTilesContainer(originalContainer);
}
@Override
protected void registerAttributeRenderers(
final BasicRendererFactory rendererFactory,
final ApplicationContext applicationContext,
final TilesContainer container,
final AttributeEvaluatorFactory attributeEvaluatorFactory) {
super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory);
StrutsFreeMarkerAttributeRenderer freemarkerRenderer = new StrutsFreeMarkerAttributeRenderer();
rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer);
}
@Override
protected Renderer createDefaultAttributeRenderer(
BasicRendererFactory rendererFactory,
ApplicationContext applicationContext,
TilesContainer container,
AttributeEvaluatorFactory attributeEvaluatorFactory) {
ChainedDelegateRenderer retValue = new ChainedDelegateRenderer();
retValue.addAttributeRenderer(rendererFactory.getRenderer(DEFINITION_RENDERER_NAME));
retValue.addAttributeRenderer(rendererFactory.getRenderer(FREEMARKER_RENDERER_NAME));
retValue.addAttributeRenderer(rendererFactory.getRenderer(TEMPLATE_RENDERER_NAME));
retValue.addAttributeRenderer(rendererFactory.getRenderer(STRING_RENDERER_NAME));
return retValue;
}
@Override
protected AttributeEvaluatorFactory createAttributeEvaluatorFactory(
ApplicationContext applicationContext,
LocaleResolver resolver) {
BasicAttributeEvaluatorFactory attributeEvaluatorFactory = new BasicAttributeEvaluatorFactory(new DirectAttributeEvaluator());
attributeEvaluatorFactory.registerAttributeEvaluator(OGNL, createOGNLEvaluator());
attributeEvaluatorFactory.registerAttributeEvaluator(EL, createELEvaluator(applicationContext));
return attributeEvaluatorFactory;
}
@Override
protected <T> PatternDefinitionResolver<T> createPatternDefinitionResolver(Class<T> customizationKeyClass) {
DefinitionPatternMatcherFactory wildcardFactory = new WildcardDefinitionPatternMatcherFactory();
DefinitionPatternMatcherFactory regexpFactory = new RegexpDefinitionPatternMatcherFactory();
PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<>();
resolver.registerDefinitionPatternMatcherFactory(PATTERN_WILDCARD, wildcardFactory);
resolver.registerDefinitionPatternMatcherFactory(PATTERN_REGEXP, regexpFactory);
return resolver;
}
protected LocaleResolver createLocaleResolver(ApplicationContext applicationContext) {
return new StrutsTilesLocaleResolver();
}
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
Collection<ApplicationResource> resources = applicationContext.getResources(getTilesDefinitionPattern(applicationContext.getInitParams()));
List<ApplicationResource> filteredResources = new ArrayList<>();
if (resources != null) {
for (ApplicationResource resource : resources) {
if (Locale.ROOT.equals(resource.getLocale())) {
filteredResources.add(resource);
}
}
}
public void init(Map<String, String> map) {
factory.init(map);
}
return filteredResources;
}
public TilesApplicationContext createApplicationContext(Object context) {
return factory.createApplicationContext(context);
protected String getTilesDefinitionPattern(Map<String, String> params) {
if (params.containsKey(DefinitionsFactory.DEFINITIONS_CONFIG)) {
return params.get(DefinitionsFactory.DEFINITIONS_CONFIG);
}
return TILES_DEFAULT_PATTERN;
}
public TilesRequestContext createRequestContext(
TilesApplicationContext tilesApplicationContext,
Object... requestItems) {
TilesRequestContext context = factory.createRequestContext(tilesApplicationContext, requestItems);
return new StrutsTilesRequestContext(context);
protected ELAttributeEvaluator createELEvaluator(ApplicationContext applicationContext) {
ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
JspExpressionFactoryFactory efFactory = new JspExpressionFactoryFactory();
efFactory.setApplicationContext(applicationContext);
evaluator.setExpressionFactory(efFactory.getExpressionFactory());
ELResolver elResolver = new CompositeELResolver() {
{
BeanELResolver beanElResolver = new BeanELResolver(false);
add(new ScopeELResolver());
add(new TilesContextELResolver(beanElResolver));
add(new TilesContextBeanELResolver());
add(new ArrayELResolver(false));
add(new ListELResolver(false));
add(new MapELResolver(false));
add(new ResourceBundleELResolver());
add(beanElResolver);
}
};
evaluator.setResolver(elResolver);
return evaluator;
}
protected OGNLAttributeEvaluator createOGNLEvaluator() {
try {
PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class);
PropertyAccessor applicationContextPropertyAccessor = new NestedObjectDelegatePropertyAccessor<>(
new TilesApplicationContextNestedObjectExtractor(), objectPropertyAccessor);
PropertyAccessor anyScopePropertyAccessor = new AnyScopePropertyAccessor();
PropertyAccessor scopePropertyAccessor = new ScopePropertyAccessor();
PropertyAccessorDelegateFactory<Request> factory = new TilesContextPropertyAccessorDelegateFactory(
objectPropertyAccessor, applicationContextPropertyAccessor, anyScopePropertyAccessor,
scopePropertyAccessor);
PropertyAccessor tilesRequestAccessor = new DelegatePropertyAccessor<>(factory);
OgnlRuntime.setPropertyAccessor(Request.class, tilesRequestAccessor);
return new OGNLAttributeEvaluator();
} catch (OgnlException e) {
throw new TilesContainerFactoryException("Cannot initialize OGNL evaluator", e);
}
}
}
}
@@ -0,0 +1,46 @@
/*
* 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 org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tiles.factory.AbstractTilesContainerFactory;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.startup.AbstractTilesInitializer;
import javax.servlet.ServletContext;
public class StrutsTilesInitializer extends AbstractTilesInitializer {
private static final Logger LOG = LogManager.getLogger(StrutsTilesInitializer.class);
@Override
protected ApplicationContext createTilesApplicationContext(ApplicationContext preliminaryContext) {
LOG.debug("Initializing Tiles wildcard support ...");
return new StrutsWildcardServletApplicationContext((ServletContext) preliminaryContext.getContext());
}
@Override
protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext context) {
LOG.trace("Creating dedicated Struts factory to create Tiles container");
return new StrutsTilesContainerFactory();
}
}
@@ -1,6 +1,4 @@
/*
* $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
@@ -21,57 +19,23 @@
package org.apache.struts2.tiles;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.TilesException;
import org.apache.tiles.factory.TilesContainerFactory;
import org.apache.tiles.web.startup.TilesListener;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tiles.startup.TilesInitializer;
import org.apache.tiles.web.startup.AbstractTilesListener;
/**
* Listener used to automatically inject ServletContext
* init parameters so that they don't need to be configured
* explicitly for tiles integration. This is provided
* mainly for backwards compatibility with Struts 2.0.1
* configuration.
* Listener used to automatically tie Tiles support into Struts
*
* @since Struts 2.0.2
* @version $Rev$
*
*/
public class StrutsTilesListener extends TilesListener {
public class StrutsTilesListener extends AbstractTilesListener {
private static final Logger LOG = LogManager.getLogger(StrutsTilesListener.class);
private static final Map<String, String> INIT;
static {
INIT = new HashMap<String, String>();
INIT.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
StrutsTilesContainerFactory.class.getName());
@Override
protected TilesInitializer createTilesInitializer() {
LOG.info("Starting Struts Tiles 2 integration ...");
return new StrutsTilesInitializer();
}
protected TilesContainer createContainer(ServletContext context)
throws TilesException {
if(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM) == null) {
context = decorate(context);
}
else {
if (LOG.isWarnEnabled()) {
LOG.warn("Tiles container factory is explicitly set. Not injecting struts configuration.");
}
}
return super.createContainer(context);
}
protected ServletContext decorate(ServletContext context) {
return new ConfiguredServletContext(context, INIT);
}
}
}
@@ -0,0 +1,54 @@
/*
* 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 com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.LocaleProvider;
import com.opensymphony.xwork2.config.ConfigurationException;
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.request.Request;
import org.apache.tiles.request.servlet.ServletUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.Locale;
public class StrutsTilesLocaleResolver implements LocaleResolver {
private static Logger LOG = LogManager.getLogger(StrutsTilesLocaleResolver.class);
@Override
public Locale resolveLocale(Request request) {
HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
if (ctx == null) {
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
throw new ConfigurationException("There is no ActionContext for current request!");
}
LocaleProvider provider = ctx.getInstance(LocaleProvider.class);
return provider.getLocale();
}
}
@@ -1,125 +0,0 @@
/*
* $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.struts2.tiles;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Container;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.views.freemarker.FreemarkerResult;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.context.TilesRequestContextWrapper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* <p>
* Default implementation of TilesUtil.
* This class contains default implementation of utilities. This implementation
* is intended to be used without Struts.
* </p>
*
* <p>
* TilesUtilImpl implementation used to intercept .ftl requests and
* ensure that they are setup properly to take advantage of the
* {@link FreemarkerResult}.
* </p>
*/
public class StrutsTilesRequestContext extends TilesRequestContextWrapper {
private static final Logger LOG = LogManager.getLogger(StrutsTilesRequestContext.class);
/**
* The mask used to detect requests which should be intercepted.
*/
private String mask;
/**
* Default constructor.
* Sets the mask to '.ftl'
*
* @param context
*/
public StrutsTilesRequestContext(TilesRequestContext context) {
this(context, ".ftl");
}
/**
* Optional constructor used to specify a specific mask.
*
* @param mask
* @param context
*/
public StrutsTilesRequestContext(TilesRequestContext context, String mask) {
super(context);
this.mask = mask;
}
public void dispatch(String include) throws IOException {
if (include.endsWith(mask)) {
// FIXME This way FreeMarker results still don't have a content-type!
include(include);
} else {
super.dispatch(include);
}
}
/**
* Enhancement of the default include which allows for freemarker
* templates to be intercepted so that the FreemarkerResult can
* be used in order to setup the appropriate model.
*
* @throws IOException
*/
public void include(String include) throws IOException {
if (include.endsWith(mask)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Intercepting tiles include '" + include + "'. Processing as freemarker result.");
}
HttpServletRequest request = (HttpServletRequest) getRequest();
HttpServletResponse response = (HttpServletResponse) getResponse();
ActionContext ctx = ServletActionContext.getActionContext(request);
ActionInvocation invocation = ctx.getActionInvocation();
try {
FreemarkerResult result = new FreemarkerResult();
result.setWriter(response.getWriter());
Container container = ctx.getContainer();
container.inject(result);
result.doExecute(include, invocation);
} catch (Exception e) {
LOG.error("Error invoking Freemarker template", e);
throw new IOException("Error invoking Freemarker template." + e.getMessage());
}
} else {
super.include(include);
}
}
}
@@ -0,0 +1,129 @@
/*
* 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 com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.util.WildcardUtil;
import com.opensymphony.xwork2.util.finder.ResourceFinder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tiles.request.ApplicationResource;
import org.apache.tiles.request.servlet.ServletApplicationContext;
import javax.servlet.ServletContext;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class StrutsWildcardServletApplicationContext extends ServletApplicationContext {
private static final Logger LOG = LogManager.getLogger(StrutsWildcardServletApplicationContext.class);
private ResourceFinder finder;
public StrutsWildcardServletApplicationContext(ServletContext context) {
super(context);
Set<URL> urls = new HashSet<>();
for (Object path : context.getResourcePaths("/")) {
try {
URL url = new File(context.getRealPath(String.valueOf(path))).toURI().toURL();
urls.add(url);
} catch (MalformedURLException e) {
throw new ConfigurationException(e);
}
}
try {
Enumeration<URL> resources = getClass().getClassLoader().getResources("/");
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
urls.add(resource);
}
} catch (IOException e) {
throw new ConfigurationException(e);
}
finder = new ResourceFinder(urls.toArray(new URL[urls.size()]));
}
public Collection<ApplicationResource> getResources(String path) {
Set<ApplicationResource> resources = new HashSet<>();
if (path.startsWith("/")) {
LOG.trace("Using ServletContext to load resource {}", path);
ApplicationResource resource = getResource(path);
if (resource != null) {
resources.add(resource);
}
}
try {
resources.addAll(findResources(path));
} catch (IOException e) {
LOG.error("Cannot find resources for [{}]", path, e);
}
return resources;
}
public ApplicationResource getResource(ApplicationResource base, Locale locale) {
String localePath = base.getLocalePath(locale);
if (new File(localePath).exists()) {
try {
return new StrutsApplicationResource(URI.create("file://" + localePath).toURL());
} catch (MalformedURLException e) {
LOG.warn("Cannot access [{}]", localePath, e);
return null;
}
}
return null;
}
protected Set<ApplicationResource> findResources(String path) throws IOException {
Set<ApplicationResource> resources = new HashSet<>();
LOG.trace("Using ResourceFinder to find matches for {}", path);
Pattern pattern = WildcardUtil.compileWildcardPattern(path);
Map<String, URL> matches = finder.getResourcesMap("");
for (String resource : matches.keySet()) {
if (pattern.matcher(resource).matches()) {
URL url = matches.get(resource);
resources.add(new StrutsApplicationResource(url));
}
}
LOG.trace("Found resources {} for path {}", resources, path);
return resources;
}
}
@@ -28,9 +28,13 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.result.ServletDispatcherResult;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.access.TilesAccess;
import com.opensymphony.xwork2.ActionInvocation;
import org.apache.tiles.access.TilesAccess;
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;
/**
* <!-- START SNIPPET: description -->
@@ -84,6 +88,7 @@ public class TilesResult extends ServletDispatcherResult {
public TilesResult(String location) {
super(location);
}
/**
* Dispatches to the given location. Does its forward via a RequestDispatcher. If the
* dispatch fails a 404 error will be sent back in the http response.
@@ -97,11 +102,15 @@ public class TilesResult extends ServletDispatcherResult {
setLocation(location);
ServletContext servletContext = ServletActionContext.getServletContext();
TilesContainer container = TilesAccess.getContainer(servletContext);
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
TilesContainer container = TilesAccess.getContainer(applicationContext);
container.render(location, request, response);
HttpServletRequest httpRequest = ServletActionContext.getRequest();
HttpServletResponse httpResponse = ServletActionContext.getResponse();
Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
container.render(location, request);
}
}
-60
View File
@@ -1,60 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* $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.
*/
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.5-SNAPSHOT</version>
</parent>
<artifactId>struts2-tiles3-plugin</artifactId>
<packaging>jar</packaging>
<name>Struts 2 Tiles 3 Plugin</name>
<properties>
<tiles3.version>3.0.1</tiles3.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${tiles3.version}</version> <!-- Version must defined here -->
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>${tiles3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${tiles3.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
@@ -1,81 +0,0 @@
/*
* $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.struts2.views.tiles;
import com.opensymphony.xwork2.ActionInvocation;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.result.ServletDispatcherResult;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.servlet.ServletRequest;
import org.apache.tiles.request.servlet.ServletUtil;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* First implementation of Tiles 3 support
*
* Please follow the link to read more how to configure the result
* http://stackoverflow.com/questions/13337938/how-to-integrate-struts-2-with-tiles-3
*
* or check the docs
*
* https://cwiki.apache.org/confluence/display/WW/Tiles+3+Plugin
*
*
* @author Ken McWilliams
*/
public class TilesResult extends ServletDispatcherResult {
public TilesResult() {
super();
}
public TilesResult(String location) {
super(location);
}
@Override
public void doExecute(String location, ActionInvocation invocation) throws Exception {
ServletContext context = ServletActionContext.getServletContext();
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
ApplicationContext applicationContext = ServletUtil.getApplicationContext(context);
ServletRequest servletRequest = new ServletRequest(applicationContext, request, response);
TilesContainer container = initTilesContainer(applicationContext, servletRequest);
container.startContext(servletRequest);
container.render(location, servletRequest);
}
protected TilesContainer initTilesContainer(ApplicationContext applicationContext, ServletRequest servletRequest) {
TilesContainer container = TilesAccess.getContainer(applicationContext);
TilesAccess.setCurrentContainer(servletRequest, container);
return container;
}
}
@@ -1,174 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
@@ -1,5 +0,0 @@
Apache Struts
Copyright 2000-2011 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
/*
* $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.
*/
-->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="tiles-default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
</package>
</struts>
-57
View File
@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/*
* 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.
*/
-->
<project name="Struts 2">
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.3.1</version>
</skin>
<bannerLeft>
<name>Apache Software Foundation</name>
<src>http://www.apache.org/images/asf-logo.gif</src>
<href>http://www.apache.org/</href>
</bannerLeft>
<bannerRight>
<name>Apache Struts</name>
<src>http://struts.apache.org/img/struts-logo.svg</src>
<href>http://struts.apache.org/</href>
</bannerRight>
<publishDate position="none"/>
<version position="none"/>
<body>
<links>
<item name="Apache" href="http://www.apache.org/"/>
<item name="Struts" href="http://struts.apache.org/"/>
</links>
<menu ref="parent"/>
<menu ref="reports"/>
<footer>
<div class="row span12">
Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts
project logos are trademarks of The Apache Software Foundation.
</div>
</footer>
</body>
</project>
+53 -2
View File
@@ -88,7 +88,8 @@
<ognl.version>3.1.2</ognl.version>
<asm.version>3.3</asm.version>
<asm5.version>5.0.2</asm5.version>
<tiles.version>2.0.6</tiles.version>
<tiles.version>3.0.5</tiles.version>
<tiles-request.version>1.0.6</tiles-request.version>
<log4j2.version>2.5</log4j2.version>
<!-- SCM Site Configuration -->
@@ -595,6 +596,12 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
@@ -616,16 +623,60 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-portlet</artifactId>
<version>${tiles-request.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-api</artifactId>
<version>${tiles-request.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-jsp</artifactId>
<version>${tiles-request.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-servlet</artifactId>
<version>${tiles-request.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${tiles.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-freemarker</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-ognl</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-el</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>