Просмотр исходного кода

Edit content and style

 - Revise all exposition
 - Remove gradle artifacts and instructions for now
 - Eliminate @Configuration class
 - Convert tabs to spaces in .java and .xml files
 - Preserve empty directory structure in 'initial'
Chris Beams 13 лет назад
Родитель
Сommit
f103b17019

+ 128
- 135
README.md Просмотреть файл

@@ -5,14 +5,21 @@
5 5
 What you'll build
6 6
 -----------------
7 7
 
8
-This guide will take you through creating a "hello world" [RESTful web service](/understanding/REST) with Spring—literally, we'll build a service that accepts an HTTP GET request:
9
-```
10
-$ curl http://localhost:8080/hello-world
11
-```
12
-and responds with the following [JSON](/understanding/JSON):
13
-```
14
-{"id":1,"content":"Hello, World!"}
15
-```
8
+This guide will walk you through creating a "hello world" [RESTful web service][u-rest] with Spring. The service will accept HTTP GET requests at:
9
+
10
+    http://localhost:8080/greeting
11
+
12
+and respond with a [JSON][u-json] representation of a greeting:
13
+
14
+    {"id":1,"content":"Hello, World!"}
15
+
16
+You'll also be able to customize the greeting by providing an optional `name` parameter in the query string:
17
+
18
+    http://localhost:8080/greeting?name=User
19
+
20
+this will override the default value of "World" and be reflected in the response:
21
+
22
+    {"id":1,"content":"Hello, User!"}
16 23
 
17 24
 
18 25
 What you'll need
@@ -20,9 +27,8 @@ What you'll need
20 27
 
21 28
  - About 15 minutes
22 29
  - A favorite text editor or IDE
23
- - [JDK 7][jdk7] or later
24
- - Your choice of Maven (3.0+) or Gradle (1.5+)
25
-
30
+ - [JDK 6][jdk] or later
31
+ - [Maven 3.0][mvn] or later
26 32
 
27 33
 [macro:how-to-complete-this-guide]
28 34
 
@@ -30,11 +36,17 @@ What you'll need
30 36
 <a name="scratch"></a>
31 37
 Set up the project
32 38
 ------------------
39
+
33 40
 [macro:build-system-intro]
34 41
 
35
-<span class="maven">
42
+### Create the directory structure
43
+
44
+    mkdir -p src/main/java/hello
45
+
36 46
 ### Create a Maven POM
37 47
 
48
+[macro:maven-project-setup-options]
49
+
38 50
 `pom.xml`
39 51
 ```xml
40 52
 <?xml version="1.0" encoding="UTF-8"?>
@@ -82,61 +94,26 @@ Set up the project
82 94
 ```
83 95
 
84 96
 [macro:bootstrap-starter-pom-disclaimer]
85
-</span>
86
-
87
-<span class="gradle">
88
-### Create a Gradle build script
89
-`build.gradle`
90
-```groovy
91
-TODO: paste complete build.gradle.
92
-compile "org.springframework.bootstrap:spring-bootstrap-web-starter:0.0.1-SNAPSHOT"
93
-compile "com.fasterxml.jackson.core:jackson-databind:2.2.0-"
94
-```
95
-</span>
96
-
97
-
98
-Create a configuration class
99
-----------------------------
100
-The first step is to set up a simple Spring configuration class. It'll look like this:
101
-
102
-`src/main/java/hello/HelloWorldConfiguration.java`
103
-
104
-```java
105
-package hello;
106
-
107
-import org.springframework.context.annotation.ComponentScan;
108
-import org.springframework.context.annotation.Configuration;
109
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
110
-
111
-@Configuration
112
-@EnableWebMvc
113
-@ComponentScan
114
-public class HelloWorldConfiguration {
115
-}
116
-```
117
-
118
-This class is concise, but there's plenty going on under the hood. [`@EnableWebMvc`](http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/web/servlet/config/annotation/EnableWebMvc.html) handles the registration of a number of components that enable Spring's support for annotation-based controllers—you'll build one of those in an upcoming step. And we've also annotated the configuration class with [`@ComponentScan`](http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/context/annotation/ComponentScan.html) which tells Spring to scan the `hello` package for those controllers (along with any other annotated component classes).
119 97
 
120 98
 
121 99
 <a name="initial"></a>
122 100
 Create a resource representation class
123 101
 --------------------------------------
124
-With the essential Spring MVC configuration out of the way, it's time to get to the nuts and bolts of our REST service by creating a resource representation class and an endpoint controller.
125 102
 
126
-Before we get too carried away with building the endpoint controller, we need to give some thought to what our API will look like.
103
+With the basics of setting up the project and build system out of the way, it's time to get to the nuts and bolts of creating our service.
127 104
 
128
-What we want is to handle GET requests for /hello-world, optionally with a name query parameter. In response to such a request, we'd like to send back JSON, representing a greeting, that looks something like this:
105
+It's best to begin this process by thinking about what interacting with the service will look like.
129 106
 
130
-```json
131
-{
132
-    "id": 1,
133
-    "content": "Hello, World!"
134
-}
135
-```
107
+We want to handle `GET` requests for `/greeting`, optionally with a `name` parameter in the query string. In response to such a request, we'd like to send back a `200 OK` response with JSON in the body that represents a greeting. It should look something like this:
108
+
109
+    {
110
+        "id": 1,
111
+        "content": "Hello, World!"
112
+    }
136 113
 
137 114
 The `id` field is a unique identifier for the greeting, and `content` is the textual representation of the greeting.
138 115
 
139
-To model the greeting representation, create a representation class:
116
+To model the greeting representation, we'll create a _resource representation class_. There's nothing fancy about this step—we're just creating a plain old java object with fields, constructors and accessors for the `id` and `content` data:
140 117
 
141 118
 `src/main/java/hello/Greeting.java`
142 119
 ```java
@@ -162,49 +139,66 @@ public class Greeting {
162 139
 }
163 140
 ```
164 141
 
165
-Now that we've got our representation class, let's create the endpoint controller that will serve it.
142
+As you'll see in a moment, Spring will the use _Jackson_ library to automatically marshal instances of type `Greeting` into JSON.
143
+
144
+Now that we've got our representation class, let's create the resource controller that will serve it.
166 145
 
