Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2013-01-25 06:04:49 -0500
committerGlyn Normington2013-01-25 06:04:49 -0500
commitdc266742b2bcdfc08fe70801067d548400964efa (patch)
tree4ed2f39e89562e5a6763018d541be14fd7603fd1
parentdaa052794b18a0ce4cc0a51c95393b9f511a6857 (diff)
parent5256530143917edcd261766796ce458206fad016 (diff)
downloadorg.eclipse.virgo.samples-dc266742b2bcdfc08fe70801067d548400964efa.tar.gz
org.eclipse.virgo.samples-dc266742b2bcdfc08fe70801067d548400964efa.tar.xz
org.eclipse.virgo.samples-dc266742b2bcdfc08fe70801067d548400964efa.zip
Merge branch 'spring-REST'
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.classpath23
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.project44
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.settings/.jsdtscope11
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.component11
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.project.facet.core.xml9
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.container1
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.name1
-rw-r--r--REST/org.eclipse.virgo.samples.rest/.springBeans13
-rw-r--r--REST/org.eclipse.virgo.samples.rest/build.xml8
-rw-r--r--REST/org.eclipse.virgo.samples.rest/ivy.xml42
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/java/org/eclipse/virgo/samples/rest/RestController.java152
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/resources/.gitignore0
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/webapp/META-INF/MANIFEST.MF26
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/applicationContext.xml8
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/jsp/roy.jsp74
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/rest-servlet.xml22
-rw-r--r--REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/web.xml34
-rw-r--r--REST/org.eclipse.virgo.samples.rest/template.mf31
19 files changed, 522 insertions, 0 deletions
diff --git a/REST/org.eclipse.virgo.samples.rest/.classpath b/REST/org.eclipse.virgo.samples.rest/.classpath
new file mode 100644
index 0000000..9ef238e
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.classpath
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="false"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web/3.1.0.RELEASE/org.springframework.web-3.1.0.RELEASE.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.web/3.1.0.RELEASE/org.springframework.web-sources-3.1.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/3.1.0.RELEASE/org.springframework.beans-3.1.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web.servlet/3.1.0.RELEASE/org.springframework.web.servlet-3.1.0.RELEASE.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.web.servlet/3.1.0.RELEASE/org.springframework.web.servlet-sources-3.1.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet/3.0.0.v201112011016/com.springsource.javax.servlet-sources-3.0.0.v201112011016.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/3.1.0.RELEASE/org.springframework.context-3.1.0.RELEASE.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-sources-3.0.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/javax.servlet.jsp/2.2.0.v201112011158/javax.servlet.jsp-2.2.0.v201112011158.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/javax.servlet.jsp.jstl/1.2.0.v201105211821/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/3.1.0.RELEASE/org.springframework.core-3.1.0.RELEASE.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-sources-3.0.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.apache.taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-3.7.1.R37x_v20110808-1106.jar" sourcepath="/IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.6.1.R36x_v20100806/org.eclipse.osgi-sources-3.6.1.R36x_v20100806.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.equinox.cm/1.0.400.v20120319-2029/org.eclipse.equinox.cm-1.0.400.v20120319-2029.jar" sourcepath="/IVY_CACHE/org.apache.felix/org.apache.felix.configadmin/1.2.4/org.apache.felix.configadmin-sources-1.2.4.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/REST/org.eclipse.virgo.samples.rest/.project b/REST/org.eclipse.virgo.samples.rest/.project
new file mode 100644
index 0000000..1e8e88a
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.project
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.virgo.samples.rest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.virgo.ide.bundlor.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.springsource.server.ide.facet.core.bundlenature</nature>
+ <nature>org.springframework.ide.eclipse.core.springnature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.eclipse.virgo.ide.facet.core.bundlenature</nature>
+ </natures>
+</projectDescription>
diff --git a/REST/org.eclipse.virgo.samples.rest/.settings/.jsdtscope b/REST/org.eclipse.virgo.samples.rest/.settings/.jsdtscope
new file mode 100644
index 0000000..5d8de19
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.settings/.jsdtscope
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="false"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.jdt.core.prefs b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f26c14e
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Aug 24 17:26:00 BST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.component b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..85ba703
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="com.springsource.server.admin.web">
+<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/js"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
+<property name="context-root" value="admin"/>
+<property name="java-output-path" value="/target/classes"/>
+</wb-module>
+</project-modules>
diff --git a/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.project.facet.core.xml b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..1ccb66e
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="VTS 3.6.0"/>
+ <fixed facet="jst.web"/>
+ <fixed facet="jst.java"/>
+ <installed facet="jst.web" version="2.5"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="org.eclipse.virgo.server.bundle" version="1.0"/>
+</faceted-project>
diff --git a/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.container b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file
diff --git a/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.name b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window \ No newline at end of file
diff --git a/REST/org.eclipse.virgo.samples.rest/.springBeans b/REST/org.eclipse.virgo.samples.rest/.springBeans
new file mode 100644
index 0000000..34b281c
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/.springBeans
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+ <version>1</version>
+ <pluginVersion><![CDATA[2.3.0.200912170948-RELEASE]]></pluginVersion>
+ <configSuffixes>
+ <configSuffix><![CDATA[xml]]></configSuffix>
+ </configSuffixes>
+ <enableImports><![CDATA[false]]></enableImports>
+ <configs>
+ </configs>
+ <configSets>
+ </configSets>
+</beansProjectDescription>
diff --git a/REST/org.eclipse.virgo.samples.rest/build.xml b/REST/org.eclipse.virgo.samples.rest/build.xml
new file mode 100644
index 0000000..0b41140
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/build.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.virgo.samples.rest">
+
+ <property file="${basedir}/../../build.properties"/>
+ <property file="${basedir}/../../build.versions"/>
+ <import file="${basedir}/../../virgo-build/wab/default.xml"/>
+
+</project>
diff --git a/REST/org.eclipse.virgo.samples.rest/ivy.xml b/REST/org.eclipse.virgo.samples.rest/ivy.xml
new file mode 100644
index 0000000..86f3497
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/ivy.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
+<ivy-module
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
+ version="1.3">
+
+ <info organisation="org.eclipse.virgo.samples" module="${ant.project.name}"/>
+
+ <configurations>
+ <include file="${virgo.build.dir}/common/default-ivy-configurations.xml"/>
+ </configurations>
+
+ <publications>
+ <artifact name="${ant.project.name}" type="wab" ext="jar"/>
+ <artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
+ </publications>
+
+ <dependencies>
+ <!-- === PROVIDED-COMPILE============================================ -->
+ <!-- === RUNTIME-DEFAULT =========================================== -->
+ <!-- === PROVIDED-RUNTIME =========================================== -->
+ <dependency org="org.eclipse.virgo.mirrored" name="javax.servlet" rev="${javax.servlet}" conf="provided->runtime"/>
+ <dependency org="org.eclipse.virgo.mirrored" name="javax.servlet.jsp" rev="${javax.servlet.jsp}" conf="provided->runtime"/>
+ <dependency org="org.eclipse.virgo.mirrored" name="javax.servlet.jsp.jstl" rev="${javax.servlet.jsp.jstl}" conf="provided->runtime"/>
+ <dependency org="org.apache.taglibs" name="com.springsource.org.apache.taglibs.standard" rev="${org.apache.taglibs.standard}" conf="provided->runtime"/>
+ <dependency org="org.apache.xmlcommons" name="com.springsource.org.apache.xmlcommons" rev="${org.apache.xmlcommons}" conf="provided->runtime"/>
+ <dependency org="org.eclipse.virgo.mirrored" name="org.eclipse.osgi" rev="${org.eclipse.osgi}" conf="provided->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.core" rev="${org.springframework}" conf="provided->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.context" rev="${org.springframework}" conf="provided->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.beans" rev="${org.springframework}" conf="provided->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.web" rev="${org.springframework}" conf="provided->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.web.servlet" rev="${org.springframework}" conf="provided->runtime"/>
+ <!-- === TEST ====================================================== -->
+ <dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.test" rev="${org.springframework}" conf="test->runtime"/>
+ <dependency org="org.eclipse.virgo.teststubs" name="org.eclipse.virgo.teststubs.osgi" rev="${org.eclipse.virgo.teststubs}" conf="test->runtime"/>
+
+ <override org="org.springframework" rev="${org.springframework}"/>
+ </dependencies>
+
+</ivy-module>
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/java/org/eclipse/virgo/samples/rest/RestController.java b/REST/org.eclipse.virgo.samples.rest/src/main/java/org/eclipse/virgo/samples/rest/RestController.java
new file mode 100644
index 0000000..31b0ba7
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/java/org/eclipse/virgo/samples/rest/RestController.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2013 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.samples.rest;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * <p>
+ * {@link RestController} uses Spring MVC to implement a REST service which associates names and inventions with
+ * "user ids".
+ * <p/>
+ * GET requests may specify a user id, e.g.:
+ *
+ * <pre>
+ * GET /rest/users/roy HTTP/1.1
+ * Accept: application/json
+ * </pre>
+ *
+ * or may be used to inquire all users, e.g.:
+ *
+ * <pre>
+ * GET /rest/users HTTP/1.1
+ * Accept: application/json
+ * </pre>
+ *
+ * whereas PUT requests specify a user id, a name, and an invention, e.g.:
+ *
+ * <pre>
+ * PUT /rest/users/james/Sir%20James%20Dyson/Cyclonic%20Separation HTTP/1.1
+ * </pre>
+ *
+ * </p>
+ * You can use curl to drive this program as follows:
+ *
+ * <pre>
+ * curl -i -H "Accept: application/json" http://localhost:8080/rest/users/roy
+ * curl -i -X PUT /rest/users/james/Sir%20James%20Dyson/Cyclonic%20Separation
+ * curl -i -H "Accept: application/json" http://localhost:8080/rest/users/james
+ * curl -i -H "Accept: application/json" http://localhost:8080/rest/users
+ * </pre>
+ *
+ * The implementation is deliberately primitive.
+ * <p/>
+ * Please consult the following for more information on REST and its support in Spring:
+ * <p/>
+ * <ul>
+ * <li><a href="http://en.wikipedia.org/wiki/Representational_state_transfer">Representational State Transfer</a>
+ * (Wikipedia article)
+ * <li><a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm">Architectural Styles and the Design of
+ * Network-based Software Architectures</a> (Roy Fielding's REST dissertation)</li>
+ * <li><a href="http://static.springsource.org/spring/docs/3.1.0.RELEASE/reference/html/mvc.html">Spring Web MVC
+ * framework<a/></li>
+ * <li><a href="http://static.springsource.org/spring-roo/reference/html/base-json.html">Spring Roo JSON Add-On</a></li>
+ * </ul>
+ * <p/>
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread safe.
+ *
+ */
+@Controller
+public final class RestController {
+
+ private Map<String, Info> model = Collections.synchronizedMap(new HashMap<String, Info>());
+
+ public RestController() {
+ this.model.put("roy", new Info("Roy T. Fielding", "Representational State Transfer"));
+ }
+
+ @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public ResponseEntity<String> getUser(@PathVariable("userId") String userId) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.add("Content-Type", "application/json; charset=utf-8");
+ Info info = model.get(userId);
+ if (info != null) {
+ return new ResponseEntity<String>(info.toJson(), headers, HttpStatus.OK);
+ } else {
+ return new ResponseEntity<String>("", headers, HttpStatus.NOT_FOUND);
+ }
+ }
+
+ @RequestMapping(value = "/users", method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public ResponseEntity<String> getUsers() {
+ HttpHeaders headers = new HttpHeaders();
+ headers.add("Content-Type", "application/json; charset=utf-8");
+ return new ResponseEntity<String>(toJson(), headers, HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/users/{userId}/{name}/{invention}", method = RequestMethod.PUT)
+ public void putUser(@PathVariable("userId") String userId, @PathVariable("name") String name, @PathVariable("invention") String invention,
+ HttpServletResponse httpServletResponse) {
+ this.model.put(userId, new Info(name, invention));
+ httpServletResponse.setStatus(HttpServletResponse.SC_OK);
+ }
+
+ private String toJson() {
+ StringBuffer json = new StringBuffer();
+ boolean first = true;
+ json.append("[");
+ for (String name : this.model.keySet()) {
+ if (first) {
+ first = false;
+ } else {
+ json.append(", ");
+ }
+ json.append("/rest/users/" + name);
+ }
+ json.append("]");
+ return json.toString();
+ }
+
+ private class Info {
+
+ private String name;
+
+ private String invention;
+
+ Info(String name, String invention) {
+ this.name = name;
+ this.invention = invention;
+ }
+
+ String toJson() {
+ return "{ \"name\" : \"" + this.name + "\", \"invention\" : \"" + this.invention + "\" }";
+ }
+ }
+}
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/resources/.gitignore b/REST/org.eclipse.virgo.samples.rest/src/main/resources/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/resources/.gitignore
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/webapp/META-INF/MANIFEST.MF b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..07b865e
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Import-Bundle: com.springsource.org.apache.taglibs.standard;version="[
+ 1.1.2,1.3)"
+Bundle-Classpath: .,WEB-INF/classes
+Bundle-Version: 1
+Tool: Bundlor 1.1.1.RELEASE
+Bundle-Name: REST Sample Web Bundle
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.virgo.samples.rest
+Web-ContextPath: rest
+Import-Package: javax.servlet.http;version="[2.1.0, 3.0.0)",org.eclips
+ e.virgo.web.dm;version="[3.0.0,4.0.0)",org.springframework.beans.fact
+ ory.xml;version="[3.0,4.0)",org.springframework.context.config;versio
+ n="[3.0,4.0)",org.springframework.context.support;version="[3.0,4.0)"
+ ,org.springframework.http;version="[3.0,4.0)",org.springframework.ste
+ reotype;version="[3.0,4.0)",org.springframework.util;version="[3.0,4.
+ 0)",org.springframework.web.bind.annotation;version="[3.0,4.0)",org.s
+ pringframework.web.context;version="[3.0,4.0)",org.springframework.we
+ b.context.support;version="[3.0,4.0)",org.springframework.web.servlet
+ ;version="[3.0,4.0)",org.springframework.web.servlet.config;version="
+ [3.0,4.0)",org.springframework.web.servlet.handler;version="[3.0,4.0)
+ ",org.springframework.web.servlet.mvc;version="[3.0,4.0)",org.springf
+ ramework.web.servlet.mvc.annotation;version="[3.0,4.0)",org.springfra
+ mework.web.servlet.support;version="[3.0,4.0)",org.springframework.we
+ b.servlet.view;version="[3.0,4.0)"
+
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/applicationContext.xml b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/applicationContext.xml
new file mode 100644
index 0000000..6fb6d13
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/applicationContext.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+</beans>
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/jsp/roy.jsp b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/jsp/roy.jsp
new file mode 100644
index 0000000..7e36a9a
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/jsp/roy.jsp
@@ -0,0 +1,74 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %><%--
+--%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--
+--%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Configuration properties sample</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ <link rel="shortcut icon" href="/resources/images/favicon.ico" />
+ <link rel="stylesheet" href="/resources/styles/main.css" type="text/css" />
+ <link rel="stylesheet" href="/resources/styles/local.css" type="text/css" />
+ <link rel="stylesheet" href="/resources/styles/print.css" type="text/css" media="print" />
+</head>
+<body class="main tundra">
+ <div id="page">
+ <div id="mini-header">
+ <div id="mini-header-left"></div>
+ <div id="mini-header-right"></div>
+ </div> <!-- /mini-header -->
+
+ <div id="primary-navigation">
+ <div id="primary-left">
+ </div>
+ <img id="left-curve" src="/config-properties/images/menu-curve-left.png"/>
+ <div id="primary-right">
+ <ul>
+ <li><a href="/admin" title="Admin Console">Admin Console</a></li>
+ <li><a href="http://www.eclipse.org/virgo" title="Virgo">Virgo</a></li>
+ </ul>
+ </div>
+ <img id="right-curve" src="/config-properties/images/menu-curve-right.png"/>
+ </div><!-- /primary-navigation -->
+
+ <div id="container">
+ <div id="content-no-nav">
+ <h1 class="title">Configuration properties sample</h1>
+ <p>
+ The following properties have been found in 'org.eclipse.virgo.samples.configuration'.
+ </p>
+ <table id="properties" class="bordered-table">
+ <tr>
+ <th>Name</th>
+ <th>Value</th>
+ </tr>
+ <c:choose>
+ <c:when test="${empty properties}">
+ <tr class="name-sublevel1-odd">
+ <td id="property_null" colspan="2">No properties have been registered.</td>
+ </tr>
+ </c:when>
+ <c:otherwise>
+ <c:forEach var="property" items="${properties}" varStatus="loopStatus">
+ <c:set var="rowStyle" value="odd" scope="page" />
+ <c:if test="${(loopStatus.index % 2) eq 0}">
+ <c:set var="rowStyle" value="even" scope="page" />
+ </c:if>
+ <tr class="sublevel1-${rowStyle}">
+ <td id="property_key">${property.key}</td>
+ <td id="property_value">${property.value}</td>
+ </tr>
+ <c:remove var="rowStyle" />
+ </c:forEach>
+ </c:otherwise>
+ </c:choose>
+ </table>
+ </div><!-- /content -->
+ </div><!-- /container -->
+
+ <div id="footer-wrapper">
+ <div id="footer-left">&copy; Copyright 2008, 2013 VMware Inc. Licensed under the Eclipse Public License v1.0.</div>
+ <div id="footer-right"></div>
+ </div>
+ </div> <!-- /page-->
+</body>
+</html> \ No newline at end of file
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/rest-servlet.xml b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/rest-servlet.xml
new file mode 100644
index 0000000..5934d54
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/rest-servlet.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
+
+
+ <context:component-scan base-package="org.eclipse.virgo.samples.rest" />
+
+ <mvc:annotation-driven />
+
+ <!-- View configuration -->
+ <bean id="topViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <property name="prefix" value="/WEB-INF/jsp/" />
+ <property name="suffix" value=".jsp" />
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/web.xml b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..c85a25d
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app 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"
+ version="2.5">
+
+ <display-name>REST Sample</display-name>
+
+ <description>Virgo Server - REST Sample</description>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+ <context-param>
+ <param-name>contextClass</param-name>
+ <param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <!-- Dispatcher servlet configuration -->
+ <servlet>
+ <servlet-name>rest</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>rest</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app> \ No newline at end of file
diff --git a/REST/org.eclipse.virgo.samples.rest/template.mf b/REST/org.eclipse.virgo.samples.rest/template.mf
new file mode 100644
index 0000000..f855a4e
--- /dev/null
+++ b/REST/org.eclipse.virgo.samples.rest/template.mf
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-Name: REST Sample Web Bundle
+Bundle-Version: 1
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.virgo.samples.rest
+Import-Template:
+ org.springframework.*;version="[3.0,4.0)",
+ org.apache.commons.logging;version="[1.1.1,1.1.1]",
+ javax.servlet.*;version="[2.1.0, 3.0.0)",
+ javax.xml.stream.*;version="0",
+ org.osgi.framework.*;version="0",
+ org.osgi.service.cm.*;version="0"
+Import-Bundle:
+ com.springsource.org.apache.taglibs.standard;version="[1.1.2,1.3)"
+Import-Package:
+ org.eclipse.virgo.web.dm;version="[3.0.0,4.0.0)",
+ org.springframework.web.servlet;version="[3.0,4.0)",
+ org.springframework.web.servlet.config;version="[3.0,4.0)",
+ org.springframework.web.servlet.handler;version="[3.0,4.0)",
+ org.springframework.web.servlet.view;version="[3.0,4.0)",
+ org.springframework.web.servlet.mvc;version="[3.0,4.0)",
+ org.springframework.web.servlet.mvc.annotation;version="[3.0,4.0)",
+ org.springframework.web.servlet.support;version="[3.0,4.0)",
+ org.springframework.web.context;version="[3.0,4.0)",
+ org.springframework.web.context.support;version="[3.0,4.0)",
+ org.springframework.context.support;version="[3.0,4.0)",
+ org.springframework.context.config;version="[3.0,4.0)",
+ org.springframework.beans.factory.xml;version="[3.0,4.0)"
+Excluded-Exports: *
+Web-ContextPath: rest
+Bundle-Classpath: .,WEB-INF/classes

Back to the top