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/10 12:21:59 UTC
[01/16] struts git commit: Adds required dependencies (cherry picked
from commit 85b2198)
Repository: struts
Updated Branches:
refs/heads/support-2-3 bd1a121b8 -> 997966829
Adds required dependencies
(cherry picked from commit 85b2198)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/1dc545e3
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/1dc545e3
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/1dc545e3
Branch: refs/heads/support-2-3
Commit: 1dc545e34c19520c0ba780b43c53a28f5e3e9484
Parents: 90dbf54
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:22:31 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:34:55 2015 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 29 +++++++++++++++++++++++++++++
pom.xml | 41 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/1dc545e3/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 9114b2b..6e872ee 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/1dc545e3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 30ebfa8..6f6ea8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,8 +89,8 @@
<ognl.version>3.0.13</ognl.version>
<asm.version>3.3</asm.version>
<asm5.version>5.0.2</asm5.version>
- <tiles.version>2.0.6</tiles.version>
- <log4j2.version>2.2</log4j2.version>
+ <tiles.version>2.2.2</tiles.version>
+ <log4j2.version>2.3</log4j2.version>
<!-- SCM Site Configuration -->
<site.mainDirectory>${project.build.directory}/site</site.mainDirectory>
@@ -641,6 +641,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>
@@ -668,10 +675,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>
[09/16] struts git commit: Reverts back to XWork logging layer
Posted by lu...@apache.org.
Reverts back to XWork logging layer
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/696e5662
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/696e5662
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/696e5662
Branch: refs/heads/support-2-3
Commit: 696e5662797d1958bdc7d6ca2345bc0538b022a6
Parents: 27aa7e1
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Nov 28 15:57:52 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:57:52 2015 +0100
----------------------------------------------------------------------
.../tiles/StrutsFreeMarkerAttributeRenderer.java | 6 +++---
.../struts2/tiles/StrutsTilesContainerFactory.java | 14 +++++++-------
.../apache/struts2/tiles/StrutsTilesInitializer.java | 6 +++---
.../org/apache/struts2/tiles/StrutsTilesListener.java | 4 ++--
4 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/696e5662/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..c9491b4 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,11 +23,11 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
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;
@@ -47,7 +47,7 @@ import java.io.IOException;
public class StrutsFreeMarkerAttributeRenderer extends AbstractTypeDetectingAttributeRenderer {
- private static Logger LOG = LogManager.getLogger(StrutsFreeMarkerAttributeRenderer.class);
+ private static Logger LOG = LoggerFactory.getLogger(StrutsFreeMarkerAttributeRenderer.class);
@Override
public void write(Object value, Attribute attribute, TilesRequestContext request) throws IOException {
http://git-wip-us.apache.org/repos/asf/struts/blob/696e5662/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..b198313 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
@@ -181,7 +181,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);
@@ -192,7 +192,7 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
protected List<URL> getSourceURLs(TilesApplicationContext applicationContext,
TilesRequestContextFactory contextFactory) {
try {
- Set<URL> finalSet = new HashSet<>();
+ Set<URL> finalSet = new HashSet<URL>();
Set<URL> webINFSet = applicationContext.getResources("/WEB-INF/**/tiles*.xml");
Set<URL> metaINFSet = applicationContext.getResources("classpath*:META-INF/**/tiles*.xml");
@@ -239,24 +239,24 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class);
PropertyAccessor mapPropertyAccessor = OgnlRuntime.getPropertyAccessor(Map.class);
PropertyAccessor applicationContextPropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
+ new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
new TilesApplicationContextNestedObjectExtractor(),
objectPropertyAccessor);
PropertyAccessor requestScopePropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
+ new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
new RequestScopeNestedObjectExtractor(), mapPropertyAccessor);
PropertyAccessor sessionScopePropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
+ new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
new SessionScopeNestedObjectExtractor(), mapPropertyAccessor);
PropertyAccessor applicationScopePropertyAccessor =
- new NestedObjectDelegatePropertyAccessor<>(
+ new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
new ApplicationScopeNestedObjectExtractor(), mapPropertyAccessor);
PropertyAccessorDelegateFactory<TilesRequestContext> factory =
new TilesContextPropertyAccessorDelegateFactory(
objectPropertyAccessor, applicationContextPropertyAccessor,
requestScopePropertyAccessor, sessionScopePropertyAccessor,
applicationScopePropertyAccessor);
- PropertyAccessor tilesRequestAccessor = new DelegatePropertyAccessor<>(factory);
+ PropertyAccessor tilesRequestAccessor = new DelegatePropertyAccessor<TilesRequestContext>(factory);
OgnlRuntime.setPropertyAccessor(TilesRequestContext.class, tilesRequestAccessor);
return new OGNLAttributeEvaluator();
} catch (OgnlException e) {
http://git-wip-us.apache.org/repos/asf/struts/blob/696e5662/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..5df819c 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
@@ -19,8 +19,8 @@
package org.apache.struts2.tiles;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.factory.AbstractTilesContainerFactory;
import org.apache.tiles.servlet.wildcard.WildcardServletTilesApplicationContext;
@@ -30,7 +30,7 @@ import javax.servlet.ServletContext;
public class StrutsTilesInitializer extends AbstractTilesInitializer {
- private static final Logger LOG = LogManager.getLogger(StrutsTilesInitializer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StrutsTilesInitializer.class);
@Override
protected TilesApplicationContext createTilesApplicationContext(TilesApplicationContext preliminaryContext) {
http://git-wip-us.apache.org/repos/asf/struts/blob/696e5662/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 db42240..c55a8bf 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
@@ -19,8 +19,8 @@
package org.apache.struts2.tiles;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.tiles.startup.TilesInitializer;
import org.apache.tiles.web.startup.AbstractTilesListener;
[07/16] struts git commit: Registers Tiles model (cherry picked from
commit 388861f)
Posted by lu...@apache.org.
Registers Tiles model
(cherry picked from commit 388861f)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f19e4be9
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f19e4be9
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f19e4be9
Branch: refs/heads/support-2-3
Commit: f19e4be947c00511a91ea2d806c9c483694f7485
Parents: 913944b
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Fri Nov 27 13:36:52 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:36:28 2015 +0100
----------------------------------------------------------------------
.../StrutsFreeMarkerAttributeRenderer.java | 27 +++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/f19e4be9/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);
+ }
+
}
[10/16] struts git commit: Drops duplicated and unused dependencies
Posted by lu...@apache.org.
Drops duplicated and unused dependencies
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/db318c21
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/db318c21
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/db318c21
Branch: refs/heads/support-2-3
Commit: db318c2116f74559a22c6854ea6aeaeca36dd298
Parents: 696e566
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Dec 19 10:13:10 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Dec 19 10:13:10 2015 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 13 -------------
pom.xml | 10 ----------
2 files changed, 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/db318c21/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 2642b07..4f9d440 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/db318c21/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f6b5ada..afa95f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -690,16 +690,6 @@
</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>
[16/16] struts git commit: WW-4568 Upgrades the Tiles plugin to Tiles
2
Posted by lu...@apache.org.
WW-4568 Upgrades the Tiles plugin to Tiles 2
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/99796682
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/99796682
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/99796682
Branch: refs/heads/support-2-3
Commit: 997966829ae3bac1bf490daf30e56415aa84aec5
Parents: bd1a121 5ed7b36
Author: Lukasz Lenart <lu...@apache.org>
Authored: Sun Jan 10 12:21:23 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Sun Jan 10 12:21:23 2016 +0100
----------------------------------------------------------------------
plugins/portlet-tiles/pom.xml | 4 +
.../struts2/views/tiles/PortletTilesResult.java | 46 ++--
plugins/tiles/pom.xml | 23 +-
.../struts2/tiles/ConfiguredServletContext.java | 187 -------------
.../StrutsFreeMarkerAttributeRenderer.java | 116 ++++++++
.../tiles/StrutsTilesContainerFactory.java | 271 ++++++++++++++++---
.../struts2/tiles/StrutsTilesInitializer.java | 46 ++++
.../struts2/tiles/StrutsTilesListener.java | 54 +---
.../tiles/StrutsTilesRequestContext.java | 123 ---------
...sWildcardServletTilesApplicationContext.java | 106 ++++++++
.../apache/struts2/views/tiles/TilesResult.java | 6 +-
pom.xml | 35 ++-
12 files changed, 592 insertions(+), 425 deletions(-)
----------------------------------------------------------------------
[06/16] struts git commit: Adds missing header with license (cherry
picked from commit 27ad6cb)
Posted by lu...@apache.org.
Adds missing header with license
(cherry picked from commit 27ad6cb)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/913944b8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/913944b8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/913944b8
Branch: refs/heads/support-2-3
Commit: 913944b8eee6c5565cb665b5477953be9b85152a
Parents: ddeb7f0
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:54:39 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:36:22 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/913944b8/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 ea134d8..3ca68fe 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/913944b8/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/913944b8/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
[11/16] struts git commit: Implements ApplicationContext which
supports wildcards
Posted by lu...@apache.org.
Implements ApplicationContext which supports wildcards
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f721d549
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f721d549
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f721d549
Branch: refs/heads/support-2-3
Commit: f721d5490cfc1ed9f1a441ea90de82e31bb32351
Parents: db318c2
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Dec 19 10:13:57 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Dec 19 10:13:57 2015 +0100
----------------------------------------------------------------------
...sWildcardServletTilesApplicationContext.java | 75 ++++++++++++++++++++
1 file changed, 75 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/f721d549/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..9482259
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletTilesApplicationContext.java
@@ -0,0 +1,75 @@
+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 com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+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.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+public class StrutsWildcardServletTilesApplicationContext extends ServletTilesApplicationContext {
+
+ private static final Logger LOG = LoggerFactory.getLogger(StrutsWildcardServletTilesApplicationContext.class);
+
+ private ResourceFinder finder;
+
+ public StrutsWildcardServletTilesApplicationContext(ServletContext context) {
+ super(context);
+
+ Set<URL> urls = new HashSet<URL>();
+ 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);
+ }
+ }
+
+ finder = new ResourceFinder(urls.toArray(new URL[urls.size()]));
+ }
+
+ public Set<URL> getResources(String path) throws IOException {
+ Set<URL> resources = new HashSet<URL>();
+
+ 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<URL>();
+
+ 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;
+ }
+
+}
[03/16] struts git commit: Drops unused classes (cherry picked from
commit 24a5bce)
Posted by lu...@apache.org.
Drops unused classes
(cherry picked from commit 24a5bce)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/efcea81b
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/efcea81b
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/efcea81b
Branch: refs/heads/support-2-3
Commit: efcea81b67d260835eff9c811efe20a816df7213
Parents: 9862580
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:29:24 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:36:04 2015 +0100
----------------------------------------------------------------------
.../struts2/tiles/ConfiguredServletContext.java | 187 -------------------
.../tiles/StrutsTilesRequestContext.java | 123 ------------
2 files changed, 310 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/efcea81b/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/efcea81b/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 856517c..0000000
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java
+++ /dev/null
@@ -1,123 +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 com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
-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;
-
-/**
- * Default implementation of TilesUtil.
- * This class contains default implementation of utilities. This implementation
- * is intended to be used without Struts.
- * <p/>
- * TilesUtilImpl implementation used to intercept .ftl requests and
- * ensure that they are setup properly to take advantage of the
- * {@link FreemarkerResult}.
- *
- * @version $Id$
- */
-public class StrutsTilesRequestContext extends TilesRequestContextWrapper {
-
- private static final Logger LOG = LoggerFactory.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);
- }
- }
-
-}
[05/16] struts git commit: Updates Portal Tiles integration (cherry
picked from commit 6edc0ff)
Posted by lu...@apache.org.
Updates Portal Tiles integration
(cherry picked from commit 6edc0ff)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/ddeb7f0f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/ddeb7f0f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/ddeb7f0f
Branch: refs/heads/support-2-3
Commit: ddeb7f0f7cc2600ceb36b8532fc433861a38c20e
Parents: 5d30eb1
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:37:42 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:36:16 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/ddeb7f0f/plugins/portlet-tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml
index c2793d7..333c570 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/ddeb7f0f/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 c08a99b..ea134d8 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/ddeb7f0f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6f6ea8a..7f45aea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -680,6 +680,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>
[14/16] 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/2d70ea2f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/2d70ea2f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/2d70ea2f
Branch: refs/heads/support-2-3
Commit: 2d70ea2f7d09d75fd8810772b7872b8dd64a1ca2
Parents: 9136521
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Dec 19 10:23:39 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Dec 19 10:23:39 2015 +0100
----------------------------------------------------------------------
...tsWildcardServletTilesApplicationContext.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/2d70ea2f/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 9482259..8aa34fe 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
@@ -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.config.ConfigurationException;
[15/16] struts git commit: Adds fetching resources from classpath
Posted by lu...@apache.org.
Adds fetching resources from classpath
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5ed7b365
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5ed7b365
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5ed7b365
Branch: refs/heads/support-2-3
Commit: 5ed7b3656769fab4198e2eedf32eac1787e370b5
Parents: 2d70ea2
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sun Dec 27 15:17:28 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sun Dec 27 15:17:28 2015 +0100
----------------------------------------------------------------------
.../StrutsWildcardServletTilesApplicationContext.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/5ed7b365/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 8aa34fe..f01b45a 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
@@ -31,6 +31,7 @@ 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;
@@ -46,6 +47,7 @@ public class StrutsWildcardServletTilesApplicationContext extends ServletTilesAp
super(context);
Set<URL> urls = new HashSet<URL>();
+
for (Object path : context.getResourcePaths("/")) {
try {
URL url = new File(context.getRealPath(String.valueOf(path))).toURI().toURL();
@@ -55,6 +57,16 @@ public class StrutsWildcardServletTilesApplicationContext extends ServletTilesAp
}
}
+ 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()]));
}
[08/16] struts git commit: Fixes dependency clash
Posted by lu...@apache.org.
Fixes dependency clash
(cherry picked from commit 6622fab25bee1dae9085cca56b87711f3197916d)
Conflicts:
apps/showcase/pom.xml
plugins/bean-validation/pom.xml
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/27aa7e1e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/27aa7e1e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/27aa7e1e
Branch: refs/heads/support-2-3
Commit: 27aa7e1e27546effcfc1e4214d231b4a31263fb5
Parents: f19e4be
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Nov 28 15:39:47 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:39:47 2015 +0100
----------------------------------------------------------------------
plugins/tiles/pom.xml | 7 +++----
pom.xml | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/27aa7e1e/plugins/tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml
index 6e872ee..2642b07 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/27aa7e1e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7f45aea..f6b5ada 100644
--- a/pom.xml
+++ b/pom.xml
@@ -641,10 +641,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>
[04/16] struts git commit: Replaces call to deprecated api (cherry
picked from commit 26f153d)
Posted by lu...@apache.org.
Replaces call to deprecated api
(cherry picked from commit 26f153d)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5d30eb1a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5d30eb1a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5d30eb1a
Branch: refs/heads/support-2-3
Commit: 5d30eb1ad21d369a5e5e844363f3ec1e0e93d03a
Parents: efcea81
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:29:43 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:36:11 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/5d30eb1a/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 6135302..1e62672 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.dispatcher.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/16] struts git commit: Cleans up and fixes issue based on feedback
Posted by lu...@apache.org.
Cleans up and fixes issue based on feedback
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9136521d
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9136521d
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9136521d
Branch: refs/heads/support-2-3
Commit: 9136521d27a45f8cd9206dc2dc4a50a2ebfa07db
Parents: 5be1590
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Dec 19 10:15:02 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Dec 19 10:15:02 2015 +0100
----------------------------------------------------------------------
.../tiles/StrutsTilesContainerFactory.java | 35 ++++++++++++--------
1 file changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/9136521d/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 b198313..b96884c 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
@@ -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<URL>();
- 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();
[12/16] struts git commit: Uses the new context implementation
Posted by lu...@apache.org.
Uses the new context implementation
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5be1590a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5be1590a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5be1590a
Branch: refs/heads/support-2-3
Commit: 5be1590a6045068bee64bbc247a39b79a3d1fa58
Parents: f721d54
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Sat Dec 19 10:14:40 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Dec 19 10:14:40 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/struts2/tiles/StrutsTilesInitializer.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/5be1590a/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 5df819c..550c6b1 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 com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
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
[02/16] struts git commit: Re-implements tiles integration based on
new API (cherry picked from commit 70716e9)
Posted by lu...@apache.org.
Re-implements tiles integration based on new API
(cherry picked from commit 70716e9)
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9862580b
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9862580b
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9862580b
Branch: refs/heads/support-2-3
Commit: 9862580bbee704cff63b917f3dfda62d21c1bad5
Parents: 1dc545e
Author: Lukasz Lenart <lu...@gmail.com>
Authored: Wed Nov 25 20:29:18 2015 +0100
Committer: Lukasz Lenart <lu...@gmail.com>
Committed: Sat Nov 28 15:35:48 2015 +0100
----------------------------------------------------------------------
.../StrutsFreeMarkerAttributeRenderer.java | 72 +++++
.../tiles/StrutsTilesContainerFactory.java | 266 +++++++++++++++----
.../struts2/tiles/StrutsTilesInitializer.java | 47 ++++
.../struts2/tiles/StrutsTilesListener.java | 58 +---
4 files changed, 351 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/9862580b/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/9862580b/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/9862580b/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/9862580b/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 b2213ca..db42240 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 com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
+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 = LoggerFactory.getLogger(StrutsTilesListener.class);
- private static final Map<String, String> INIT;
-
- static {
- INIT = new HashMap<String, String>();
- INIT.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
- StrutsTilesContainerFactory.class.getName());
+ @Override
+ protected TilesInitializer createTilesInitializer() {
+ LOG.info("Starting Struts Tiles 2 integration ...");
+ return new StrutsTilesInitializer();
}
-
- protected TilesContainer createContainer(ServletContext context)
- throws TilesException {
- if(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM) == null) {
- context = decorate(context);
- }
- else {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Tiles container factory is explicitly set. Not injecting struts configuration.");
- }
- }
- return super.createContainer(context);
- }
-
- protected ServletContext decorate(ServletContext context) {
- return new ConfiguredServletContext(context, INIT);
- }
-
-}
+}
\ No newline at end of file