167 146
 
168 147
 Create a resource controller
169 148
 ------------------------------
170
-In Spring, REST endpoints are just Spring MVC controllers. The following Spring MVC controller handles a GET request for /hello-world and returns our `Greeting` resource:
171 149
 
172
-`src/main/java/hello/HelloWorldController.java`
150
+In Spring's approach to building RESTful web services, HTTP requests are handled by a _controller_. These components are are easily identified by the [`@Controller`][] annotation, and the `GreetingController` below handles `GET` requests for `/greeting` by returning a new instance of our `Greeting` class:
151
+
152
+`src/main/java/hello/GreetingController.java`
173 153
 ```java
174 154
 package hello;
155
+
175 156
 import java.util.concurrent.atomic.AtomicLong;
176 157
 import org.springframework.stereotype.Controller;
177 158
 import org.springframework.web.bind.annotation.RequestMapping;
178
-import org.springframework.web.bind.annotation.RequestMethod;
179 159
 import org.springframework.web.bind.annotation.RequestParam;
180 160
 import org.springframework.web.bind.annotation.ResponseBody;
181 161
 
182 162
 @Controller
183
-@RequestMapping("/hello-world")
184
-public class HelloWorldController {
163
+public class GreetingController {
185 164
 
186 165
     private static final String template = "Hello, %s!";
187 166
     private final AtomicLong counter = new AtomicLong();
188 167
 
189
-    @RequestMapping(method=RequestMethod.GET)
190
-    public @ResponseBody Greeting sayHello(
168
+    @RequestMapping("/greeting")
169
+    public @ResponseBody Greeting greeting(
191 170
             @RequestParam(value="name", required=false, defaultValue="World") String name) {
192
-        return new Greeting(counter.incrementAndGet(), String.format(template, name));
171
+        return new Greeting(counter.incrementAndGet(),
172
+                            String.format(template, name));
193 173
     }
194 174
 }
195 175
 ```
196 176
 
197
-The key difference between a human-facing controller and a REST endpoint controller is in how the response is created. Rather than rely on a view (such as a [JSP](/understanding/JSP)) to render model data in HTML, an endpoint controller simply returns the data to be written directly to the body of the response.
177
+This controller is concise and simple, but there's plenty going on under the hood. Let's break it down step by step.
178
+
179
+The `@RequestMapping` annotation ensures that HTTP requests to `/greeting` are mapped to the `greeting()` method.
180
+
181
+[admon:note] We have not explicitly specified `GET` vs. `PUT`, `POST`, etc. above, because `@RequestMapping` maps _all_ HTTP operations by default. Use `@RequestMapping(method=GET)` to narrow this down.
182
+
183
+`@RequestParam` binds the value of the query string parameter `name` into the `name` parameter of the `greeting()` method. This query string parameter is not `required`, so if absent in the request the `defaultValue` of "World" will be used.
184
+
185
+The implementation of the method body is straightforward—create and return a new `Greeting` object with `id` and `content` attributes based on the next value from our `counter` and formatting the given `name` using our greeting `template`.
186
+
187
+One key difference between a traditional MVC controller and the RESTful web service controller above is in the way the HTTP response body is created. Rather than relying on a view technology (such as [JSP][u-jsp]) to perform server-side rendering of our greeting data to HTML, this service controller simply populates and returns a `Greeting` object, with the goal that its data is written directly to the HTTP response as JSON.
188
+
189
+The [`@ResponseBody`][] annotation helps make this happen. The presence of this annotation on the `greeting()` method tells Spring MVC that it does not need to render the greeting object through a server-side view layer, but that instead that the greeting object returned _is_ the response body, and should be written out directly.
190
+
191
+The only step that remains is converting the `Greeting` object to JSON. And fortunately, thanks to Spring's _HTTP message converter_ support, we don't need to bother with doing this conversion by hand. Because [Jackson 2][jackson] is on the classpath, Spring's [`MappingJackson2HttpMessageConverter`][] is automatically chosen to convert the `Greeting` instance to JSON.
198 192
 
199
-The magic is in the [`@ResponseBody`](http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/web/bind/annotation/ResponseBody.html) annotation. `@ResponseBody` tells Spring MVC to not render a model into a view, but rather to write the returned object into the response body. It does this by using one of Spring's message converters. Because Jackson 2 is on the classpath, Spring's [`MappingJackson2HttpMessageConverter`](http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/http/converter/json/MappingJackson2HttpMessageConverter.html) is automatically chosen to convert the Greeting instance to JSON.
200 193
 
194
+Make the application executable
195
+-------------------------------
201 196
 
202
-Create an executable main class
203
----------------------------------
197
+While it is possible to package this service up as a traditional _web application archive_ or [WAR][u-war] file for deployment to an external application server, we demonstrate below the simpler approach of creating a _standalone application_. You'll package everything up a single, executable JAR file, driven by a good old Java `main()` method. And along the way, we'll use Spring's support for embedding the [Tomcat][u-tomcat] servlet container as the HTTP runtime, instead of deploying to an external instance.
204 198
 
205
-We can launch the application from a custom main class, or we can do that directly from one of the configuration classes.  The easiest way is to use the `SpringApplication` helper class:
199
+### Create a main class
206 200
 
207
-`src/main/java/hello/HelloWorldConfiguration.java`
201
+`src/main/java/hello/ServiceMain.java`
208 202
 
209 203
 ```java
210 204
 package hello;
@@ -212,101 +206,100 @@ package hello;
212 206
 import org.springframework.bootstrap.SpringApplication;
213 207
 import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration;
214 208
 import org.springframework.context.annotation.ComponentScan;
215
-import org.springframework.context.annotation.Configuration;
216
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
217 209
 
218
-@Configuration
219
-@EnableAutoConfiguration
220
-@EnableWebMvc
221 210
 @ComponentScan
222
-public class HelloWorldConfiguration {
211
+@EnableAutoConfiguration
212
+public class ServiceMain {
213
+
223 214
     public static void main(String[] args) {
224
-        SpringApplication.run(HelloWorldConfiguration.class, args);
215
+        SpringApplication.run(ServiceMain.class, args);
225 216
     }
226 217
 }
227 218
 ```
219
+The `main()` method defers to the [`SpringApplication`][] helper class, providing `ServiceMain.class` as an argument to its `run()` method. This tells Spring to read the annotation metadata from `ServiceMain` and to manage it as a component in the _[Spring application context][u-application-context]_.
220
+
221
+The `@ComponentScan` annotation tells Spring to recursively search through the `hello` package and its children for classes marked directly or indirectly with Spring's [`@Component`][] annotation. This directive ensures that Spring will find and register our `GreetingController`, because it is marked with `@Controller`, which in turn is a kind of `@Component` annotation.
222
+
223
+The [`@EnableAutoConfiguration`][] annotation has also been added: it switches on a number of reasonable default behaviors based on the content of your classpath. For example, because the application depends on the embeddable version of Tomcat (tomcat-embed-core.jar), a Tomcat server is set up and configured with reasonable defaults on your behalf. And because the application also depends on Spring MVC (spring-webmvc.jar), a Spring MVC [`DispatcherServlet`][] is configured and registered for you—no `web.xml` necessary! Auto-configuration is a powerful, flexible mechanism—See the [API documentation][`@EnableAutoConfiguration`] for further details.
228 224
 
229
-The `@EnableAutoConfiguration` annotation has also been added: it provides a load of defaults (like the embedded servlet container) depending on the contents of your classpath, and other things.
225
+### Build an executable JAR
230 226
 
227
+Now that we have our `ServiceMain` class ready to go, we simply need to instruct the build system to create a single, executable jar containing everything. This will make it dead simple to ship and version and deploy the service as an application throughout the development lifecycle, across different environments, etc.
231 228
 
232
-Build an executable JAR
233
------------------------
234
-<span class="maven">
235
-Add the following to your `pom.xml` file (keeping any existing properties or plugins intact):
229
+Add the following configuration to your existing Maven POM
236 230
 
237 231
 `pom.xml`
238 232
 ```xml
239
-<properties>
240
-    <start-class>hello.HelloWorldConfiguration</start-class>
241
-</properties>
242
-
243
-<build>
244
-    <plugins>
245
-        <plugin>
246
-            <groupId>org.apache.maven.plugins</groupId>
247
-            <artifactId>maven-shade-plugin</artifactId>
248
-        </plugin>
249
-    </plugins>
250
-</build>
233
+    <properties>
234
+        <start-class>hello.ServiceMain</start-class>
235
+    </properties>
236
+
237
+    <build>
238
+        <plugins>
239
+            <plugin>
240
+                <groupId>org.apache.maven.plugins</groupId>
241
+                <artifactId>maven-shade-plugin</artifactId>
242
+            </plugin>
243
+        </plugins>
244
+    </build>
251 245
 ```
252
-</span>
253
-<span class="gradle">
254
-```groovy
255
-TODO: gradle syntax
256
-```
257
-</span>
258 246
 
259
-The following will produce a single executable JAR file containing all necessary dependency classes:
260
-<span class="maven">
261
-```
262
-$ mvn package
263
-```
264
-</span>
265
-<span class="gradle">
266
-```
267
-$ gradle build
268
-```
269
-</span>
247
+The `start-class` property tells Maven to create a `META-INF/MANIFEST.MF` file with a `Main-Class: hello.ServiceMain` entry. This is the key to being able to run the jar with `java -jar`.
248
+
249
+The [Maven Shade plugin][maven-shade-plugin] extracts classes from all the jars on the classpath and builds a single "über-jar". This makes it much more convenient to execute and transport your service.
250
+
251
+Now run the following to produce a single executable JAR file containing all necessary dependency classes and resources:
252
+
253
+    mvn package
270 254
 
271 255
 
272 256
 Run the service
273 257
 ---------------
274 258
 
275
-Now you can run it from the jar as well, and distribute that as an executable artifact:
276
-```
277
-$ java -jar target/gs-rest-service-1.0.jar
259
+That's it! You're ready to run your service with `java -jar` at the command line:
278 260
 
279
-```
261
+    java -jar target/gs-rest-service-1.0.jar
262
+
263
+You'll see a bit of logging output, and the service should be up and running within a second or two.
280 264
 
281 265
 
282 266
 Test the service
283 267
 ----------------
284 268
 
285
-Once the service starts, you can test it by pointing your web browser at <http://localhost:8080/hello-world>. Or you can consume it from the command line using [`curl`][curl]:
269
+Now that the service is up, visit <http://localhost:8080/greeting>, where you'll see
286 270
 
287
-```
288
-$ curl http://localhost:8080/hello-world
289
-```
271
+    {"id":1,"content":"Hello, World!"}
290 272
 
291
-Either way, the response should look like this:
292
-```
293
-{"id":1,"content":"Hello, World!"}
294
-```
273
+Try providing a `name` query string parameter with <http://localhost:8080/greeting?name=User>. Notice how the value of the `content` attribute changes from "Hello, World!" to "Hello User!":
295 274
 
296
-Now try providing a `name` query string parameter: <http://localhost:8080/hello-world?name=User>
275
+    {"id":2,"content":"Hello, User!"}
297 276
 
298
-```
299
-$ curl http://localhost:8080/hello-world?name=User
300
-```
277
+This demonstrates that the `@RequestParam` arrangement in `GreetingController` is working as expected. The `name` parameter has been given a default value of "World", but can always be explicitly overridden through the query string.
301 278
 
302
-And notice how the content changes:
279
+Notice also how the `id` attribute has changed from `1` to `2`. This proves that we're working against the same `GreetingController` instance across multiple requests, and that its `counter` field is being incremented on each call as expected.
303 280
 
304
-```
305
-{"id":1,"content":"Hello, User"}
306
-```
307 281
 
308
-Congratulations! You have just developed a simple RESTful service using Spring. This is a basic foundation for building a complete REST API in Spring.
282
+Summary
283
+-------
284
+
285
+Congrats! You've just developed your first RESTful web service using Spring. This of course is just the beginning, and there are many more features to explore and take advantage of. Be sure to check out Spring's support for [securing](TODO), [testing](TODO), [describing](TODO) and [managing](TODO) RESTful web services.
286
+
309 287
 
288
+[mvn]: http://maven.apache.org/download.cgi
310 289
 [zip]: https://github.com/springframework-meta/gs-rest-service/archive/master.zip
311
-[jdk7]: http://docs.oracle.com/javase/7/docs/webnotes/install/index.html
312
-[curl]: http://curl.haxx.se/download.html
290
+[jdk]: http://www.oracle.com/technetwork/java/javase/downloads/index.html
291
+[u-rest]: /understanding/rest
292
+[u-json]: /understanding/json
293
+[u-jsp]: /understanding/jsp
294
+[jackson]: http://wiki.fasterxml.com/JacksonHome
295
+[u-war]: /understanding/war
296
+[u-tomcat]: /understanding/tomcat
297
+[u-application-context]: /understanding/application-context
298
+[maven-shade-plugin]: https://maven.apache.org/plugins/maven-shade-plugin
299
+[`@Controller`]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/stereotype/Controller.html
300
+[`SpringApplication`]: http://static.springsource.org/spring-bootstrap/docs/0.5.0.BUILD-SNAPSHOT/javadoc-api/org/springframework/bootstrap/SpringApplication.html
301
+[`@EnableAutoConfiguration`]: http://static.springsource.org/spring-bootstrap/docs/0.5.0.BUILD-SNAPSHOT/javadoc-api/org/springframework/bootstrap/context/annotation/SpringApplication.html
302
+[`@Component`]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/stereotype/Component.html
303
+[`@ResponseBody`]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/ResponseBody.html
304
+[`MappingJackson2HttpMessageConverter`]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/http/converter/json/MappingJackson2HttpMessageConverter.html
305
+[`DispatcherServlet`]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html

+ 0
- 17
complete/build.gradle Просмотреть файл

@@ -1,17 +0,0 @@
1
-apply plugin: 'java'
2
-apply plugin: 'eclipse-wtp'
3
-apply plugin: 'idea'
4
-apply plugin: 'application'
5
-
6
-mainClassName = "hello.HelloWorlConfiguration"
7
-
8
-repositories { mavenCentral() }
9
-
10
-dependencies {
11
-	compile "org.springframework.bootstrap:spring-bootstrap-web-starter:0.5.0.BUILD-SNAPSHOT"
12
-	compile "com.fasterxml.jackson.core:jackson-databind:2.2.0"
13
-}
14
-
15
-task wrapper(type: Wrapper) {
16
-	gradleVersion = '1.5'
17
-}

Двоичные данные
complete/gradle/wrapper/gradle-wrapper.jar Просмотреть файл


+ 0
- 6
complete/gradle/wrapper/gradle-wrapper.properties Просмотреть файл

@@ -1,6 +0,0 @@
1
-#Thu Apr 18 13:47:23 CDT 2013
2
-distributionBase=GRADLE_USER_HOME
3
-distributionPath=wrapper/dists
4
-zipStoreBase=GRADLE_USER_HOME
5
-zipStorePath=wrapper/dists
6
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip

+ 0
- 164
complete/gradlew Просмотреть файл

@@ -1,164 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-##############################################################################
4
-##
5
-##  Gradle start up script for UN*X
6
-##
7
-##############################################################################
8
-
9
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
-DEFAULT_JVM_OPTS=""
11
-
12
-APP_NAME="Gradle"
13
-APP_BASE_NAME=`basename "$0"`
14
-
15
-# Use the maximum available, or set MAX_FD != -1 to use that value.
16
-MAX_FD="maximum"
17
-
18
-warn ( ) {
19
-    echo "$*"
20
-}
21
-
22
-die ( ) {
23
-    echo
24
-    echo "$*"
25
-    echo
26
-    exit 1
27
-}
28
-
29
-# OS specific support (must be 'true' or 'false').
30
-cygwin=false
31
-msys=false
32
-darwin=false
33
-case "`uname`" in
34
-  CYGWIN* )
35
-    cygwin=true
36
-    ;;
37
-  Darwin* )
38
-    darwin=true
39
-    ;;
40
-  MINGW* )
41
-    msys=true
42
-    ;;
43
-esac
44
-
45
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
46
-if $cygwin ; then
47
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
-fi
49
-
50
-# Attempt to set APP_HOME
51
-# Resolve links: $0 may be a link
52
-PRG="$0"
53
-# Need this for relative symlinks.
54
-while [ -h "$PRG" ] ; do
55
-    ls=`ls -ld "$PRG"`
56
-    link=`expr "$ls" : '.*-> \(.*\)$'`
57
-    if expr "$link" : '/.*' > /dev/null; then
58
-        PRG="$link"
59
-    else
60
-        PRG=`dirname "$PRG"`"/$link"
61
-    fi
62
-done
63
-SAVED="`pwd`"
64
-cd "`dirname \"$PRG\"`/" >&-
65
-APP_HOME="`pwd -P`"
66
-cd "$SAVED" >&-
67
-
68
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69
-
70
-# Determine the Java command to use to start the JVM.
71
-if [ -n "$JAVA_HOME" ] ; then
72
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73
-        # IBM's JDK on AIX uses strange locations for the executables
74
-        JAVACMD="$JAVA_HOME/jre/sh/java"
75
-    else
76
-        JAVACMD="$JAVA_HOME/bin/java"
77
-    fi
78
-    if [ ! -x "$JAVACMD" ] ; then
79
-        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80
-
81
-Please set the JAVA_HOME variable in your environment to match the
82
-location of your Java installation."
83
-    fi
84
-else
85
-    JAVACMD="java"
86
-    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87
-
88
-Please set the JAVA_HOME variable in your environment to match the
89
-location of your Java installation."
90
-fi
91
-
92
-# Increase the maximum file descriptors if we can.
93
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94
-    MAX_FD_LIMIT=`ulimit -H -n`
95
-    if [ $? -eq 0 ] ; then
96
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97
-            MAX_FD="$MAX_FD_LIMIT"
98
-        fi
99
-        ulimit -n $MAX_FD
100
-        if [ $? -ne 0 ] ; then
101
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
102
-        fi
103
-    else
104
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105
-    fi
106
-fi
107
-
108
-# For Darwin, add options to specify how the application appears in the dock
109
-if $darwin; then
110
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111
-fi
112
-
113
-# For Cygwin, switch paths to Windows format before running java
114
-if $cygwin ; then
115
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117
-
118
-    # We build the pattern for arguments to be converted via cygpath
119
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
-    SEP=""
121
-    for dir in $ROOTDIRSRAW ; do
122
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
123
-        SEP="|"
124
-    done
125
-    OURCYGPATTERN="(^($ROOTDIRS))"
126
-    # Add a user-defined pattern to the cygpath arguments
127
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
-    fi
130
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
-    i=0
132
-    for arg in "$@" ; do
133
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
135
-
136
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
137
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
-        else
139
-            eval `echo args$i`="\"$arg\""
140
-        fi
141
-        i=$((i+1))
142
-    done
143
-    case $i in
144
-        (0) set -- ;;
145
-        (1) set -- "$args0" ;;
146
-        (2) set -- "$args0" "$args1" ;;
147
-        (3) set -- "$args0" "$args1" "$args2" ;;
148
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
-    esac
155
-fi
156
-
157
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158
-function splitJvmOpts() {
159
-    JVM_OPTS=("$@")
160
-}
161
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163
-
164
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 0
- 90
complete/gradlew.bat Просмотреть файл

