Skip to content

Commit 83f14d5

Browse files
committed
merged old project into this one
1 parent b7fe476 commit 83f14d5

File tree

17 files changed

+28769
-9
lines changed

17 files changed

+28769
-9
lines changed

demo-war/pom.xml

+13-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@
3737
<artifactId>jstl</artifactId>
3838
<version>1.2</version>
3939
</dependency>
40-
40+
41+
<dependency>
42+
<groupId>com.googlecode.objectify</groupId>
43+
<artifactId>objectify</artifactId>
44+
<version>5.0.2</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.google.code.gson</groupId>
49+
<artifactId>gson</artifactId>
50+
<version>2.2.4</version>
51+
</dependency>
52+
4153
<!-- Test Dependencies -->
4254
<dependency>
4355
<groupId>com.google.appengine</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.pscuderi.appengineangulardemo.servlet;
2+
import java.io.IOException;
3+
import java.util.Date;
4+
5+
import javax.servlet.http.HttpServlet;
6+
import javax.servlet.http.HttpServletRequest;
7+
import javax.servlet.http.HttpServletResponse;
8+
9+
import com.pscuderi.appengineangulardemo.util.ServletUtils;
10+
11+
@SuppressWarnings("serial")
12+
public class GetUserServlet extends HttpServlet {
13+
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
14+
resp.setContentType("text/json");
15+
16+
17+
resp.getWriter().println(ServletUtils.toJson(new Date()));
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.pscuderi.appengineangulardemo.util;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
6+
import com.google.gson.Gson;
7+
8+
public final class ServletUtils {
9+
private ServletUtils() { }
10+
11+
private static Gson gson = new Gson();
12+
13+
public static String toJson(Object o) {
14+
return gson.toJson(o);
15+
}
16+
17+
public static <T> T fromJson(String json, Class<T> clazz) {
18+
return gson.fromJson(json, clazz);
19+
}
20+
21+
public static <T> T fromJson(BufferedReader reader, Class<T> clazz) throws IOException {
22+
StringBuilder sb = new StringBuilder();
23+
try {
24+
String line = reader.readLine();
25+
if (line != null) {
26+
sb.append(line);
27+
while ((line = reader.readLine()) != null)
28+
sb.append('\n').append(line);
29+
}
30+
}
31+
finally {
32+
reader.close();
33+
}
34+
return fromJson(sb.toString(), clazz);
35+
}
36+
}

demo-war/src/main/webapp/WEB-INF/appengine-web.xml

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
<version>${appengine.app.version}</version>
55
<threadsafe>true</threadsafe>
66

7+
<static-files>
8+
<include path="/js/*.*" />
9+
<include path="/css/*.*" />
10+
<include path="/templates/*.*" />
11+
</static-files>
12+
713
<system-properties>
814
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
915
</system-properties>

demo-war/src/main/webapp/WEB-INF/web.xml

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
3+
4+
<servlet>
5+
<servlet-name>GetUser</servlet-name>
6+
<servlet-class>com.pscuderi.appengineangulardemo.servlet.GetUserServlet</servlet-class>
7+
</servlet>
8+
<servlet-mapping>
9+
<servlet-name>GetUser</servlet-name>
10+
<url-pattern>servlets/GetUser</url-pattern>
11+
</servlet-mapping>
12+
313
<welcome-file-list>
414
<welcome-file>index.html</welcome-file>
515
</welcome-file-list>

0 commit comments

Comments
 (0)