Commits

Jonghyouk Yun  committed 5981651

Jersey Viewable, JSP-EL/JSTL.

  • Participants
  • Parent commits 18e10fd

Comments (0)

Files changed (6)

 	DONE - Transactions
 
 
-* javadocs!
+DONE * Viewable example?
+
+DONE * jsp-el? jstl?
+
+* /public?
+
+* /public config-ize.
 
+* no serve-urls?
+
+
+* javadocs!
 
-* WORKFLOW TODOs
+* WORKFLOW DOCS TODOs
 	- maven, eclipse, m2eclipse.
 	- maven and ojdbc.
 	- add new sqlmap?
 	</build>
 
 	<dependencies>
+		<!-- JUnit -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.10</version>
+			<scope>test</scope>
+		</dependency>
+		<!-- Guava -->
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>13.0</version>
+		</dependency>
+		<!-- Commons Lang -->
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<!-- Commons BeanUtils -->
+		<dependency>
+			<groupId>commons-beanutils</groupId>
+			<artifactId>commons-beanutils</artifactId>
+			<version>1.8.3</version>
+			<scope>runtime</scope>
+		</dependency>
+		<!-- Commons Configuration -->
+		<dependency>
+			<groupId>commons-configuration</groupId>
+			<artifactId>commons-configuration</artifactId>
+			<version>1.8</version>
+		</dependency>
+		<!-- Google Guice -->
 		<dependency>
 			<groupId>com.google.inject</groupId>
 			<artifactId>guice</artifactId>
 			<version>3.0</version>
 		</dependency>
+		<!-- Logging -->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.6.6</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.6.6</version>
+		</dependency>
+		<!-- HSQLDB -->
+		<dependency>
+			<groupId>org.hsqldb</groupId>
+			<artifactId>hsqldb</artifactId>
+			<version>2.2.8</version>
+		</dependency>
+		<!-- MyBatis -->
 		<dependency>
 			<groupId>org.mybatis</groupId>
 			<artifactId>mybatis-guice</artifactId>
 			<artifactId>mybatis</artifactId>
 			<version>3.1.1</version>
 		</dependency>
+		<!-- javax.servlet -->
 		<dependency>
-			<groupId>commons-configuration</groupId>
-			<artifactId>commons-configuration</artifactId>
-			<version>1.8</version>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>3.0.1</version>
+		</dependency>
+		<dependency>
+			<groupId>jstl</groupId>
+			<artifactId>jstl</artifactId>
+			<version>1.2</version>
+		</dependency>
+		<!-- Jersey -->
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-servlet</artifactId>
+			<version>1.13</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-json</artifactId>
+			<version>1.13</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey.contribs</groupId>
+			<artifactId>jersey-guice</artifactId>
+			<version>1.13</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-client</artifactId>
+			<version>1.13</version>
 		</dependency>
-		 <dependency>
-		 	<groupId>org.slf4j</groupId>
-		 	<artifactId>slf4j-api</artifactId>
-		 	<version>1.6.6</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>com.google.guava</groupId>
-		 	<artifactId>guava</artifactId>
-		 	<version>13.0</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>commons-lang</groupId>
-		 	<artifactId>commons-lang</artifactId>
-		 	<version>2.6</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>org.slf4j</groupId>
-		 	<artifactId>slf4j-log4j12</artifactId>
-		 	<version>1.6.6</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>org.hsqldb</groupId>
-		 	<artifactId>hsqldb</artifactId>
-		 	<version>2.2.8</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>com.sun.jersey</groupId>
-		 	<artifactId>jersey-servlet</artifactId>
-		 	<version>1.13</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>com.sun.jersey</groupId>
-		 	<artifactId>jersey-json</artifactId>
-		 	<version>1.13</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>junit</groupId>
-		 	<artifactId>junit</artifactId>
-		 	<version>4.10</version>
-		 	<scope>test</scope>
-		 </dependency>
-		 <dependency>
-		 	<groupId>commons-beanutils</groupId>
-		 	<artifactId>commons-beanutils</artifactId>
-		 	<version>1.8.3</version>
-		 	<scope>runtime</scope>
-		 </dependency>
-		 <dependency>
-		 	<groupId>com.sun.jersey.contribs</groupId>
-		 	<artifactId>jersey-guice</artifactId>
-		 	<version>1.13</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>javax.servlet</groupId>
-		 	<artifactId>javax.servlet-api</artifactId>
-		 	<version>3.0.1</version>
-		 </dependency>
-		 <dependency>
-		 	<groupId>com.sun.jersey</groupId>
-		 	<artifactId>jersey-client</artifactId>
-		 	<version>1.13</version>
-		 </dependency>
+
 	</dependencies>
 </project>

File src/main/java/jhyun/mybatis_with_guice/controllers/HelloController.java

 import com.google.common.collect.ImmutableMap;
 import com.google.inject.Inject;
 import com.google.inject.servlet.RequestScoped;
+import com.sun.jersey.api.view.Viewable;
 
 /**
  * 테스트용 "Hello" 컨트롤로/리소스.
 		return "OK.";
 	}
 
+	/** Viewable 활용해서 JSP/MVC 패턴 구현. */
+	@GET
+	@Path("/viewable/foo")
+	@Produces(MediaType.TEXT_HTML)
+	public Viewable viewableFoo(@Context HttpServletRequest request) {
+		return new Viewable("/foo.jsp",
+				new ImmutableMap.Builder<String, Object>().put("value", "42")
+						.build());
+	}
+
 }

File src/main/java/jhyun/mybatis_with_guice/injections/JerseyServletModule.java

 		 */
 		params.put("com.sun.jersey.config.feature.Redirect", "true");
 		params.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
+		
+		params.put("com.sun.jersey.config.property.JSPTemplatesBasePath", "/WEB-INF/jsp");
+		
+		// FIXME:
+		params.put("com.sun.jersey.config.property.WebPageContentRegex",
+	       "(/(public)/.*)");//|(/.*\\.jsp)|(/WEB-INF/.*\\.jsp)|(/WEB-INF/.*\\.jspf)|(/.*\\.html)|(/favicon\\.ico)|(/robots\\.txt)");
+		
+		
+		
 		// serving urls
 		Configuration config = AppConfig.load();
 		serveRegex(config.getString("default-serve-url-regex", "/public/.*"))
-				.with(DefaultWrapperServlet.class);
+				.with(DefaultWrapperServlet.class);	// FIXME:
+        filter("/*").through(GuiceContainer.class, params);
+
+		/*
 		serve(config.getString("jersey-serve-url-pattern", "/*")).with(
 				GuiceContainer.class, params);
+				*/
+		
 	}
 
 	/**

File src/main/webapp/WEB-INF/jsp/foo.jsp

+<%@ page contentType="text/html; charset=UTF-8" language="java" %>
+
+<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
+
+<!DOCTYPE html>
+<html>
+    <body>
+        Value: [<c:out value="${it.value}"/>]
+    </body>
+</html>

File src/main/webapp/public/foo.txt

+FOOBAR!