@@ -1,90 +0,0 @@
1
-@if "%DEBUG%" == "" @echo off
2
-@rem ##########################################################################
3
-@rem
4
-@rem  Gradle startup script for Windows
5
-@rem
6
-@rem ##########################################################################
7
-
8
-@rem Set local scope for the variables with windows NT shell
9
-if "%OS%"=="Windows_NT" setlocal
10
-
11
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
-set DEFAULT_JVM_OPTS=
13
-
14
-set DIRNAME=%~dp0
15
-if "%DIRNAME%" == "" set DIRNAME=.
16
-set APP_BASE_NAME=%~n0
17
-set APP_HOME=%DIRNAME%
18
-
19
-@rem Find java.exe
20
-if defined JAVA_HOME goto findJavaFromJavaHome
21
-
22
-set JAVA_EXE=java.exe
23
-%JAVA_EXE% -version >NUL 2>&1
24
-if "%ERRORLEVEL%" == "0" goto init
25
-
26
-echo.
27
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
-echo.
29
-echo Please set the JAVA_HOME variable in your environment to match the
30
-echo location of your Java installation.
31
-
32
-goto fail
33
-
34
-:findJavaFromJavaHome
35
-set JAVA_HOME=%JAVA_HOME:"=%
36
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
-
38
-if exist "%JAVA_EXE%" goto init
39
-
40
-echo.
41
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
-echo.
43
-echo Please set the JAVA_HOME variable in your environment to match the
44
-echo location of your Java installation.
45
-
46
-goto fail
47
-
48
-:init
49
-@rem Get command-line arguments, handling Windowz variants
50
-
51
-if not "%OS%" == "Windows_NT" goto win9xME_args
52
-if "%@eval[2+2]" == "4" goto 4NT_args
53
-
54
-:win9xME_args
55
-@rem Slurp the command line arguments.
56
-set CMD_LINE_ARGS=
57
-set _SKIP=2
58
-
59
-:win9xME_args_slurp
60
-if "x%~1" == "x" goto execute
61
-
62
-set CMD_LINE_ARGS=%*
63
-goto execute
64
-
65
-:4NT_args
66
-@rem Get arguments from the 4NT Shell from JP Software
67
-set CMD_LINE_ARGS=%$
68
-
69
-:execute
70
-@rem Setup the command line
71
-
72
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
-
74
-@rem Execute Gradle
75
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
-
77
-:end
78
-@rem End local scope for the variables with windows NT shell
79
-if "%ERRORLEVEL%"=="0" goto mainEnd
80
-
81
-:fail
82
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
-rem the _cmd.exe /c_ return code!
84
-if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
-exit /b 1
86
-
87
-:mainEnd
88
-if "%OS%"=="Windows_NT" endlocal
89
-
90
-:omega

+ 46
- 45
complete/pom.xml Просмотреть файл

@@ -1,54 +1,55 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
-	<modelVersion>4.0.0</modelVersion>
3
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5 5
 
6
-	<groupId>org.springframework</groupId>
7
-	<artifactId>gs-rest-service-complete</artifactId>
8
-	<version>1.0</version>
6
+    <groupId>org.springframework</groupId>
7
+    <artifactId>gs-rest-service-complete</artifactId>
8
+    <version>1.0</version>
9 9
 
10
-	<parent>
11
-		<groupId>org.springframework.bootstrap</groupId>
12
-		<artifactId>spring-bootstrap-starters</artifactId>
13
-		<version>0.5.0.BUILD-SNAPSHOT</version>
14
-	</parent>
10
+    <parent>
11
+        <groupId>org.springframework.bootstrap</groupId>
12
+        <artifactId>spring-bootstrap-starters</artifactId>
13
+        <version>0.5.0.BUILD-SNAPSHOT</version>
14
+    </parent>
15 15
 
16
-	<properties>
17
-		<start-class>hello.HelloWorldConfiguration</start-class>
18
-	</properties>
16
+    <dependencies>
17
+        <dependency>
18
+            <groupId>org.springframework.bootstrap</groupId>
19
+            <artifactId>spring-bootstrap-web-starter</artifactId>
20
+        </dependency>
21
+        <dependency>
22
+            <groupId>com.fasterxml.jackson.core</groupId>
23
+            <artifactId>jackson-databind</artifactId>
24
+        </dependency>
25
+    </dependencies>
19 26
 
20
-	<dependencies>
21
-		<dependency>
22
-			<groupId>org.springframework.bootstrap</groupId>
23
-			<artifactId>spring-bootstrap-web-starter</artifactId>
24
-		</dependency>
25
-		<dependency>
26
-			<groupId>com.fasterxml.jackson.core</groupId>
27
-			<artifactId>jackson-databind</artifactId>
28
-		</dependency>
29
-	</dependencies>
27
+    <properties>
28
+        <start-class>hello.ServiceMain</start-class>
29
+    </properties>
30 30
 
31
-	<build>
32
-		<plugins>
33
-			<plugin>
34
-				<groupId>org.apache.maven.plugins</groupId>
35
-				<artifactId>maven-shade-plugin</artifactId>
36
-			</plugin>
37
-		</plugins>
38
-	</build>
31
+    <build>
32
+        <plugins>
33
+            <plugin>
34
+                <groupId>org.apache.maven.plugins</groupId>
35
+                <artifactId>maven-shade-plugin</artifactId>
36
+            </plugin>
37
+        </plugins>
38
+    </build>
39 39
 
