You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2008/10/30 15:41:40 UTC
svn commit: r709175 - in /tiles/sandbox/trunk/tiles-freemarker: ./
src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/tiles/ src/main/java/org/apache/tiles/freemarker/
src/main/java/org/apache/tiles/freemarker/context/
Author: apetrelli
Date: Thu Oct 30 07:41:39 2008
New Revision: 709175
URL: http://svn.apache.org/viewvc?rev=709175&view=rev
Log:
TILESSB-3
First series of classes.
Added:
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java (with props)
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java (with props)
tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java (with props)
Modified:
tiles/sandbox/trunk/tiles-freemarker/pom.xml
Modified: tiles/sandbox/trunk/tiles-freemarker/pom.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-freemarker/pom.xml?rev=709175&r1=709174&r2=709175&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-freemarker/pom.xml (original)
+++ tiles/sandbox/trunk/tiles-freemarker/pom.xml Thu Oct 30 07:41:39 2008
@@ -35,4 +35,22 @@
<groupId>org.apache.tiles</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-servlet</artifactId>
+ <version>2.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.14</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
Added: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java?rev=709175&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java (added)
+++ tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java Thu Oct 30 07:41:39 2008
@@ -0,0 +1,26 @@
+package org.apache.tiles.freemarker;
+
+import org.apache.tiles.TilesException;
+
+public class FreeMarkerTilesException extends TilesException {
+
+ public FreeMarkerTilesException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public FreeMarkerTilesException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public FreeMarkerTilesException(Exception e) {
+ super(e);
+ // TODO Auto-generated constructor stub
+ }
+
+ public FreeMarkerTilesException(String message, Exception e) {
+ super(message, e);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Propchange: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/FreeMarkerTilesException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java?rev=709175&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java (added)
+++ tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java Thu Oct 30 07:41:39 2008
@@ -0,0 +1,31 @@
+package org.apache.tiles.freemarker.context;
+
+import java.util.Map;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.context.TilesRequestContext;
+
+import freemarker.core.Environment;
+
+public class FreeMarkerTilesContextFactory implements TilesContextFactory {
+
+ public TilesApplicationContext createApplicationContext(Object context) {
+ throw new UnsupportedOperationException(
+ "Cannot create an application context "
+ + "since FreeMarker is only available at request time");
+ }
+
+ public TilesRequestContext createRequestContext(
+ TilesApplicationContext context, Object... requestItems) {
+ if (requestItems.length == 1 && requestItems[0] instanceof Environment) {
+ return new FreeMarkerTilesRequestContext(context,
+ (Environment) requestItems[0]);
+ }
+ return null;
+ }
+
+ public void init(Map<String, String> configurationParameters) {
+ // Nothing to initialize.
+ }
+}
Propchange: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesContextFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java?rev=709175&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java (added)
+++ tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java Thu Oct 30 07:41:39 2008
@@ -0,0 +1,90 @@
+package org.apache.tiles.freemarker.context;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.freemarker.FreeMarkerTilesException;
+import org.apache.tiles.servlet.context.ServletTilesRequestContext;
+
+import freemarker.core.Environment;
+import freemarker.ext.servlet.HttpRequestHashModel;
+import freemarker.template.TemplateModelException;
+
+public class FreeMarkerTilesRequestContext implements TilesRequestContext {
+
+ private TilesApplicationContext applicationContext;
+
+ private Environment env;
+
+ private TilesRequestContext enclosedRequest;
+
+ public FreeMarkerTilesRequestContext(
+ TilesApplicationContext applicationContext, Environment env) {
+ this.applicationContext = applicationContext;
+ this.env = env;
+ try {
+ HttpRequestHashModel request = (HttpRequestHashModel) env
+ .getDataModel().get("Request");
+ enclosedRequest = new ServletTilesRequestContext(applicationContext,
+ request.getRequest(), request.getResponse());
+ } catch (TemplateModelException e) {
+ throw new FreeMarkerTilesException(
+ "Cannot obtain a hash from FreeMarker", e);
+ }
+ }
+
+ public void dispatch(String path) throws IOException {
+ include(path);
+ }
+
+ public TilesApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public Map<String, String> getHeader() {
+ return enclosedRequest.getHeader();
+ }
+
+ public Map<String, String[]> getHeaderValues() {
+ return enclosedRequest.getHeaderValues();
+ }
+
+ public Map<String, String> getParam() {
+ return enclosedRequest.getParam();
+ }
+
+ public Map<String, String[]> getParamValues() {
+ return enclosedRequest.getParamValues();
+ }
+
+ public Object getRequest() {
+ return env;
+ }
+
+ public Locale getRequestLocale() {
+ return env.getLocale();
+ }
+
+ public Map<String, Object> getRequestScope() {
+ return enclosedRequest.getRequestScope();
+ }
+
+ public Object getResponse() {
+ return env;
+ }
+
+ public Map<String, Object> getSessionScope() {
+ return enclosedRequest.getSessionScope();
+ }
+
+ public void include(String path) throws IOException {
+ enclosedRequest.include(path);
+ }
+
+ public boolean isUserInRole(String role) {
+ return enclosedRequest.isUserInRole(role);
+ }
+}
Propchange: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-freemarker/src/main/java/org/apache/tiles/freemarker/context/FreeMarkerTilesRequestContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL