You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/01/18 15:56:43 UTC
[01/30] struts git commit: Adds required dependencies
Repository: struts
Updated Branches:
refs/heads/master 294394b25 -> d923c7c4f
Adds required dependencies
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/85b21981
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/85b21981
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/85b21981
Branch: refs/heads/master
Commit: 85b219813f982ad28059197c6ebcb0b099f7e4b3
Parents: ed8dc57
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:22:31 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Nov 25 20:22:31 2015 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 29 +++++++++++++++++++++++++++++
pom.xml | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/85b21981/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 3d2a01c..57d083f 100644
--- a/plugins/tiles/pom.xml
+++ b/plugins/tiles/pom.xml
@@ -40,14 +40,43 @@
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-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-servlet-wildcard</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-jsp</artifactId>
+ </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>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<properties>
http://git-wip-us.apache.org/repos/asf/struts/blob/85b21981/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5b33c88..098044d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@
<ognl.version>3.1.1</ognl.version>
<asm.version>3.3</asm.version>
<asm5.version>5.0.2</asm5.version>
- <tiles.version>2.0.6</tiles.version>
+ <tiles.version>2.2.2</tiles.version>
<log4j2.version>2.3</log4j2.version>
<!-- SCM Site Configuration -->
@@ -577,6 +577,13 @@
</dependency>
<dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
@@ -604,10 +611,40 @@
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-servlet</artifactId>
+ <version>${tiles.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-servlet-wildcard</artifactId>
+ <version>${tiles.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-jsp</artifactId>
+ <version>${tiles.version}</version>
+ </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>
<groupId>javax.servlet</groupId>
[10/30] struts git commit: Removes module
Posted by lu...@apache.org.
Removes module
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5fe760dc
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5fe760dc
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5fe760dc
Branch: refs/heads/master
Commit: 5fe760dc67f4b3bd16112ac48494782e570dd242
Parents: 2d0fe9f
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 08:19:52 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 08:19:52 2016 +0100
----------------------------------------------------------------------
plugins/pom.xml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/5fe760dc/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 2f1fe76..ba44181 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -59,7 +59,6 @@
<module>spring</module>
<module>testng</module>
<module>tiles</module>
- <module>tiles3</module>
</modules>
<dependencies>
[29/30] struts git commit: Simplifies logging
Posted by lu...@apache.org.
Simplifies logging
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/93375125
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/93375125
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/93375125
Branch: refs/heads/master
Commit: 93375125adb54a9e1e4a000557a202c7ca23fe73
Parents: 328da4e
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sun Jan 17 10:25:36 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sun Jan 17 10:25:36 2016 +0100
----------------------------------------------------------------------
.../struts2/tiles/StrutsWildcardServletApplicationContext.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/93375125/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
----------------------------------------------------------------------
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 2f67f04..0fa1bc3 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 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.logging.log4j.message.MessageFormatMessage;
import org.apache.tiles.request.ApplicationResource;
import org.apache.tiles.request.servlet.ServletApplicationContext;
@@ -89,7 +88,7 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC
try {
resources.addAll(findResources(path));
} catch (IOException e) {
- LOG.error(new MessageFormatMessage("Cannot find resources for [{}]", path), e);
+ LOG.error("Cannot find resources for [{}]", path, e);
}
return resources;
@@ -101,7 +100,7 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC
try {
return new StrutsApplicationResource(URI.create("file://" + localePath).toURL());
} catch (MalformedURLException e) {
- LOG.warn(new MessageFormatMessage("Cannot access [{}]", localePath), e);
+ LOG.warn("Cannot access [{}]", localePath, e);
return null;
}
}
[30/30] struts git commit: WW-4584 Upgrades Tiles plugin to Tiles 3
Also drops existing Tiles 3 plugin
Posted by lu...@apache.org.
WW-4584 Upgrades Tiles plugin to Tiles 3
Also drops existing Tiles 3 plugin
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d923c7c4
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d923c7c4
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d923c7c4
Branch: refs/heads/master
Commit: d923c7c4f2c7a674949c623350cd8948869ea987
Parents: 294394b 9337512
Author: Lukasz Lenart <lu...@apache.org>
Authored: Mon Jan 18 15:55:59 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Mon Jan 18 15:55:59 2016 +0100
----------------------------------------------------------------------
apps/showcase/pom.xml | 5 -
.../views/freemarker/FreemarkerManager.java | 1 +
plugins/bean-validation/pom.xml | 1 -
plugins/pom.xml | 1 -
plugins/portlet-tiles/pom.xml | 4 +
.../struts2/views/tiles/PortletTilesResult.java | 92 +++++---
plugins/tiles/pom.xml | 39 ++-
.../struts2/tiles/ConfiguredServletContext.java | 187 ---------------
.../tiles/StrutsApplicationResource.java | 55 +++++
.../StrutsFreeMarkerAttributeRenderer.java | 118 ++++++++++
.../tiles/StrutsTilesContainerFactory.java | 236 +++++++++++++++----
.../struts2/tiles/StrutsTilesInitializer.java | 46 ++++
.../struts2/tiles/StrutsTilesListener.java | 56 +----
.../tiles/StrutsTilesLocaleResolver.java | 54 +++++
.../tiles/StrutsTilesRequestContext.java | 125 ----------
...StrutsWildcardServletApplicationContext.java | 129 ++++++++++
.../apache/struts2/views/tiles/TilesResult.java | 19 +-
plugins/tiles3/pom.xml | 60 -----
.../apache/struts2/views/tiles/TilesResult.java | 81 -------
plugins/tiles3/src/main/resources/LICENSE.txt | 174 --------------
plugins/tiles3/src/main/resources/NOTICE.txt | 5 -
.../tiles3/src/main/resources/struts-plugin.xml | 34 ---
plugins/tiles3/src/site/site.xml | 57 -----
pom.xml | 55 ++++-
24 files changed, 772 insertions(+), 862 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d923c7c4/pom.xml
----------------------------------------------------------------------
[15/30] struts git commit: Adjusts code to Tiles 3
Posted by lu...@apache.org.
Adjusts code to Tiles 3
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/ace6a5d5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/ace6a5d5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/ace6a5d5
Branch: refs/heads/master
Commit: ace6a5d5ee0bdcfc81225832a477dff1bf4effbf
Parents: 4638b33
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 10:13:51 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 10:13:51 2016 +0100
----------------------------------------------------------------------
.../StrutsFreeMarkerAttributeRenderer.java | 75 ++++-----
.../tiles/StrutsTilesContainerFactory.java | 163 +++++++------------
.../struts2/tiles/StrutsTilesInitializer.java | 6 +-
...sWildcardServletTilesApplicationContext.java | 34 ++--
4 files changed, 110 insertions(+), 168 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/ace6a5d5/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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 849053a..48592e0 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,68 +33,53 @@ 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.Attribute;
-import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.freemarker.template.TilesFMModelRepository;
import org.apache.tiles.impl.InvalidTemplateException;
-import org.apache.tiles.renderer.impl.AbstractTypeDetectingAttributeRenderer;
-import org.apache.tiles.servlet.context.ServletTilesRequestContext;
-import org.apache.tiles.servlet.context.ServletUtil;
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.render.Renderer;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
-public class StrutsFreeMarkerAttributeRenderer extends AbstractTypeDetectingAttributeRenderer {
+public class StrutsFreeMarkerAttributeRenderer implements Renderer {
private static Logger LOG = LogManager.getLogger(StrutsFreeMarkerAttributeRenderer.class);
@Override
- public void write(Object value, Attribute attribute, TilesRequestContext request) throws IOException {
- if (value != null) {
- if (value instanceof String) {
- LOG.trace("Rendering freemarker tile ...");
-
- ServletTilesRequestContext servletRequest = ServletUtil.getServletRequest(request);
- HttpServletRequest httpRequest = servletRequest.getRequest();
-
- ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
- if (ctx == null) {
- throw new ConfigurationException("There is no ActionContext for current request!");
- }
-
- registerTilesBeanModel(ctx);
-
- String include = (String) value;
- FreemarkerResult result = new FreemarkerResult(include);
- result.setWriter(request.getWriter());
-
- Container container = ctx.getContainer();
- container.inject(result);
-
- try {
- ActionInvocation invocation = ctx.getActionInvocation();
- result.doExecute(include, invocation);
- } catch (TemplateException e) {
- LOG.error("Exception was thrown during rendering value {}: {}", value, e.getMessage());
- throw new InvalidTemplateException(e);
- }
- } else {
- LOG.error("Value {} is not a String, cannot render template!", value);
- throw new InvalidTemplateException("Cannot render a template that is not a string: " + String.valueOf(value));
+ public void render(String path, Request request) throws IOException {
+ if (path != null) {
+ LOG.trace("Rendering freemarker tile ...");
+
+ ActionContext ctx = ServletActionContext.getActionContext((HttpServletRequest) request);
+ if (ctx == null) {
+ throw new ConfigurationException("There is no ActionContext for current 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("Value is null, cannot render template!");
+ LOG.error("Path is null, cannot render template!");
throw new InvalidTemplateException("Cannot render a null template");
}
}
- public boolean isRenderable(Object value, Attribute attribute, TilesRequestContext request) {
- if (value instanceof String) {
- String string = (String) value;
- return string.startsWith("/") && string.endsWith(".ftl");
- }
- return false;
+ @Override
+ public boolean isRenderable(String path, Request request) {
+ return path != null && path.startsWith("/") && path.endsWith(".ftl");
}
/**
http://git-wip-us.apache.org/repos/asf/struts/blob/ace6a5d5/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 785082b..2c9b094 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
@@ -22,13 +22,8 @@ package org.apache.struts2.tiles;
import ognl.OgnlException;
import ognl.OgnlRuntime;
import ognl.PropertyAccessor;
-import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.TilesContainer;
-import org.apache.tiles.context.ChainedTilesRequestContextFactory;
-import org.apache.tiles.context.TilesRequestContext;
-import org.apache.tiles.context.TilesRequestContextFactory;
import org.apache.tiles.definition.DefinitionsFactory;
-import org.apache.tiles.definition.DefinitionsFactoryException;
import org.apache.tiles.definition.pattern.DefinitionPatternMatcherFactory;
import org.apache.tiles.definition.pattern.PatternDefinitionResolver;
import org.apache.tiles.definition.pattern.PrefixedPatternDefinitionResolver;
@@ -36,6 +31,7 @@ import org.apache.tiles.definition.pattern.regexp.RegexpDefinitionPatternMatcher
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;
@@ -43,25 +39,22 @@ 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.freemarker.context.FreeMarkerTilesRequestContextFactory;
-import org.apache.tiles.impl.BasicTilesContainer;
import org.apache.tiles.impl.mgmt.CachingTilesContainer;
import org.apache.tiles.locale.LocaleResolver;
-import org.apache.tiles.ognl.ApplicationScopeNestedObjectExtractor;
+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.RequestScopeNestedObjectExtractor;
-import org.apache.tiles.ognl.SessionScopeNestedObjectExtractor;
+import org.apache.tiles.ognl.ScopePropertyAccessor;
import org.apache.tiles.ognl.TilesApplicationContextNestedObjectExtractor;
import org.apache.tiles.ognl.TilesContextPropertyAccessorDelegateFactory;
-import org.apache.tiles.renderer.AttributeRenderer;
-import org.apache.tiles.renderer.TypeDetectingAttributeRenderer;
-import org.apache.tiles.renderer.impl.BasicRendererFactory;
-import org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer;
-import org.apache.tiles.servlet.context.ServletUtil;
-import org.apache.tiles.util.URLUtil;
+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;
@@ -70,12 +63,11 @@ import javax.el.ELResolver;
import javax.el.ListELResolver;
import javax.el.MapELResolver;
import javax.el.ResourceBundleELResolver;
-import javax.servlet.ServletContext;
-import java.io.IOException;
-import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
-import java.util.Set;
/**
* Dedicated Struts factory to build Tiles container with support for:
@@ -106,76 +98,42 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
public static final String TILES_DEFAULT_PATTERN = "tiles*.xml";
@Override
- protected BasicTilesContainer instantiateContainer(TilesApplicationContext applicationContext) {
- CachingTilesContainer tilesContainer = new CachingTilesContainer();
- ServletContext servletContext = (ServletContext) applicationContext.getContext();
- ServletUtil.setContainer(servletContext, tilesContainer);
- return tilesContainer;
- }
-
- @Override
- protected List<TilesRequestContextFactory> getTilesRequestContextFactoriesToBeChained(ChainedTilesRequestContextFactory parent) {
-
- List<TilesRequestContextFactory> factories = super.getTilesRequestContextFactoriesToBeChained(parent);
-
- registerRequestContextFactory(FreeMarkerTilesRequestContextFactory.class.getName(), factories, parent);
-
- return factories;
+ public TilesContainer createDecoratedContainer(TilesContainer originalContainer, ApplicationContext applicationContext) {
+ return new CachingTilesContainer(originalContainer);
}
@Override
protected void registerAttributeRenderers(
- BasicRendererFactory rendererFactory,
- TilesApplicationContext applicationContext,
- TilesRequestContextFactory contextFactory,
- TilesContainer container,
- AttributeEvaluatorFactory attributeEvaluatorFactory) {
+ final BasicRendererFactory rendererFactory,
+ final ApplicationContext applicationContext,
+ final TilesContainer container,
+ final AttributeEvaluatorFactory attributeEvaluatorFactory) {
- super.registerAttributeRenderers(
- rendererFactory,
- applicationContext,
- contextFactory,
- container,
- attributeEvaluatorFactory);
+ super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory);
StrutsFreeMarkerAttributeRenderer freemarkerRenderer = new StrutsFreeMarkerAttributeRenderer();
- freemarkerRenderer.setApplicationContext(applicationContext);
- freemarkerRenderer.setAttributeEvaluatorFactory(attributeEvaluatorFactory);
- freemarkerRenderer.setRequestContextFactory(contextFactory);
rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer);
}
@Override
- protected AttributeRenderer createDefaultAttributeRenderer(
+ protected Renderer createDefaultAttributeRenderer(
BasicRendererFactory rendererFactory,
- TilesApplicationContext applicationContext,
- TilesRequestContextFactory contextFactory,
+ ApplicationContext applicationContext,
TilesContainer container,
AttributeEvaluatorFactory attributeEvaluatorFactory) {
- ChainedDelegateAttributeRenderer retValue = new ChainedDelegateAttributeRenderer();
-
- retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
- .getRenderer(DEFINITION_RENDERER_NAME));
- retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
- .getRenderer(FREEMARKER_RENDERER_NAME));
- retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
- .getRenderer(TEMPLATE_RENDERER_NAME));
- retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
- .getRenderer(STRING_RENDERER_NAME));
-
- retValue.setApplicationContext(applicationContext);
- retValue.setRequestContextFactory(contextFactory);
- retValue.setAttributeEvaluatorFactory(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(
- TilesApplicationContext applicationContext,
- TilesRequestContextFactory contextFactory,
+ ApplicationContext applicationContext,
LocaleResolver resolver) {
BasicAttributeEvaluatorFactory attributeEvaluatorFactory = new BasicAttributeEvaluatorFactory(new DirectAttributeEvaluator());
@@ -187,26 +145,30 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
@Override
protected <T> PatternDefinitionResolver<T> createPatternDefinitionResolver(Class<T> customizationKeyClass) {
-
DefinitionPatternMatcherFactory wildcardFactory = new WildcardDefinitionPatternMatcherFactory();
DefinitionPatternMatcherFactory regexpFactory = new RegexpDefinitionPatternMatcherFactory();
+ PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<>();
- PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<T>();
- resolver.registerDefinitionPatternMatcherFactory(PATTERN_WILDCARD, wildcardFactory);
- resolver.registerDefinitionPatternMatcherFactory(PATTERN_REGEXP, regexpFactory);
+ resolver.registerDefinitionPatternMatcherFactory("WILDCARD", wildcardFactory);
+ resolver.registerDefinitionPatternMatcherFactory("REGEXP", regexpFactory);
return resolver;
}
@Override
- protected List<URL> getSourceURLs(TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) {
- try {
- Set<URL> finalSet = applicationContext.getResources(getTilesDefinitionPattern(applicationContext.getInitParams()));
-
- return URLUtil.getBaseTilesDefinitionURLs(finalSet);
- } catch (IOException e) {
- throw new DefinitionsFactoryException("Cannot load definition URLs", e);
+ 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);
+ }
+ }
}
+
+ return filteredResources;
}
protected String getTilesDefinitionPattern(Map<String, String> params) {
@@ -216,55 +178,40 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
return TILES_DEFAULT_PATTERN;
}
- protected ELAttributeEvaluator createELEvaluator(TilesApplicationContext applicationContext) {
-
+ protected ELAttributeEvaluator createELEvaluator(ApplicationContext applicationContext) {
ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
- evaluator.setApplicationContext(applicationContext);
JspExpressionFactoryFactory efFactory = new JspExpressionFactoryFactory();
efFactory.setApplicationContext(applicationContext);
evaluator.setExpressionFactory(efFactory.getExpressionFactory());
-
ELResolver elResolver = new CompositeELResolver() {
{
- add(new TilesContextELResolver());
+ 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(new BeanELResolver(false));
+ add(beanElResolver);
}
};
-
evaluator.setResolver(elResolver);
-
return evaluator;
}
protected OGNLAttributeEvaluator createOGNLEvaluator() {
try {
PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class);
- PropertyAccessor mapPropertyAccessor = OgnlRuntime.getPropertyAccessor(Map.class);
- PropertyAccessor applicationContextPropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
- new TilesApplicationContextNestedObjectExtractor(),
- objectPropertyAccessor);
- PropertyAccessor requestScopePropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
- new RequestScopeNestedObjectExtractor(), mapPropertyAccessor);
- PropertyAccessor sessionScopePropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
- new SessionScopeNestedObjectExtractor(), mapPropertyAccessor);
- PropertyAccessor applicationScopePropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
- new ApplicationScopeNestedObjectExtractor(), mapPropertyAccessor);
- PropertyAccessorDelegateFactory<TilesRequestContext> factory =
- new TilesContextPropertyAccessorDelegateFactory(
- objectPropertyAccessor, applicationContextPropertyAccessor,
- requestScopePropertyAccessor, sessionScopePropertyAccessor,
- applicationScopePropertyAccessor);
+ 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(TilesRequestContext.class, tilesRequestAccessor);
+ OgnlRuntime.setPropertyAccessor(Request.class, tilesRequestAccessor);
return new OGNLAttributeEvaluator();
} catch (OgnlException e) {
throw new TilesContainerFactoryException("Cannot initialize OGNL evaluator", e);
http://git-wip-us.apache.org/repos/asf/struts/blob/ace6a5d5/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
----------------------------------------------------------------------
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 0ff33c7..37fe1d1 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
@@ -21,8 +21,8 @@ package org.apache.struts2.tiles;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.factory.AbstractTilesContainerFactory;
+import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.startup.AbstractTilesInitializer;
import javax.servlet.ServletContext;
@@ -32,13 +32,13 @@ public class StrutsTilesInitializer extends AbstractTilesInitializer {
private static final Logger LOG = LogManager.getLogger(StrutsTilesInitializer.class);
@Override
- protected TilesApplicationContext createTilesApplicationContext(TilesApplicationContext preliminaryContext) {
+ protected ApplicationContext createTilesApplicationContext(ApplicationContext preliminaryContext) {
LOG.debug("Initializing Tiles wildcard support ...");
return new StrutsWildcardServletTilesApplicationContext((ServletContext) preliminaryContext.getContext());
}
@Override
- protected AbstractTilesContainerFactory createContainerFactory(TilesApplicationContext context) {
+ protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext context) {
LOG.trace("Creating dedicated Struts factory to create Tiles container");
return new StrutsTilesContainerFactory();
}
http://git-wip-us.apache.org/repos/asf/struts/blob/ace6a5d5/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
index 2328f06..d942e96 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
@@ -24,20 +24,24 @@ 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.servlet.context.ServletTilesApplicationContext;
+import org.apache.logging.log4j.message.MessageFormatMessage;
+import org.apache.tiles.request.ApplicationResource;
+import org.apache.tiles.request.locale.URLApplicationResource;
+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.URL;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
-public class StrutsWildcardServletTilesApplicationContext extends ServletTilesApplicationContext {
+public class StrutsWildcardServletTilesApplicationContext extends ServletApplicationContext {
private static final Logger LOG = LogManager.getLogger(StrutsWildcardServletTilesApplicationContext.class);
@@ -70,36 +74,42 @@ public class StrutsWildcardServletTilesApplicationContext extends ServletTilesAp
finder = new ResourceFinder(urls.toArray(new URL[urls.size()]));
}
- public Set<URL> getResources(String path) throws IOException {
- Set<URL> resources = new HashSet<>();
+ public Collection<ApplicationResource> getResources(String path) {
+ Set<ApplicationResource> resources = new HashSet<>();
if (path.startsWith("/")) {
- LOG.trace("Using ServletContext to load resource #0", path);
- URL resource = getResource(path);
+ LOG.trace("Using ServletContext to load resource {}", path);
+ ApplicationResource resource = getResource(path);
if (resource != null) {
resources.add(resource);
}
}
- resources.addAll(findResources(path));
+
+ try {
+ resources.addAll(findResources(path));
+ } catch (IOException e) {
+ LOG.error(new MessageFormatMessage("Cannot find resources for [{}]", path), e);
+ }
return resources;
}
- protected Set<URL> findResources(String path) throws IOException {
- Set<URL> resources = new HashSet<>();
+ protected Set<ApplicationResource> findResources(String path) throws IOException {
+ Set<ApplicationResource> resources = new HashSet<>();
- LOG.trace("Using ResourceFinder to find matches for #0", path);
+ 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()) {
- resources.add(matches.get(resource));
+ URL url = matches.get(resource);
+ resources.add(new URLApplicationResource("", url));
}
}
- LOG.trace("Found resources #0 for path #1", resources, path);
+ LOG.trace("Found resources {} for path {}", resources, path);
return resources;
}
[14/30] struts git commit: Adds missing Tiles API dependency
Posted by lu...@apache.org.
Adds missing Tiles API dependency
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/4638b334
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/4638b334
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/4638b334
Branch: refs/heads/master
Commit: 4638b3345757b900edead4a5e4de4c3d37c0eafe
Parents: b675844
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 10:13:38 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 10:13:38 2016 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 4 ++++
pom.xml | 5 +++++
2 files changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/4638b334/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index be39762..09cd71e 100644
--- a/plugins/tiles/pom.xml
+++ b/plugins/tiles/pom.xml
@@ -36,6 +36,10 @@
<dependencies>
<dependency>
<groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/struts/blob/4638b334/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b468f92..0955de9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -605,6 +605,11 @@
<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>
[19/30] struts git commit: Renames class to match pattern used in
Tiles
Posted by lu...@apache.org.
Renames class to match pattern used in Tiles
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6f98d776
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6f98d776
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6f98d776
Branch: refs/heads/master
Commit: 6f98d776c398a036c563e863eacd59dedc9cd375
Parents: e56d8b2
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 22:16:06 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 22:16:06 2016 +0100
----------------------------------------------------------------------
.../struts2/tiles/StrutsTilesInitializer.java | 2 +-
...StrutsWildcardServletApplicationContext.java | 117 +++++++++++++++++++
...sWildcardServletTilesApplicationContext.java | 116 ------------------
3 files changed, 118 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/6f98d776/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
----------------------------------------------------------------------
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 37fe1d1..d0f32f0 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
@@ -34,7 +34,7 @@ public class StrutsTilesInitializer extends AbstractTilesInitializer {
@Override
protected ApplicationContext createTilesApplicationContext(ApplicationContext preliminaryContext) {
LOG.debug("Initializing Tiles wildcard support ...");
- return new StrutsWildcardServletTilesApplicationContext((ServletContext) preliminaryContext.getContext());
+ return new StrutsWildcardServletApplicationContext((ServletContext) preliminaryContext.getContext());
}
@Override
http://git-wip-us.apache.org/repos/asf/struts/blob/6f98d776/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..abd78a2
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.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.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.logging.log4j.message.MessageFormatMessage;
+import org.apache.tiles.request.ApplicationResource;
+import org.apache.tiles.request.locale.URLApplicationResource;
+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.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(new MessageFormatMessage("Cannot find resources for [{}]", path), e);
+ }
+
+ return resources;
+ }
+
+ 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 URLApplicationResource(url.getPath(), url));
+ }
+ }
+
+ LOG.trace("Found resources {} for path {}", resources, path);
+ return resources;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/6f98d776/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
deleted file mode 100644
index d942e96..0000000
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.logging.log4j.message.MessageFormatMessage;
-import org.apache.tiles.request.ApplicationResource;
-import org.apache.tiles.request.locale.URLApplicationResource;
-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.URL;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-public class StrutsWildcardServletTilesApplicationContext extends ServletApplicationContext {
-
- private static final Logger LOG = LogManager.getLogger(StrutsWildcardServletTilesApplicationContext.class);
-
- private ResourceFinder finder;
-
- public StrutsWildcardServletTilesApplicationContext(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(new MessageFormatMessage("Cannot find resources for [{}]", path), e);
- }
-
- return resources;
- }
-
- 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 URLApplicationResource("", url));
- }
- }
-
- LOG.trace("Found resources {} for path {}", resources, path);
- return resources;
- }
-
-}
[05/30] struts git commit: Updates Portal Tiles integration
Posted by lu...@apache.org.
Updates Portal Tiles integration
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6edc0ff5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6edc0ff5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6edc0ff5
Branch: refs/heads/master
Commit: 6edc0ff5e0410651f7055654116c3346aeaa4ee5
Parents: 26f153d
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:37:42 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Nov 25 20:37:42 2015 +0100
----------------------------------------------------------------------
plugins/portlet-tiles/pom.xml | 4 ++++
.../struts2/views/tiles/PortletTilesResult.java | 25 +++++++-------------
pom.xml | 5 ++++
3 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/6edc0ff5/plugins/portlet-tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml
index bb8b6e1..9e9a81f 100644
--- a/plugins/portlet-tiles/pom.xml
+++ b/plugins/portlet-tiles/pom.xml
@@ -43,6 +43,10 @@
<artifactId>struts2-portlet-plugin</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-portlet</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/struts/blob/6edc0ff5/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
index d10693c..736fb85 100644
--- a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
+++ b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
@@ -9,6 +9,7 @@ import org.apache.struts2.portlet.context.PortletActionContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.TilesException;
import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.portlet.context.PortletUtil;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
@@ -19,11 +20,13 @@ import java.io.IOException;
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 +36,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,15 +44,10 @@ 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);
+ TilesContainer container = PortletUtil.getContainer(PortletActionContext.getPortletContext());
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
@@ -60,14 +55,10 @@ public class PortletTilesResult extends ServletDispatcherResult {
container.render(location, request, response);
}
- /**
- * @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);
http://git-wip-us.apache.org/repos/asf/struts/blob/6edc0ff5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 098044d..def2539 100644
--- a/pom.xml
+++ b/pom.xml
@@ -616,6 +616,11 @@
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-portlet</artifactId>
+ <version>${tiles.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${tiles.version}</version>
<scope>runtime</scope>
[17/30] struts git commit: Migrates tiles-portlet to the same version
Posted by lu...@apache.org.
Migrates tiles-portlet to the same version
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/33edfffb
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/33edfffb
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/33edfffb
Branch: refs/heads/master
Commit: 33edfffbe256e071fc33355518f24457da815a8b
Parents: c07020c
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 10:36:46 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 10:36:46 2016 +0100
----------------------------------------------------------------------
plugins/portlet-tiles/pom.xml | 2 +-
.../struts2/views/tiles/PortletTilesResult.java | 50 +++++++++++++++-----
pom.xml | 5 +-
3 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/33edfffb/plugins/portlet-tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml
index 9e9a81f..8b710b2 100644
--- a/plugins/portlet-tiles/pom.xml
+++ b/plugins/portlet-tiles/pom.xml
@@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
- <artifactId>tiles-portlet</artifactId>
+ <artifactId>tiles-request-portlet</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
http://git-wip-us.apache.org/repos/asf/struts/blob/33edfffb/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
index 83fcd4e..f12274b 100644
--- a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
+++ b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
@@ -22,22 +22,20 @@
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.portlet.context.PortletUtil;
+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;
/**
@@ -68,12 +66,15 @@ public class PortletTilesResult extends ServletDispatcherResult {
protected void executeRenderResult(String location) throws TilesException {
setLocation(location);
- TilesContainer container = PortletUtil.getContainer(PortletActionContext.getPortletContext());
+ 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);
}
protected void executeActionResult(String location, ActionInvocation invocation) {
@@ -87,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);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/struts/blob/33edfffb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0955de9..14360e4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,6 +89,7 @@
<asm.version>3.3</asm.version>
<asm5.version>5.0.2</asm5.version>
<tiles.version>3.0.5</tiles.version>
+ <tiles-request.version>1.0.6</tiles-request.version>
<log4j2.version>2.3</log4j2.version>
<!-- SCM Site Configuration -->
@@ -620,8 +621,8 @@
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
- <artifactId>tiles-portlet</artifactId>
- <version>${tiles.version}</version>
+ <artifactId>tiles-request-portlet</artifactId>
+ <version>${tiles-request.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
[25/30] struts git commit: Uses existing constants instead of literals
Posted by lu...@apache.org.
Uses existing constants instead of literals
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/0e85da62
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/0e85da62
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/0e85da62
Branch: refs/heads/master
Commit: 0e85da62282cbf884d058b7850eda38f8017f36e
Parents: b5c96a5
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Jan 15 08:44:25 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Fri Jan 15 08:44:25 2016 +0100
----------------------------------------------------------------------
.../org/apache/struts2/tiles/StrutsTilesContainerFactory.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/0e85da62/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 2c9b094..57594af 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
@@ -149,8 +149,8 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
DefinitionPatternMatcherFactory regexpFactory = new RegexpDefinitionPatternMatcherFactory();
PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<>();
- resolver.registerDefinitionPatternMatcherFactory("WILDCARD", wildcardFactory);
- resolver.registerDefinitionPatternMatcherFactory("REGEXP", regexpFactory);
+ resolver.registerDefinitionPatternMatcherFactory(PATTERN_WILDCARD, wildcardFactory);
+ resolver.registerDefinitionPatternMatcherFactory(PATTERN_REGEXP, regexpFactory);
return resolver;
}
[07/30] struts git commit: Registers Tiles model
Posted by lu...@apache.org.
Registers Tiles model
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/388861ff
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/388861ff
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/388861ff
Branch: refs/heads/master
Commit: 388861ff073f54f7959a35cc205b264237d043d0
Parents: 27ad6cb
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Nov 27 13:36:52 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Fri Nov 27 13:36:52 2015 +0100
----------------------------------------------------------------------
.../StrutsFreeMarkerAttributeRenderer.java | 27 +++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/388861ff/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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 032f7e6..849053a 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
@@ -23,18 +23,25 @@ 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.Attribute;
import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.freemarker.template.TilesFMModelRepository;
import org.apache.tiles.impl.InvalidTemplateException;
import org.apache.tiles.renderer.impl.AbstractTypeDetectingAttributeRenderer;
import org.apache.tiles.servlet.context.ServletTilesRequestContext;
import org.apache.tiles.servlet.context.ServletUtil;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@@ -55,7 +62,8 @@ public class StrutsFreeMarkerAttributeRenderer extends AbstractTypeDetectingAttr
if (ctx == null) {
throw new ConfigurationException("There is no ActionContext for current request!");
}
- ActionInvocation invocation = ctx.getActionInvocation();
+
+ registerTilesBeanModel(ctx);
String include = (String) value;
FreemarkerResult result = new FreemarkerResult(include);
@@ -65,6 +73,7 @@ public class StrutsFreeMarkerAttributeRenderer extends AbstractTypeDetectingAttr
container.inject(result);
try {
+ ActionInvocation invocation = ctx.getActionInvocation();
result.doExecute(include, invocation);
} catch (TemplateException e) {
LOG.error("Exception was thrown during rendering value {}: {}", value, e.getMessage());
@@ -88,4 +97,20 @@ public class StrutsFreeMarkerAttributeRenderer extends AbstractTypeDetectingAttr
return false;
}
+ /**
+ * 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);
+ }
+
}
[24/30] struts git commit: Simplifies logic to fetch
HttpServletRequest
Posted by lu...@apache.org.
Simplifies logic to fetch HttpServletRequest
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b5c96a58
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b5c96a58
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b5c96a58
Branch: refs/heads/master
Commit: b5c96a5888eb3a7b7ca6acbd857b38bda51e2f87
Parents: 5bd54cf
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Thu Jan 14 08:17:50 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Thu Jan 14 08:17:50 2016 +0100
----------------------------------------------------------------------
.../tiles/StrutsFreeMarkerAttributeRenderer.java | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/b5c96a58/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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 0b19b1d..5102ead 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
@@ -36,9 +36,8 @@ 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.jsp.JspRequest;
import org.apache.tiles.request.render.Renderer;
-import org.apache.tiles.request.servlet.ServletRequest;
+import org.apache.tiles.request.servlet.ServletUtil;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -81,18 +80,10 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
* or a ServletRequest (FreeMarker)
*/
protected ActionContext readActionContext(Request request) {
- ActionContext ctx = null;
-
LOG.debug("Obtaining HttpServletRequest based on [{}]", request.getClass().getName());
- if (request instanceof ServletRequest) {
- HttpServletRequest httpRequest = ((ServletRequest) request).getRequest();
- ctx = ServletActionContext.getActionContext(httpRequest);
- }
- if (request instanceof JspRequest) {
- HttpServletRequest httpRequest = (HttpServletRequest) ((JspRequest) request).getPageContext().getRequest();
- ctx = ServletActionContext.getActionContext(httpRequest);
- }
+ HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
+ ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
if (ctx == null) {
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
[06/30] struts git commit: Adds missing header with license
Posted by lu...@apache.org.
Adds missing header with license
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/27ad6cb1
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/27ad6cb1
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/27ad6cb1
Branch: refs/heads/master
Commit: 27ad6cb13e9fa75d48f8e5cf26687b49af9ed213
Parents: 6edc0ff
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:54:39 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Nov 25 20:54:39 2015 +0100
----------------------------------------------------------------------
.../struts2/views/tiles/PortletTilesResult.java | 21 ++++++++++++++++++++
.../StrutsFreeMarkerAttributeRenderer.java | 19 ++++++++++++++++++
.../tiles/StrutsTilesContainerFactory.java | 2 --
3 files changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/27ad6cb1/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
index 736fb85..83fcd4e 100644
--- a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
+++ b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
@@ -1,3 +1,24 @@
+/*
+ * $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;
http://git-wip-us.apache.org/repos/asf/struts/blob/27ad6cb1/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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 e2669c7..032f7e6 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
@@ -1,3 +1,22 @@
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/struts/blob/27ad6cb1/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 4c5871d..1b01a8d 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
@@ -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
[08/30] struts git commit: Fixes dependency clash
Posted by lu...@apache.org.
Fixes dependency clash
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6622fab2
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6622fab2
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6622fab2
Branch: refs/heads/master
Commit: 6622fab25bee1dae9085cca56b87711f3197916d
Parents: 388861f
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Nov 27 16:09:37 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Fri Nov 27 16:09:37 2015 +0100
----------------------------------------------------------------------
apps/showcase/pom.xml | 5 -----
plugins/bean-validation/pom.xml | 1 -
plugins/tiles/pom.xml | 7 +++----
pom.xml | 7 +++----
4 files changed, 6 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/6622fab2/apps/showcase/pom.xml
----------------------------------------------------------------------
diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml
index 7173275..4e6044b 100644
--- a/apps/showcase/pom.xml
+++ b/apps/showcase/pom.xml
@@ -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-->
http://git-wip-us.apache.org/repos/asf/struts/blob/6622fab2/plugins/bean-validation/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml
index b7318ef..f2500c5 100644
--- a/plugins/bean-validation/pom.xml
+++ b/plugins/bean-validation/pom.xml
@@ -58,7 +58,6 @@
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
- <version>3.0.0</version>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/struts/blob/6622fab2/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 57d083f..45a9b7e 100644
--- a/plugins/tiles/pom.xml
+++ b/plugins/tiles/pom.xml
@@ -73,11 +73,10 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <scope>provided</scope>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.el</artifactId>
+ <optional>true</optional>
</dependency>
-
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
http://git-wip-us.apache.org/repos/asf/struts/blob/6622fab2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index def2539..d5489ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -577,10 +577,9 @@
</dependency>
<dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.el</artifactId>
+ <version>3.0.0</version>
</dependency>
<dependency>
[12/30] struts git commit: Upgrade Tiles dependencies
Posted by lu...@apache.org.
Upgrade Tiles dependencies
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/af82d23c
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/af82d23c
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/af82d23c
Branch: refs/heads/master
Commit: af82d23c95f592bac84f1cac105bc00163c53b4d
Parents: 47ecd00
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 08:51:14 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 08:51:14 2016 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 13 -------------
pom.xml | 13 +------------
2 files changed, 1 insertion(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/af82d23c/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 45a9b7e..be39762 100644
--- a/plugins/tiles/pom.xml
+++ b/plugins/tiles/pom.xml
@@ -49,14 +49,6 @@
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
- <artifactId>tiles-servlet-wildcard</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tiles</groupId>
- <artifactId>tiles-jsp</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tiles</groupId>
<artifactId>tiles-freemarker</artifactId>
</dependency>
<dependency>
@@ -68,11 +60,6 @@
<artifactId>tiles-el</artifactId>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/struts/blob/af82d23c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d5489ec..b468f92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@
<ognl.version>3.1.1</ognl.version>
<asm.version>3.3</asm.version>
<asm5.version>5.0.2</asm5.version>
- <tiles.version>2.2.2</tiles.version>
+ <tiles.version>3.0.5</tiles.version>
<log4j2.version>2.3</log4j2.version>
<!-- SCM Site Configuration -->
@@ -622,17 +622,6 @@
<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-servlet-wildcard</artifactId>
- <version>${tiles.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tiles</groupId>
- <artifactId>tiles-jsp</artifactId>
- <version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
[20/30] struts git commit: Adds missing dependencies to tiles-request
Posted by lu...@apache.org.
Adds missing dependencies to tiles-request
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b417894e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b417894e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b417894e
Branch: refs/heads/master
Commit: b417894ebc09cdbd2a64d30734ed33cae06e219f
Parents: 6f98d77
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Jan 13 12:04:43 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Jan 13 12:04:43 2016 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 18 +++++++++++++++++-
pom.xml | 15 +++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/b417894e/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 09cd71e..0b964af 100644
--- a/plugins/tiles/pom.xml
+++ b/plugins/tiles/pom.xml
@@ -48,8 +48,19 @@
</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>
@@ -68,6 +79,11 @@
<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>
http://git-wip-us.apache.org/repos/asf/struts/blob/b417894e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1e0f708..5d836d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -626,6 +626,21 @@
</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>
</dependency>
[09/30] struts git commit: Drops Tiles 3 plugin
Posted by lu...@apache.org.
Drops Tiles 3 plugin
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/2d0fe9f7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/2d0fe9f7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/2d0fe9f7
Branch: refs/heads/master
Commit: 2d0fe9f742c9add4a1803d3165a3ed906551dc45
Parents: 6622fab
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 08:19:26 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 08:19:26 2016 +0100
----------------------------------------------------------------------
plugins/tiles3/pom.xml | 60 -------
.../apache/struts2/views/tiles/TilesResult.java | 81 ---------
plugins/tiles3/src/main/resources/LICENSE.txt | 174 -------------------
plugins/tiles3/src/main/resources/NOTICE.txt | 5 -
.../tiles3/src/main/resources/struts-plugin.xml | 34 ----
plugins/tiles3/src/site/site.xml | 57 ------
6 files changed, 411 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/2d0fe9f7/plugins/tiles3/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles3/pom.xml b/plugins/tiles3/pom.xml
deleted file mode 100644
index a029dff..0000000
--- a/plugins/tiles3/pom.xml
+++ /dev/null
@@ -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>
http://git-wip-us.apache.org/repos/asf/struts/blob/2d0fe9f7/plugins/tiles3/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/tiles3/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles3/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
deleted file mode 100644
index 6bc15bb..0000000
--- a/plugins/tiles3/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ /dev/null
@@ -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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/2d0fe9f7/plugins/tiles3/src/main/resources/LICENSE.txt
----------------------------------------------------------------------
diff --git a/plugins/tiles3/src/main/resources/LICENSE.txt b/plugins/tiles3/src/main/resources/LICENSE.txt
deleted file mode 100644
index dd5b3a5..0000000
--- a/plugins/tiles3/src/main/resources/LICENSE.txt
+++ /dev/null
@@ -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.
http://git-wip-us.apache.org/repos/asf/struts/blob/2d0fe9f7/plugins/tiles3/src/main/resources/NOTICE.txt
----------------------------------------------------------------------
diff --git a/plugins/tiles3/src/main/resources/NOTICE.txt b/plugins/tiles3/src/main/resources/NOTICE.txt
deleted file mode 100644
index bfba90c..0000000
--- a/plugins/tiles3/src/main/resources/NOTICE.txt
+++ /dev/null
@@ -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/).
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/2d0fe9f7/plugins/tiles3/src/main/resources/struts-plugin.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles3/src/main/resources/struts-plugin.xml b/plugins/tiles3/src/main/resources/struts-plugin.xml
deleted file mode 100644
index 0018a5f..0000000
--- a/plugins/tiles3/src/main/resources/struts-plugin.xml
+++ /dev/null
@@ -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>
http://git-wip-us.apache.org/repos/asf/struts/blob/2d0fe9f7/plugins/tiles3/src/site/site.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles3/src/site/site.xml b/plugins/tiles3/src/site/site.xml
deleted file mode 100644
index 07a667e..0000000
--- a/plugins/tiles3/src/site/site.xml
+++ /dev/null
@@ -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>
[26/30] struts git commit: Extracts constants representing expression
languages
Posted by lu...@apache.org.
Extracts constants representing expression languages
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f645c91e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f645c91e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f645c91e
Branch: refs/heads/master
Commit: f645c91ee66416e964b5823f8c9cdc48ba8ef53c
Parents: 0e85da6
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Jan 15 08:45:54 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Fri Jan 15 08:45:54 2016 +0100
----------------------------------------------------------------------
.../apache/struts2/tiles/StrutsTilesContainerFactory.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/f645c91e/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 57594af..8403610 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
@@ -97,6 +97,12 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
*/
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);
@@ -137,8 +143,8 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
LocaleResolver resolver) {
BasicAttributeEvaluatorFactory attributeEvaluatorFactory = new BasicAttributeEvaluatorFactory(new DirectAttributeEvaluator());
- attributeEvaluatorFactory.registerAttributeEvaluator("OGNL", createOGNLEvaluator());
- attributeEvaluatorFactory.registerAttributeEvaluator("EL", createELEvaluator(applicationContext));
+ attributeEvaluatorFactory.registerAttributeEvaluator(OGNL, createOGNLEvaluator());
+ attributeEvaluatorFactory.registerAttributeEvaluator(EL, createELEvaluator(applicationContext));
return attributeEvaluatorFactory;
}
[16/30] struts git commit: Uses new way to access TileContainer
Posted by lu...@apache.org.
Uses new way to access TileContainer
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c07020cb
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c07020cb
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c07020cb
Branch: refs/heads/master
Commit: c07020cb7cc1d1a8eb15cacc7f62be3a864474f8
Parents: ace6a5d
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 10:14:11 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 10:14:11 2016 +0100
----------------------------------------------------------------------
.../apache/struts2/views/tiles/TilesResult.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/c07020cb/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
----------------------------------------------------------------------
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 72d7916..a402869 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
@@ -30,7 +30,11 @@ import org.apache.struts2.result.ServletDispatcherResult;
import org.apache.tiles.TilesContainer;
import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.tiles.servlet.context.ServletUtil;
+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 -->
@@ -99,11 +103,14 @@ public class TilesResult extends ServletDispatcherResult {
ServletContext servletContext = ServletActionContext.getServletContext();
- TilesContainer container = ServletUtil.getContainer(servletContext);
+ ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
+ TilesContainer container = TilesAccess.getContainer(applicationContext);
- HttpServletRequest request = ServletActionContext.getRequest();
- HttpServletResponse response = ServletActionContext.getResponse();
+ HttpServletRequest httpRequest = ServletActionContext.getRequest();
+ HttpServletResponse httpResponse = ServletActionContext.getResponse();
- container.render(location, request, response);
+ Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
+
+ container.render(location, request);
}
}
[18/30] struts git commit: Merge remote-tracking branch
'upstream/master' into upgrade-tiles-plugin
Posted by lu...@apache.org.
Merge remote-tracking branch 'upstream/master' into upgrade-tiles-plugin
Conflicts:
pom.xml
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e56d8b2e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e56d8b2e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e56d8b2e
Branch: refs/heads/master
Commit: e56d8b2e072f59cf14c590a614e9dfdde10162ad
Parents: 33edfff 460faa3
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 10:42:04 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 10:42:04 2016 +0100
----------------------------------------------------------------------
.../src/main/webapp/WEB-INF/view/helloWorld.vm | 2 +-
apps/portlet/src/main/webapp/tiles/footer.ftl | 2 +-
apps/portlet/src/main/webapp/tiles/footer.jsp | 2 +-
apps/portlet/src/main/webapp/tiles/index.jsp | 2 +-
.../webapp/WEB-INF/empmanager/editSkill.jsp | 6 +--
.../webapp/WEB-INF/hangman/hangmanNonAjax.ftl | 52 ++++++++++----------
.../hangman/updateCharacterAvailable.ftl | 24 ++++-----
.../webapp/WEB-INF/hangman/updateGuessLeft.ftl | 4 +-
.../webapp/WEB-INF/hangman/updateScaffold.ftl | 4 +-
.../WEB-INF/hangman/updateVocabCharacters.ftl | 12 ++---
.../main/webapp/WEB-INF/person/edit-person.jsp | 6 +--
.../main/webapp/WEB-INF/person/list-people.ftl | 6 +--
.../main/webapp/WEB-INF/person/new-person.ftl | 6 +--
.../non-ui/actionPrefix/actionPrefixExample.ftl | 2 +-
.../iteratorTag/appendIteratorTagDemoResult.jsp | 2 +-
.../main/webapp/WEB-INF/example/HelloWorld.jsp | 4 +-
.../src/main/webapp/WEB-INF/content/hello.jsp | 4 +-
.../src/main/webapp/WEB-INF/view/index.jsp | 2 +-
assembly/pom.xml | 6 +++
assembly/src/main/assembly/all.xml | 5 +-
assembly/src/main/assembly/apps.xml | 5 +-
assembly/src/main/assembly/docs.xml | 4 +-
assembly/src/main/assembly/lib.xml | 5 +-
assembly/src/main/assembly/min-lib.xml | 49 ++++++++++++++++++
assembly/src/main/assembly/src.xml | 5 +-
.../com/opensymphony/xwork2/ognl/OgnlUtil.java | 8 +--
.../xwork2/ognl/OgnlValueStack.java | 12 ++---
.../DefaultExcludedPatternsChecker.java | 1 +
.../xwork2/util/AnnotationUtils.java | 10 ++--
.../opensymphony/xwork2/util/CompoundRoot.java | 9 ++--
.../validator/validators/EmailValidator.java | 2 +-
.../struts2/components/IteratorComponent.java | 2 +-
.../JakartaStreamMultiPartRequest.java | 10 ++++
.../apache/struts2/result/PostbackResult.java | 5 ++
.../resources/template/simple/doubleselect.ftl | 2 +-
.../providers/XmlConfigurationProviderTest.java | 16 ++++++
.../interceptor/ParametersInterceptorTest.java | 9 ++--
.../components/IteratorComponentTest.java | 38 ++++++++++++++
.../providers/xwork-test-include-wildcard.xml | 8 +++
.../resources/config-browser/actionNames.ftl | 2 +-
.../resources/config-browser/page-header.ftl | 8 +--
.../resources/config-browser/showConfig.ftl | 2 +-
.../resources/config-browser/tigris-macros.ftl | 2 +-
plugins/jasperreports/pom.xml | 4 +-
.../jasperreports/JasperReportsResult.java | 8 ++-
.../org/apache/struts2/json/JSONReader.java | 15 ++++--
.../org/apache/struts2/json/JSONResult.java | 2 +-
.../org/apache/struts2/json/JSONResultTest.java | 24 ++++-----
.../struts2/rest/DefaultHttpHeadersTest.java | 16 ++++--
pom.xml | 4 +-
50 files changed, 304 insertions(+), 136 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/e56d8b2e/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index 14360e4,862630b..1e0f708
--- a/pom.xml
+++ b/pom.xml
@@@ -85,12 -85,11 +85,12 @@@
<properties>
<currentVersion>${project.version}</currentVersion>
<struts2.springPlatformVersion>4.1.6.RELEASE</struts2.springPlatformVersion>
- <ognl.version>3.1.1</ognl.version>
+ <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.3</log4j2.version>
+ <log4j2.version>2.5</log4j2.version>
<!-- SCM Site Configuration -->
<site.mainDirectory>${project.build.directory}/site</site.mainDirectory>
[22/30] struts git commit: Overrides method to use defined base
instead of fetching it again
Posted by lu...@apache.org.
Overrides method to use defined base instead of fetching it again
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/66d29d42
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/66d29d42
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/66d29d42
Branch: refs/heads/master
Commit: 66d29d42c388bc17561d1b3d82f447426dda8db5
Parents: 334e6ca
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Jan 13 12:05:58 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Jan 13 12:05:58 2016 +0100
----------------------------------------------------------------------
.../struts2/tiles/StrutsWildcardServletApplicationContext.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/66d29d42/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
----------------------------------------------------------------------
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 abd78a2..b8f10f9 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
@@ -95,6 +95,10 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC
return resources;
}
+ public ApplicationResource getResource(ApplicationResource base, Locale locale) {
+ return base;
+ }
+
protected Set<ApplicationResource> findResources(String path) throws IOException {
Set<ApplicationResource> resources = new HashSet<>();
[04/30] struts git commit: Replaces call to deprecated api
Posted by lu...@apache.org.
Replaces call to deprecated api
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/26f153d2
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/26f153d2
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/26f153d2
Branch: refs/heads/master
Commit: 26f153d262f7a4dfb767c391afece8ac1d9e1c0d
Parents: 24a5bce
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:29:43 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Nov 25 20:29:43 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/struts2/views/tiles/TilesResult.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/26f153d2/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
----------------------------------------------------------------------
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 490de79..72d7916 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
@@ -28,9 +28,9 @@ 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.servlet.context.ServletUtil;
/**
* <!-- START SNIPPET: description -->
@@ -84,6 +84,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,7 +98,8 @@ public class TilesResult extends ServletDispatcherResult {
setLocation(location);
ServletContext servletContext = ServletActionContext.getServletContext();
- TilesContainer container = TilesAccess.getContainer(servletContext);
+
+ TilesContainer container = ServletUtil.getContainer(servletContext);
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
[13/30] struts git commit: Ports solution to resolve problem with EL
functions
Posted by lu...@apache.org.
Ports solution to resolve problem with EL functions
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b675844a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b675844a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b675844a
Branch: refs/heads/master
Commit: b675844a8f0de848d200439ed01ebbb532ca9b53
Parents: af82d23
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 08:51:34 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 08:51:34 2016 +0100
----------------------------------------------------------------------
.../java/org/apache/struts2/views/freemarker/FreemarkerManager.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/b675844a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
index ddc7669..3323302 100644
--- a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
+++ b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
@@ -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);
[27/30] struts git commit: Adds support to use Struts' Locale
Posted by lu...@apache.org.
Adds support to use Struts' Locale
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a42a1731
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a42a1731
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a42a1731
Branch: refs/heads/master
Commit: a42a1731f301a712da3d61f43291c5e1126c50ff
Parents: f645c91
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Jan 15 10:12:15 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Fri Jan 15 10:12:15 2016 +0100
----------------------------------------------------------------------
.../tiles/StrutsTilesContainerFactory.java | 4 ++
.../tiles/StrutsTilesLocaleResolver.java | 54 ++++++++++++++++++++
2 files changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/a42a1731/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 8403610..0cb14f3 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
@@ -161,6 +161,10 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
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()));
http://git-wip-us.apache.org/repos/asf/struts/blob/a42a1731/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesLocaleResolver.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..2c0ef9d
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesLocaleResolver.java
@@ -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();
+ }
+
+}
[28/30] struts git commit: Adds support for I18N
Posted by lu...@apache.org.
Adds support for I18N
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/328da4e2
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/328da4e2
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/328da4e2
Branch: refs/heads/master
Commit: 328da4e2258573acd049cdd3fd5bce2f37869adf
Parents: a42a173
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Jan 15 10:12:25 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Fri Jan 15 10:12:25 2016 +0100
----------------------------------------------------------------------
.../tiles/StrutsApplicationResource.java | 55 ++++++++++++++++++++
...StrutsWildcardServletApplicationContext.java | 15 ++++--
2 files changed, 67 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/328da4e2/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java
new file mode 100644
index 0000000..6884e9a
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java
@@ -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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/328da4e2/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
----------------------------------------------------------------------
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 b8f10f9..2f67f04 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
@@ -26,13 +26,13 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.MessageFormatMessage;
import org.apache.tiles.request.ApplicationResource;
-import org.apache.tiles.request.locale.URLApplicationResource;
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;
@@ -96,7 +96,16 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC
}
public ApplicationResource getResource(ApplicationResource base, Locale locale) {
- return base;
+ String localePath = base.getLocalePath(locale);
+ if (new File(localePath).exists()) {
+ try {
+ return new StrutsApplicationResource(URI.create("file://" + localePath).toURL());
+ } catch (MalformedURLException e) {
+ LOG.warn(new MessageFormatMessage("Cannot access [{}]", localePath), e);
+ return null;
+ }
+ }
+ return null;
}
protected Set<ApplicationResource> findResources(String path) throws IOException {
@@ -110,7 +119,7 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC
for (String resource : matches.keySet()) {
if (pattern.matcher(resource).matches()) {
URL url = matches.get(resource);
- resources.add(new URLApplicationResource(url.getPath(), url));
+ resources.add(new StrutsApplicationResource(url));
}
}
[21/30] struts git commit: Defines helper method to fetch
ActionContext from request
Posted by lu...@apache.org.
Defines helper method to fetch ActionContext from request
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/334e6ca4
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/334e6ca4
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/334e6ca4
Branch: refs/heads/master
Commit: 334e6ca462ad0cec85de090066ae81e03b199919
Parents: b417894
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Jan 13 12:05:03 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Jan 13 12:05:03 2016 +0100
----------------------------------------------------------------------
.../StrutsFreeMarkerAttributeRenderer.java | 30 +++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/334e6ca4/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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 48592e0..fbc5416 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
@@ -36,7 +36,9 @@ 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.jsp.JspRequest;
import org.apache.tiles.request.render.Renderer;
+import org.apache.tiles.request.servlet.ServletRequest;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -51,10 +53,7 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
if (path != null) {
LOG.trace("Rendering freemarker tile ...");
- ActionContext ctx = ServletActionContext.getActionContext((HttpServletRequest) request);
- if (ctx == null) {
- throw new ConfigurationException("There is no ActionContext for current request!");
- }
+ ActionContext ctx = readActionContext(request);
registerTilesBeanModel(ctx);
@@ -77,6 +76,29 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
}
}
+ /**
+ * Depending how Tiles definition was defined, request can an instance of JspRequest (for JSPs)
+ * or a ServletRequest (FreeMarker)
+ */
+ protected ActionContext readActionContext(Request request) {
+ ActionContext ctx = null;
+
+ if (request instanceof ServletRequest) {
+ HttpServletRequest httpRequest = ((ServletRequest) request).getRequest();
+ ctx = ServletActionContext.getActionContext(httpRequest);
+ }
+ if (request instanceof JspRequest) {
+ HttpServletRequest httpRequest = (HttpServletRequest) ((JspRequest) request).getPageContext().getRequest();
+ ctx = ServletActionContext.getActionContext(httpRequest);
+ }
+
+ if (ctx == null) {
+ throw new ConfigurationException("There is no ActionContext for current request!");
+ }
+
+ return ctx;
+ }
+
@Override
public boolean isRenderable(String path, Request request) {
return path != null && path.startsWith("/") && path.endsWith(".ftl");
[03/30] struts git commit: Drops unused classes
Posted by lu...@apache.org.
Drops unused classes
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/24a5bce6
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/24a5bce6
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/24a5bce6
Branch: refs/heads/master
Commit: 24a5bce6c436ddaea9f65f792b280fdd6f9c4ae3
Parents: 70716e9
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:29:24 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Nov 25 20:29:24 2015 +0100
----------------------------------------------------------------------
.../struts2/tiles/ConfiguredServletContext.java | 187 -------------------
.../tiles/StrutsTilesRequestContext.java | 125 -------------
2 files changed, 312 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/24a5bce6/plugins/tiles/src/main/java/org/apache/struts2/tiles/ConfiguredServletContext.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/ConfiguredServletContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/ConfiguredServletContext.java
deleted file mode 100644
index dfc1408..0000000
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/ConfiguredServletContext.java
+++ /dev/null
@@ -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();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/24a5bce6/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java
deleted file mode 100644
index d9319a4..0000000
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java
+++ /dev/null
@@ -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);
- }
- }
-
-}
[02/30] struts git commit: Re-implements tiles integration based on
new API
Posted by lu...@apache.org.
Re-implements tiles integration based on new API
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/70716e94
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/70716e94
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/70716e94
Branch: refs/heads/master
Commit: 70716e945295526d207cab6c66306a3113f8a333
Parents: 85b2198
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:29:18 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Nov 25 20:29:18 2015 +0100
----------------------------------------------------------------------
.../StrutsFreeMarkerAttributeRenderer.java | 72 +++++
.../tiles/StrutsTilesContainerFactory.java | 266 +++++++++++++++----
.../struts2/tiles/StrutsTilesInitializer.java | 47 ++++
.../struts2/tiles/StrutsTilesListener.java | 56 +---
4 files changed, 350 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/70716e94/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..e2669c7
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
@@ -0,0 +1,72 @@
+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.template.TemplateException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.views.freemarker.FreemarkerResult;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.impl.InvalidTemplateException;
+import org.apache.tiles.renderer.impl.AbstractTypeDetectingAttributeRenderer;
+import org.apache.tiles.servlet.context.ServletTilesRequestContext;
+import org.apache.tiles.servlet.context.ServletUtil;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+public class StrutsFreeMarkerAttributeRenderer extends AbstractTypeDetectingAttributeRenderer {
+
+ private static Logger LOG = LogManager.getLogger(StrutsFreeMarkerAttributeRenderer.class);
+
+ @Override
+ public void write(Object value, Attribute attribute, TilesRequestContext request) throws IOException {
+ if (value != null) {
+ if (value instanceof String) {
+ LOG.trace("Rendering freemarker tile ...");
+
+ ServletTilesRequestContext servletRequest = ServletUtil.getServletRequest(request);
+ HttpServletRequest httpRequest = servletRequest.getRequest();
+
+ ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
+ if (ctx == null) {
+ throw new ConfigurationException("There is no ActionContext for current request!");
+ }
+ ActionInvocation invocation = ctx.getActionInvocation();
+
+ String include = (String) value;
+ FreemarkerResult result = new FreemarkerResult(include);
+ result.setWriter(request.getWriter());
+
+ Container container = ctx.getContainer();
+ container.inject(result);
+
+ try {
+ result.doExecute(include, invocation);
+ } catch (TemplateException e) {
+ LOG.error("Exception was thrown during rendering value {}: {}", value, e.getMessage());
+ throw new InvalidTemplateException(e);
+ }
+ } else {
+ LOG.error("Value {} is not a String, cannot render template!", value);
+ throw new InvalidTemplateException("Cannot render a template that is not a string: " + String.valueOf(value));
+ }
+ } else {
+ LOG.error("Value is null, cannot render template!");
+ throw new InvalidTemplateException("Cannot render a null template");
+ }
+ }
+
+ public boolean isRenderable(Object value, Attribute attribute, TilesRequestContext request) {
+ if (value instanceof String) {
+ String string = (String) value;
+ return string.startsWith("/") && string.endsWith(".ftl");
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/70716e94/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 491ee02..4c5871d 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
@@ -21,73 +21,249 @@
package org.apache.struts2.tiles;
+import ognl.OgnlException;
+import ognl.OgnlRuntime;
+import ognl.PropertyAccessor;
import org.apache.tiles.TilesApplicationContext;
-import org.apache.tiles.TilesException;
-import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.context.ChainedTilesRequestContextFactory;
import org.apache.tiles.context.TilesRequestContext;
-import org.apache.tiles.definition.DefinitionsFactory;
-import org.apache.tiles.factory.TilesContainerFactory;
+import org.apache.tiles.context.TilesRequestContextFactory;
+import org.apache.tiles.definition.DefinitionsFactoryException;
+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.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.freemarker.context.FreeMarkerTilesRequestContextFactory;
import org.apache.tiles.impl.BasicTilesContainer;
-import org.apache.tiles.preparer.PreparerFactory;
+import org.apache.tiles.impl.mgmt.CachingTilesContainer;
+import org.apache.tiles.locale.LocaleResolver;
+import org.apache.tiles.ognl.ApplicationScopeNestedObjectExtractor;
+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.RequestScopeNestedObjectExtractor;
+import org.apache.tiles.ognl.SessionScopeNestedObjectExtractor;
+import org.apache.tiles.ognl.TilesApplicationContextNestedObjectExtractor;
+import org.apache.tiles.ognl.TilesContextPropertyAccessorDelegateFactory;
+import org.apache.tiles.renderer.AttributeRenderer;
+import org.apache.tiles.renderer.TypeDetectingAttributeRenderer;
+import org.apache.tiles.renderer.impl.BasicRendererFactory;
+import org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer;
+import org.apache.tiles.util.URLUtil;
+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.io.IOException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
+/**
+ * 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 {
-public class StrutsTilesContainerFactory extends TilesContainerFactory {
+ /**
+ * The freemarker renderer name.
+ */
+ public static final String FREEMARKER_RENDERER_NAME = "freemarker";
+ /**
+ * Supported pattern types
+ */
+ public static final String PATTERN_WILDCARD = "WILDCARD";
+ public static final String PATTERN_REGEXP = "REGEXP";
@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);
+ protected BasicTilesContainer instantiateContainer(TilesApplicationContext applicationContext) {
+ return new CachingTilesContainer();
+ }
- contextFactory = new StrutsTilesContextFactory(contextFactory);
+ @Override
+ protected List<TilesRequestContextFactory> getTilesRequestContextFactoriesToBeChained(ChainedTilesRequestContextFactory parent) {
- DefinitionsFactory defsFactory =
- (DefinitionsFactory) createFactory(configuration,
- DEFINITIONS_FACTORY_INIT_PARAM);
+ List<TilesRequestContextFactory> factories = super.getTilesRequestContextFactoriesToBeChained(parent);
- PreparerFactory prepFactory =
- (PreparerFactory) createFactory(configuration,
- PREPARER_FACTORY_INIT_PARAM);
+ registerRequestContextFactory(FreeMarkerTilesRequestContextFactory.class.getName(), factories, parent);
- contextFactory.init(configuration);
- TilesApplicationContext tilesContext =
- contextFactory.createApplicationContext(context);
+ return factories;
+ }
+
+ @Override
+ protected void registerAttributeRenderers(
+ BasicRendererFactory rendererFactory,
+ TilesApplicationContext applicationContext,
+ TilesRequestContextFactory contextFactory,
+ TilesContainer container,
+ AttributeEvaluatorFactory attributeEvaluatorFactory) {
- container.setDefinitionsFactory(defsFactory);
- container.setContextFactory(contextFactory);
- container.setPreparerFactory(prepFactory);
- container.setApplicationContext(tilesContext);
+ super.registerAttributeRenderers(
+ rendererFactory,
+ applicationContext,
+ contextFactory,
+ container,
+ attributeEvaluatorFactory);
+
+ StrutsFreeMarkerAttributeRenderer freemarkerRenderer = new StrutsFreeMarkerAttributeRenderer();
+ freemarkerRenderer.setApplicationContext(applicationContext);
+ freemarkerRenderer.setAttributeEvaluatorFactory(attributeEvaluatorFactory);
+ freemarkerRenderer.setRequestContextFactory(contextFactory);
+
+ rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer);
}
- /**
- * Wrapper factory, used to decorate the TilesRequestContext with a
- * FreemarkerResult aware version.
- *
- */
- class StrutsTilesContextFactory implements TilesContextFactory {
+ @Override
+ protected AttributeRenderer createDefaultAttributeRenderer(
+ BasicRendererFactory rendererFactory,
+ TilesApplicationContext applicationContext,
+ TilesRequestContextFactory contextFactory,
+ TilesContainer container,
+ AttributeEvaluatorFactory attributeEvaluatorFactory) {
- private TilesContextFactory factory;
+ ChainedDelegateAttributeRenderer retValue = new ChainedDelegateAttributeRenderer();
- public StrutsTilesContextFactory(TilesContextFactory factory) {
- this.factory = factory;
- }
+ retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
+ .getRenderer(DEFINITION_RENDERER_NAME));
+ retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
+ .getRenderer(FREEMARKER_RENDERER_NAME));
+ retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
+ .getRenderer(TEMPLATE_RENDERER_NAME));
+ retValue.addAttributeRenderer((TypeDetectingAttributeRenderer) rendererFactory
+ .getRenderer(STRING_RENDERER_NAME));
- public void init(Map<String, String> map) {
- factory.init(map);
- }
+ retValue.setApplicationContext(applicationContext);
+ retValue.setRequestContextFactory(contextFactory);
+ retValue.setAttributeEvaluatorFactory(attributeEvaluatorFactory);
+
+ return retValue;
+ }
+
+ @Override
+ protected AttributeEvaluatorFactory createAttributeEvaluatorFactory(
+ TilesApplicationContext applicationContext,
+ TilesRequestContextFactory contextFactory,
+ 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) {
- public TilesApplicationContext createApplicationContext(Object context) {
- return factory.createApplicationContext(context);
+ 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;
+ }
+
+ @Override
+ protected List<URL> getSourceURLs(TilesApplicationContext applicationContext,
+ TilesRequestContextFactory contextFactory) {
+ try {
+ Set<URL> finalSet = new HashSet<>();
+ Set<URL> webINFSet = applicationContext.getResources("/WEB-INF/**/tiles*.xml");
+ Set<URL> metaINFSet = applicationContext.getResources("classpath*:META-INF/**/tiles*.xml");
+
+ if (webINFSet != null) {
+ finalSet.addAll(webINFSet);
+ }
+ if (metaINFSet != null) {
+ finalSet.addAll(metaINFSet);
+ }
+
+ return URLUtil.getBaseTilesDefinitionURLs(finalSet);
+ } catch (IOException e) {
+ throw new DefinitionsFactoryException("Cannot load definition URLs", e);
}
+ }
+
+ protected ELAttributeEvaluator createELEvaluator(TilesApplicationContext applicationContext) {
+
+ ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
+ evaluator.setApplicationContext(applicationContext);
+ JspExpressionFactoryFactory efFactory = new JspExpressionFactoryFactory();
+ efFactory.setApplicationContext(applicationContext);
+ evaluator.setExpressionFactory(efFactory.getExpressionFactory());
- public TilesRequestContext createRequestContext(
- TilesApplicationContext tilesApplicationContext,
- Object... requestItems) {
- TilesRequestContext context = factory.createRequestContext(tilesApplicationContext, requestItems);
- return new StrutsTilesRequestContext(context);
+ ELResolver elResolver = new CompositeELResolver() {
+ {
+ add(new TilesContextELResolver());
+ add(new TilesContextBeanELResolver());
+ add(new ArrayELResolver(false));
+ add(new ListELResolver(false));
+ add(new MapELResolver(false));
+ add(new ResourceBundleELResolver());
+ add(new BeanELResolver(false));
+ }
+ };
+
+ evaluator.setResolver(elResolver);
+
+ return evaluator;
+ }
+
+ protected OGNLAttributeEvaluator createOGNLEvaluator() {
+ try {
+ PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class);
+ PropertyAccessor mapPropertyAccessor = OgnlRuntime.getPropertyAccessor(Map.class);
+ PropertyAccessor applicationContextPropertyAccessor =
+ new NestedObjectDelegatePropertyAccessor<>(
+ new TilesApplicationContextNestedObjectExtractor(),
+ objectPropertyAccessor);
+ PropertyAccessor requestScopePropertyAccessor =
+ new NestedObjectDelegatePropertyAccessor<>(
+ new RequestScopeNestedObjectExtractor(), mapPropertyAccessor);
+ PropertyAccessor sessionScopePropertyAccessor =
+ new NestedObjectDelegatePropertyAccessor<>(
+ new SessionScopeNestedObjectExtractor(), mapPropertyAccessor);
+ PropertyAccessor applicationScopePropertyAccessor =
+ new NestedObjectDelegatePropertyAccessor<>(
+ new ApplicationScopeNestedObjectExtractor(), mapPropertyAccessor);
+ PropertyAccessorDelegateFactory<TilesRequestContext> factory =
+ new TilesContextPropertyAccessorDelegateFactory(
+ objectPropertyAccessor, applicationContextPropertyAccessor,
+ requestScopePropertyAccessor, sessionScopePropertyAccessor,
+ applicationScopePropertyAccessor);
+ PropertyAccessor tilesRequestAccessor = new DelegatePropertyAccessor<>(factory);
+ OgnlRuntime.setPropertyAccessor(TilesRequestContext.class, tilesRequestAccessor);
+ return new OGNLAttributeEvaluator();
+ } catch (OgnlException e) {
+ throw new TilesContainerFactoryException("Cannot initialize OGNL evaluator", e);
}
}
-}
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/70716e94/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..b2e2700
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
@@ -0,0 +1,47 @@
+/*
+ * 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.TilesApplicationContext;
+import org.apache.tiles.factory.AbstractTilesContainerFactory;
+import org.apache.tiles.servlet.wildcard.WildcardServletTilesApplicationContext;
+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 TilesApplicationContext createTilesApplicationContext(TilesApplicationContext preliminaryContext) {
+ LOG.debug("Initializing Tiles wildcard support ...");
+ return new WildcardServletTilesApplicationContext((ServletContext) preliminaryContext.getContext());
+ }
+
+ @Override
+ protected AbstractTilesContainerFactory createContainerFactory(TilesApplicationContext context) {
+ LOG.trace("Creating dedicated Struts factory to create Tiles container");
+ return new StrutsTilesContainerFactory();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/70716e94/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java
----------------------------------------------------------------------
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 b04908a..cf874b1 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
@@ -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());
- }
-
- 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);
+ @Override
+ protected TilesInitializer createTilesInitializer() {
+ LOG.info("Starting Struts Tiles 2 integration ...");
+ return new StrutsTilesInitializer();
}
-
- protected ServletContext decorate(ServletContext context) {
- return new ConfiguredServletContext(context, INIT);
- }
-
-}
+}
\ No newline at end of file
[23/30] struts git commit: Extends logging
Posted by lu...@apache.org.
Extends logging
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5bd54cf8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5bd54cf8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5bd54cf8
Branch: refs/heads/master
Commit: 5bd54cf8ac40775e97a8dde9a0cd78ddcd2b8339
Parents: 66d29d4
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Jan 13 17:22:36 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Wed Jan 13 17:22:36 2016 +0100
----------------------------------------------------------------------
.../struts2/tiles/StrutsFreeMarkerAttributeRenderer.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/5bd54cf8/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
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 fbc5416..0b19b1d 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
@@ -51,7 +51,7 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
@Override
public void render(String path, Request request) throws IOException {
if (path != null) {
- LOG.trace("Rendering freemarker tile ...");
+ LOG.trace("Rendering freemarker tile [{}]", path);
ActionContext ctx = readActionContext(request);
@@ -83,6 +83,8 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
protected ActionContext readActionContext(Request request) {
ActionContext ctx = null;
+ LOG.debug("Obtaining HttpServletRequest based on [{}]", request.getClass().getName());
+
if (request instanceof ServletRequest) {
HttpServletRequest httpRequest = ((ServletRequest) request).getRequest();
ctx = ServletActionContext.getActionContext(httpRequest);
@@ -93,6 +95,7 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
}
if (ctx == null) {
+ LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
throw new ConfigurationException("There is no ActionContext for current request!");
}
@@ -101,6 +104,7 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
@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");
}
[11/30] struts git commit: Ports solution from 2.3.x branch
Posted by lu...@apache.org.
Ports solution from 2.3.x branch
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/47ecd001
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/47ecd001
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/47ecd001
Branch: refs/heads/master
Commit: 47ecd001ec8b35e4569d43a481e82166eed6cfb1
Parents: 5fe760d
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Tue Jan 12 08:51:03 2016 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Tue Jan 12 08:51:03 2016 +0100
----------------------------------------------------------------------
.../tiles/StrutsTilesContainerFactory.java | 37 ++++---
.../struts2/tiles/StrutsTilesInitializer.java | 3 +-
...sWildcardServletTilesApplicationContext.java | 106 +++++++++++++++++++
3 files changed, 129 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/47ecd001/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
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 1b01a8d..785082b 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
@@ -27,6 +27,7 @@ import org.apache.tiles.TilesContainer;
import org.apache.tiles.context.ChainedTilesRequestContextFactory;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.context.TilesRequestContextFactory;
+import org.apache.tiles.definition.DefinitionsFactory;
import org.apache.tiles.definition.DefinitionsFactoryException;
import org.apache.tiles.definition.pattern.DefinitionPatternMatcherFactory;
import org.apache.tiles.definition.pattern.PatternDefinitionResolver;
@@ -59,6 +60,7 @@ import org.apache.tiles.renderer.AttributeRenderer;
import org.apache.tiles.renderer.TypeDetectingAttributeRenderer;
import org.apache.tiles.renderer.impl.BasicRendererFactory;
import org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer;
+import org.apache.tiles.servlet.context.ServletUtil;
import org.apache.tiles.util.URLUtil;
import javax.el.ArrayELResolver;
@@ -68,9 +70,9 @@ import javax.el.ELResolver;
import javax.el.ListELResolver;
import javax.el.MapELResolver;
import javax.el.ResourceBundleELResolver;
+import javax.servlet.ServletContext;
import java.io.IOException;
import java.net.URL;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -98,9 +100,17 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
public static final String PATTERN_WILDCARD = "WILDCARD";
public static final String PATTERN_REGEXP = "REGEXP";
+ /**
+ * Default pattern to be used to collect Tiles definitions if user didn't configure any
+ */
+ public static final String TILES_DEFAULT_PATTERN = "tiles*.xml";
+
@Override
protected BasicTilesContainer instantiateContainer(TilesApplicationContext applicationContext) {
- return new CachingTilesContainer();
+ CachingTilesContainer tilesContainer = new CachingTilesContainer();
+ ServletContext servletContext = (ServletContext) applicationContext.getContext();
+ ServletUtil.setContainer(servletContext, tilesContainer);
+ return tilesContainer;
}
@Override
@@ -181,7 +191,7 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
DefinitionPatternMatcherFactory wildcardFactory = new WildcardDefinitionPatternMatcherFactory();
DefinitionPatternMatcherFactory regexpFactory = new RegexpDefinitionPatternMatcherFactory();
- PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<>();
+ PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<T>();
resolver.registerDefinitionPatternMatcherFactory(PATTERN_WILDCARD, wildcardFactory);
resolver.registerDefinitionPatternMatcherFactory(PATTERN_REGEXP, regexpFactory);
@@ -189,19 +199,9 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
}
@Override
- protected List<URL> getSourceURLs(TilesApplicationContext applicationContext,
- TilesRequestContextFactory contextFactory) {
+ protected List<URL> getSourceURLs(TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) {
try {
- Set<URL> finalSet = new HashSet<>();
- Set<URL> webINFSet = applicationContext.getResources("/WEB-INF/**/tiles*.xml");
- Set<URL> metaINFSet = applicationContext.getResources("classpath*:META-INF/**/tiles*.xml");
-
- if (webINFSet != null) {
- finalSet.addAll(webINFSet);
- }
- if (metaINFSet != null) {
- finalSet.addAll(metaINFSet);
- }
+ Set<URL> finalSet = applicationContext.getResources(getTilesDefinitionPattern(applicationContext.getInitParams()));
return URLUtil.getBaseTilesDefinitionURLs(finalSet);
} catch (IOException e) {
@@ -209,6 +209,13 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
}
}
+ protected String getTilesDefinitionPattern(Map<String, String> params) {
+ if (params.containsKey(DefinitionsFactory.DEFINITIONS_CONFIG)) {
+ return params.get(DefinitionsFactory.DEFINITIONS_CONFIG);
+ }
+ return TILES_DEFAULT_PATTERN;
+ }
+
protected ELAttributeEvaluator createELEvaluator(TilesApplicationContext applicationContext) {
ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
http://git-wip-us.apache.org/repos/asf/struts/blob/47ecd001/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesInitializer.java
----------------------------------------------------------------------
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 b2e2700..0ff33c7 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
@@ -23,7 +23,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.factory.AbstractTilesContainerFactory;
-import org.apache.tiles.servlet.wildcard.WildcardServletTilesApplicationContext;
import org.apache.tiles.startup.AbstractTilesInitializer;
import javax.servlet.ServletContext;
@@ -35,7 +34,7 @@ public class StrutsTilesInitializer extends AbstractTilesInitializer {
@Override
protected TilesApplicationContext createTilesApplicationContext(TilesApplicationContext preliminaryContext) {
LOG.debug("Initializing Tiles wildcard support ...");
- return new WildcardServletTilesApplicationContext((ServletContext) preliminaryContext.getContext());
+ return new StrutsWildcardServletTilesApplicationContext((ServletContext) preliminaryContext.getContext());
}
@Override
http://git-wip-us.apache.org/repos/asf/struts/blob/47ecd001/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
new file mode 100644
index 0000000..2328f06
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.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.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.servlet.context.ServletTilesApplicationContext;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+public class StrutsWildcardServletTilesApplicationContext extends ServletTilesApplicationContext {
+
+ private static final Logger LOG = LogManager.getLogger(StrutsWildcardServletTilesApplicationContext.class);
+
+ private ResourceFinder finder;
+
+ public StrutsWildcardServletTilesApplicationContext(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 Set<URL> getResources(String path) throws IOException {
+ Set<URL> resources = new HashSet<>();
+
+ if (path.startsWith("/")) {
+ LOG.trace("Using ServletContext to load resource #0", path);
+ URL resource = getResource(path);
+ if (resource != null) {
+ resources.add(resource);
+ }
+ }
+ resources.addAll(findResources(path));
+
+ return resources;
+ }
+
+ protected Set<URL> findResources(String path) throws IOException {
+ Set<URL> resources = new HashSet<>();
+
+ LOG.trace("Using ResourceFinder to find matches for #0", path);
+
+ Pattern pattern = WildcardUtil.compileWildcardPattern(path);
+ Map<String, URL> matches = finder.getResourcesMap("");
+
+ for (String resource : matches.keySet()) {
+ if (pattern.matcher(resource).matches()) {
+ resources.add(matches.get(resource));
+ }
+ }
+
+ LOG.trace("Found resources #0 for path #1", resources, path);
+ return resources;
+ }
+
+}