40
-	<repositories>
41
-		<repository>
42
-			<id>spring-snapshots</id>
43
-			<url>http://repo.springsource.org/snapshot</url>
44
-			<snapshots><enabled>true</enabled></snapshots>
45
-		</repository>
46
-	</repositories>
47
-	<pluginRepositories>
48
-		<pluginRepository>
49
-			<id>spring-snapshots</id>
50
-			<url>http://repo.springsource.org/snapshot</url>
51
-			<snapshots><enabled>true</enabled></snapshots>
52
-		</pluginRepository>
53
-	</pluginRepositories>
40
+    <!-- TODO: remove once bootstrap goes GA -->
41
+    <repositories>
42
+        <repository>
43
+            <id>spring-snapshots</id>
44
+            <url>http://repo.springsource.org/snapshot</url>
45
+            <snapshots><enabled>true</enabled></snapshots>
46
+        </repository>
47
+    </repositories>
48
+    <pluginRepositories>
49
+        <pluginRepository>
50
+            <id>spring-snapshots</id>
51
+            <url>http://repo.springsource.org/snapshot</url>
52
+            <snapshots><enabled>true</enabled></snapshots>
53
+        </pluginRepository>
54
+    </pluginRepositories>
54 55
 </project>

+ 0
- 1
complete/settings.gradle Просмотреть файл

@@ -1 +0,0 @@
1
-rootProject.name = 'gs-rest-service-complete'

+ 12
- 13
complete/src/main/java/hello/Greeting.java Просмотреть файл

@@ -2,20 +2,19 @@ package hello;
2 2
 
3 3
 public class Greeting {
4 4
 
5
-	private final long id;
6
-	private final String content;
5
+    private final long id;
6
+    private final String content;
7 7
 
8
-	public Greeting(long id, String content) {
9
-		this.id = id;
10
-		this.content = content;
11
-	}
8
+    public Greeting(long id, String content) {
9
+        this.id = id;
10
+        this.content = content;
11
+    }
12 12
 
13
-	public long getId() {
14
-		return id;
15
-	}
16
-
17
-	public String getContent() {
18
-		return content;
19
-	}
13
+    public long getId() {
14
+        return id;
15
+    }
20 16
 
17
+    public String getContent() {
18
+        return content;
19
+    }
21 20
 }

+ 21
- 0
complete/src/main/java/hello/GreetingController.java Просмотреть файл

@@ -0,0 +1,21 @@
1
+package hello;
2
+
3
+import java.util.concurrent.atomic.AtomicLong;
4
+import org.springframework.stereotype.Controller;
5
+import org.springframework.web.bind.annotation.RequestMapping;
6
+import org.springframework.web.bind.annotation.RequestParam;
7
+import org.springframework.web.bind.annotation.ResponseBody;
8
+
9
+@Controller
10
+public class GreetingController {
11
+
12
+    private static final String template = "Hello, %s!";
13
+    private final AtomicLong counter = new AtomicLong();
14
+
15
+    @RequestMapping("/greeting")
16
+    public @ResponseBody Greeting greeting(
17
+            @RequestParam(value="name", required=false, defaultValue="World") String name) {
18
+        return new Greeting(counter.incrementAndGet(),
19
+                            String.format(template, name));
20
+    }
21
+}

+ 0
- 18
complete/src/main/java/hello/HelloWorldConfiguration.java Просмотреть файл

@@ -1,18 +0,0 @@
1
-package hello;
2
-
3
-import org.springframework.bootstrap.SpringApplication;
4
-import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration;
5
-import org.springframework.context.annotation.ComponentScan;
6
-import org.springframework.context.annotation.Configuration;
7
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
8
-
9
-@Configuration
10
-@EnableAutoConfiguration
11
-@EnableWebMvc
12
-@ComponentScan
13
-public class HelloWorldConfiguration {
14
-	
15
-	public static void main(String[] args) {
16
-		SpringApplication.run(HelloWorldConfiguration.class, args);
17
-	}
18
-} 

+ 0
- 24
complete/src/main/java/hello/HelloWorldController.java Просмотреть файл

@@ -1,24 +0,0 @@
1
-package hello;
2
-
3
-import java.util.concurrent.atomic.AtomicLong;
4
-
5
-import org.springframework.stereotype.Controller;
6
-import org.springframework.web.bind.annotation.RequestMapping;
7
-import org.springframework.web.bind.annotation.RequestMethod;
8
-import org.springframework.web.bind.annotation.RequestParam;
9
-import org.springframework.web.bind.annotation.ResponseBody;
10
-
11
-@Controller
12
-@RequestMapping("/hello-world")
13
-public class HelloWorldController {
14
-
15
-	private static final String template = "Hello, %s!";
16
-	private final AtomicLong counter = new AtomicLong();
17
-	
18
-    @RequestMapping(method=RequestMethod.GET)
19
-    public @ResponseBody Greeting sayHello(
20
-            @RequestParam(value="name", required=false, defaultValue="World") String name) {
21
-        return new Greeting(counter.incrementAndGet(), String.format(template, name));
22
-    }
23
-
24
-}

+ 14
- 0
complete/src/main/java/hello/ServiceMain.java Просмотреть файл

@@ -0,0 +1,14 @@
1
+package hello;
2
+
3
+import org.springframework.bootstrap.SpringApplication;
4
+import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration;
5
+import org.springframework.context.annotation.ComponentScan;
6
+
7
+@ComponentScan
8
+@EnableAutoConfiguration
9
+public class ServiceMain {
10
+
11
+    public static void main(String[] args) {
12
+        SpringApplication.run(ServiceMain.class, args);
13
+    }
14
+}

+ 0
- 17
initial/build.gradle Просмотреть файл

