Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating dependencies

  • Loading branch information...
commit aa74759a83da81b8b6a179b0c24078920c5d0122 2 parents aa41c81 + 64dc263
@royclarkson royclarkson authored
View
33 spring-android-showcase/server/pom.xml
@@ -8,12 +8,24 @@
<version>1.0.0-BUILD-SNAPSHOT</version>
<packaging>war</packaging>
<url>http://www.springsource.org</url>
+
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.0.5.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.1</org.slf4j-version>
+ <org.codehaus.jackson-version>1.8.4</org.codehaus.jackson-version>
+ <log4j-version>1.2.16</log4j-version>
+ <javax.xml.bind-version>2.2.2</javax.xml.bind-version>
+ <javax.inject-version>1</javax.inject-version>
+ <javax.servlet-api-version>2.5</javax.servlet-api-version>
+ <javax.servlet.jsp-version>2.1</javax.servlet.jsp-version>
+ <javax.servlet-jstl-version>1.2</javax.servlet-jstl-version>
+ <commons-fileupload-version>1.2.2</commons-fileupload-version>
+ <commons-io-version>1.4</commons-io-version>
+ <junit-version>4.7</junit-version>
</properties>
+
<dependencies>
<!-- Spring -->
<dependency>
@@ -62,7 +74,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.16</version>
+ <version>${log4j-version}</version>
<scope>runtime</scope>
</dependency>
@@ -70,63 +82,64 @@
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
- <version>1</version>
+ <version>${javax.inject-version}</version>
</dependency>
<!-- Jackson JSON Processor -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
- <version>1.7.6</version>
+ <version>${org.codehaus.jackson-version}</version>
</dependency>
<!-- JAXB XML Processor -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
- <version>2.2.2</version>
+ <version>${javax.xml.bind-version}</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>2.5</version>
+ <version>${javax.servlet-api-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
- <version>2.1</version>
+ <version>${javax.servlet.jsp-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
- <version>1.2</version>
+ <version>${javax.servlet-jstl-version}</version>
</dependency>
<!-- File Upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
- <version>1.2.2</version>
+ <version>${commons-fileupload-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>1.4</version>
+ <version>${commons-io-version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
+ <version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
+
<repositories>
<!-- For testing against latest Spring snapshots -->
<repository>
View
41 spring-android-showcase/server/src/main/java/org/springframework/android/showcase/HomeController.java
@@ -38,7 +38,10 @@
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
+
private static List<State> states;
+
+ private static List<Message> messages;
/**
* Simply selects the home view to render by returning its name.
@@ -171,6 +174,30 @@ public String home() {
return "Map message received! Your message: " + message.toString();
}
+ /**
+ * Retrieve a list of messages containing 1000 items. Accepts a GET request for JSON
+ *
+ * @return A JSON array of messages
+ */
+ @RequestMapping(value="messages", method=RequestMethod.GET, headers="Accept=application/json")
+ public @ResponseBody List<Message> fetchMessagesJson() {
+ logger.info("fetching JSON messages");
+ return getMessages();
+ }
+
+ /**
+ * Retrieve a list of messages containing 1000 items. Accepts a GET request for XML
+ *
+ * @return An XML array of messages
+ */
+ @RequestMapping(value="messages", method=RequestMethod.GET, headers="Accept=application/xml")
+ public @ResponseBody MessageList fetchMessagesXml() {
+ logger.info("fetching XML messages");
+ List<Message> messages = getMessages();
+ MessageList messageList = new MessageList(messages);
+ return messageList;
+ }
+
// helper methods
@@ -247,5 +274,19 @@ private State getStateByAbbreviation(String abbreviation) {
return states;
}
+ private List<Message> getMessages() {
+ if (messages == null) {
+ messages = new ArrayList<Message>();
+ for (int i = 0; i < 1000; i++) {
+ Message m = new Message();
+ m.setId(i);
+ m.setSubject("Message " + i);
+ m.setText("This is message number " + i + ". It is used to illustrate gzip compression on the client.");
+ messages.add(m);
+ }
+ }
+ return messages;
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.