@@ -1,17 +0,0 @@
1
-apply plugin: 'java'
2
-apply plugin: 'eclipse-wtp'
3
-apply plugin: 'idea'
4
-apply plugin: 'application'
5
-
6
-mainClassName = "hello.HelloWorlConfiguration"
7
-
8
-repositories { mavenCentral() }
9
-
10
-dependencies {
11
-	compile "org.springframework.bootstrap:spring-bootstrap-web-starter:0.5.0.BUILD-SNAPSHOT"
12
-	compile "com.fasterxml.jackson.core:jackson-databind:2.2.0"
13
-}
14
-
15
-task wrapper(type: Wrapper) {
16
-	gradleVersion = '1.5'
17
-}

Двоичные данные
initial/gradle/wrapper/gradle-wrapper.jar Просмотреть файл


+ 0
- 6
initial/gradle/wrapper/gradle-wrapper.properties Просмотреть файл

@@ -1,6 +0,0 @@
1
-#Thu Apr 18 13:47:12 CDT 2013
2
-distributionBase=GRADLE_USER_HOME
3
-distributionPath=wrapper/dists
4
-zipStoreBase=GRADLE_USER_HOME
5
-zipStorePath=wrapper/dists
6
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip

+ 0
- 164
initial/gradlew Просмотреть файл

@@ -1,164 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-##############################################################################
4
-##
5
-##  Gradle start up script for UN*X
6
-##
7
-##############################################################################
8
-
9
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
-DEFAULT_JVM_OPTS=""
11
-
12
-APP_NAME="Gradle"
13
-APP_BASE_NAME=`basename "$0"`
14
-
15
-# Use the maximum available, or set MAX_FD != -1 to use that value.
16
-MAX_FD="maximum"
17
-
18
-warn ( ) {
19
-    echo "$*"
20
-}
21
-
22
-die ( ) {
23
-    echo
24
-    echo "$*"
25
-    echo
26
-    exit 1
27
-}
28
-
29
-# OS specific support (must be 'true' or 'false').
30
-cygwin=false
31
-msys=false
32
-darwin=false
33
-case "`uname`" in
34
-  CYGWIN* )
35
-    cygwin=true
36
-    ;;
37
-  Darwin* )
38
-    darwin=true
39
-    ;;
40
-  MINGW* )
41
-    msys=true
42
-    ;;
43
-esac
44
-
45
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
46
-if $cygwin ; then
47
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
-fi
49
-
50
-# Attempt to set APP_HOME
51
-# Resolve links: $0 may be a link
52
-PRG="$0"
53
-# Need this for relative symlinks.
54
-while [ -h "$PRG" ] ; do
55
-    ls=`ls -ld "$PRG"`
56
-    link=`expr "$ls" : '.*-> \(.*\)$'`
57
-    if expr "$link" : '/.*' > /dev/null; then
58
-        PRG="$link"
59
-    else
60
-        PRG=`dirname "$PRG"`"/$link"
61
-    fi
62
-done
63
-SAVED="`pwd`"
64
-cd "`dirname \"$PRG\"`/" >&-
65
-APP_HOME="`pwd -P`"
66
-cd "$SAVED" >&-
67
-
68
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69
-
70
-# Determine the Java command to use to start the JVM.
71
-if [ -n "$JAVA_HOME" ] ; then
72
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73
-        # IBM's JDK on AIX uses strange locations for the executables
74
-        JAVACMD="$JAVA_HOME/jre/sh/java"
75
-    else
76
-        JAVACMD="$JAVA_HOME/bin/java"
77
-    fi
78
-    if [ ! -x "$JAVACMD" ] ; then
79
-        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80
-
81
-Please set the JAVA_HOME variable in your environment to match the
82
-location of your Java installation."
83
-    fi
84
-else
85
-    JAVACMD="java"
86
-    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87
-
88
-Please set the JAVA_HOME variable in your environment to match the
89
-location of your Java installation."
90
-fi
91
-
92
-# Increase the maximum file descriptors if we can.
93
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94
-    MAX_FD_LIMIT=`ulimit -H -n`
95
-    if [ $? -eq 0 ] ; then
96
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97
-            MAX_FD="$MAX_FD_LIMIT"
98
-        fi
99
-        ulimit -n $MAX_FD
100
-        if [ $? -ne 0 ] ; then
101
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
102
-        fi
103
-    else
104
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105
-    fi
106
-fi
107
-
108
-# For Darwin, add options to specify how the application appears in the dock
109
-if $darwin; then
110
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111
-fi
112
-
113
-# For Cygwin, switch paths to Windows format before running java
114
-if $cygwin ; then
115
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117
-
118
-    # We build the pattern for arguments to be converted via cygpath
119
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
-    SEP=""
121
-    for dir in $ROOTDIRSRAW ; do
122
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
123
-        SEP="|"
124
-    done
125
-    OURCYGPATTERN="(^($ROOTDIRS))"
126
-    # Add a user-defined pattern to the cygpath arguments
127
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
-    fi
130
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
-    i=0
132
-    for arg in "$@" ; do
133
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
135
-
136
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
137
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
-        else
139
-            eval `echo args$i`="\"$arg\""
140
-        fi
141
-        i=$((i+1))
142
-    done
143
-    case $i in
144
-        (0) set -- ;;
145
-        (1) set -- "$args0" ;;
146
-        (2) set -- "$args0" "$args1" ;;
147
-        (3) set -- "$args0" "$args1" "$args2" ;;
148
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
-    esac
155
-fi
156
-
157
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158
-function splitJvmOpts() {
159
-    JVM_OPTS=("$@")
160
-}
161
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163
-
164
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 0
- 90
initial/gradlew.bat Просмотреть файл

@@ -1,90 +0,0 @@
1
-@if "%DEBUG%" == "" @echo off
2
-@rem ##########################################################################
3
-@rem
4
-@rem  Gradle startup script for Windows
5
-@rem
6
-@rem ##########################################################################
7
-
8
-@rem Set local scope for the variables with windows NT shell
9
-if "%OS%"=="Windows_NT" setlocal
10
-
11
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
-set DEFAULT_JVM_OPTS=
13
-
14
-set DIRNAME=%~dp0
15
-if "%DIRNAME%" == "" set DIRNAME=.
16
-set APP_BASE_NAME=%~n0
17
-set APP_HOME=%DIRNAME%
18
-
19
-@rem Find java.exe
20
-if defined JAVA_HOME goto findJavaFromJavaHome
21
-
22
-set JAVA_EXE=java.exe
23
-%JAVA_EXE% -version >NUL 2>&1
24
-if "%ERRORLEVEL%" == "0" goto init
25
-
26
-echo.
27
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
-echo.
29
-echo Please set the JAVA_HOME variable in your environment to match the
30
-echo location of your Java installation.
31
-
32
-goto fail
33
-
34
-:findJavaFromJavaHome
35
-set JAVA_HOME=%JAVA_HOME:"=%
36
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
-
38
-if exist "%JAVA_EXE%" goto init
39
-
40
-echo.
41
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
-echo.
43
-echo Please set the JAVA_HOME variable in your environment to match the
44
-echo location of your Java installation.
45
-
46
-goto fail
47
-
48
-:init
49
-@rem Get command-line arguments, handling Windowz variants
50
-
51
-if not "%OS%" == "Windows_NT" goto win9xME_args
52
-if "%@eval[2+2]" == "4" goto 4NT_args
53
-
54
-:win9xME_args
55
-@rem Slurp the command line arguments.
56
-set CMD_LINE_ARGS=
57
-set _SKIP=2
58
-
59
-:win9xME_args_slurp
60
-if "x%~1" == "x" goto execute
61
-
62
-set CMD_LINE_ARGS=%*
63
-goto execute
64
-
65
-:4NT_args
66
-@rem Get arguments from the 4NT Shell from JP Software
67
-set CMD_LINE_ARGS=%$
68
-
69
-:execute
70
-@rem Setup the command line
71
-
72
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
-
74
-@rem Execute Gradle
75
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
-
77
-:end
78
-@rem End local scope for the variables with windows NT shell
79
-if "%ERRORLEVEL%"=="0" goto mainEnd
80
-
81
-:fail
82
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
-rem the _cmd.exe /c_ return code!
84
-if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
-exit /b 1
86
-
87
-:mainEnd
88
-if "%OS%"=="Windows_NT" endlocal
89
-
90
-:omega

+ 35
- 34
initial/pom.xml Просмотреть файл

@@ -1,41 +1,42 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
-	<modelVersion>4.0.0</modelVersion>
3
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5 5
 
6
-	<groupId>org.springframework</groupId>
7
-	<artifactId>gs-rest-service</artifactId>
8
-	<version>1.0</version>
6
+    <groupId>org.springframework</groupId>
7
+    <artifactId>gs-rest-service</artifactId>
8
+    <version>1.0</version>
9 9
 
10
-	<parent>
11
-		<groupId>org.springframework.bootstrap</groupId>
12
-		<artifactId>spring-bootstrap-starters</artifactId>
13
-		<version>0.5.0.BUILD-SNAPSHOT</version>
14
-	</parent>
10
+    <parent>
11
+        <groupId>org.springframework.bootstrap</groupId>
12
+        <artifactId>spring-bootstrap-starters</artifactId>
13
+        <version>0.5.0.BUILD-SNAPSHOT</version>
14
+    </parent>
15 15
 
16
-	<dependencies>
17
-		<dependency>
18
-			<groupId>org.springframework.bootstrap</groupId>
19
-			<artifactId>spring-bootstrap-web-starter</artifactId>
20
-		</dependency>
21
-		<dependency>
22
-			<groupId>com.fasterxml.jackson.core</groupId>
23
-			<artifactId>jackson-databind</artifactId>
24
-		</dependency>
25
-	</dependencies>
16
+    <dependencies>
17
+        <dependency>
18
+            <groupId>org.springframework.bootstrap</groupId>
19
+            <artifactId>spring-bootstrap-web-starter</artifactId>
20
+        </dependency>
21
+        <dependency>
22
+            <groupId>com.fasterxml.jackson.core</groupId>
23
+            <artifactId>jackson-databind</artifactId>
24
+        </dependency>
25
+    </dependencies>
26 26
 
27
-	<repositories>
28
-		<repository>
29
-			<id>spring-snapshots</id>
30
-			<url>http://repo.springsource.org/snapshot</url>
31
-			<snapshots><enabled>true</enabled></snapshots>
32
-		</repository>
33
-	</repositories>
34
-	<pluginRepositories>
35
-		<pluginRepository>
36
-			<id>spring-snapshots</id>
37
-			<url>http://repo.springsource.org/snapshot</url>
38
-			<snapshots><enabled>true</enabled></snapshots>
39
-		</pluginRepository>
40
-	</pluginRepositories>
27
+    <!-- TODO: remove once bootstrap goes GA -->
28
+    <repositories>
29
+        <repository>
30
+            <id>spring-snapshots</id>
31
+            <url>http://repo.springsource.org/snapshot</url>
32
+            <snapshots><enabled>true</enabled></snapshots>
33
+        </repository>
34
+    </repositories>
35
+    <pluginRepositories>
36
+        <pluginRepository>
37
+            <id>spring-snapshots</id>
38
+            <url>http://repo.springsource.org/snapshot</url>
39
+            <snapshots><enabled>true</enabled></snapshots>
40
+        </pluginRepository>
41
+    </pluginRepositories>
41 42
 </project>

+ 0
- 1
initial/settings.gradle Просмотреть файл

@@ -1 +0,0 @@
1
-rootProject.name = 'gs-rest-service-start'

+ 0
- 0
initial/src/main/java/hello/.gitignore Просмотреть файл


+ 0
- 12
initial/src/main/java/hello/HelloWorldConfiguration.java Просмотреть файл

@@ -1,12 +0,0 @@
1
-package hello;
2
-
3
-import org.springframework.context.annotation.ComponentScan;
4
-import org.springframework.context.annotation.Configuration;
5
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6
-
7
-@Configuration
8
-@EnableWebMvc
9
-@ComponentScan
10
-public class HelloWorldConfiguration {
11
-	
12
-} 

+ 1
- 1
test/run.sh Просмотреть файл

@@ -4,7 +4,7 @@ mvn package
4 4
 java -jar target/gs-rest-service-complete-1.0.jar &
5 5
 PID=$!
6 6
 sleep 3
7
-curl -s http://localhost:8080/hello-world > target/actual.json
7
+curl -s http://localhost:8080/greeting > target/actual.json
8 8
 kill -9 $PID
9 9
 
10 10
 if diff -w ../test/expected.json target/actual.json