Bläddra i källkod

Rename implementation classes

Craig Walls 13 år sedan
förälder
incheckning
c5b09857dd
4 ändrade filer med 12 tillägg och 56 borttagningar
  1. 11
    11
      README.md
  2. 1
    1
      build.gradle
  3. 0
    23
      src/main/java/hello/HelloWorldResource.java
  4. 0
    21
      src/main/java/hello/Saying.java

+ 11
- 11
README.md Visa fil

@@ -6,13 +6,13 @@ This Getting Started guide will walk you through the process of creating a simpl
6 6
 To help you get started, we've provided an initial project structure for you in GitHub:
7 7
 
8 8
 ```sh
9
-$ git clone git://github.com/SpringSource/gs-rest-service.git
9
+$ git clone https://github.com/springframework-meta/gs-rest-service.git
10 10
 ```
11 11
 
12 12
 As you work through this guide, you can fill in this project with the code necessary to complete the guide. Or, if you'd prefer to see the end result, the completed project is available in the *completed* branch of the Git repository:
13 13
 
14 14
 ```sh
15
-$ git clone -b completed git://github.com/SpringSource/gs-rest-service.git
15
+$ git clone -b completed https://github.com/springframework-meta/gs-rest-service.git
16 16
 ```
17 17
 
18 18
 Before we can write the REST endpoint itself, there's some initial project setup that's required. Or, you can skip straight to the [fun part]().
@@ -22,7 +22,7 @@ Selecting Dependencies
22 22
 The sample in this Getting Started Guide will leverage Spring MVC and the Jackson JSON processor. Therefore, you'll need to declare the following library dependencies in your build:
23 23
 
24 24
   - org.springframework:spring-webmvc:3.2.2.RELEASE
25
-  - org.codehaus.jackson:jackson-mapper-asl:1.9.9
25
+  - com.fasterxml.jackson.core:jackson-core:2.1.4
26 26
 
27 27
 Click here for details on how to map these dependencies to your specific build tool.
28 28
 
@@ -90,7 +90,7 @@ With the essential Spring MVC configuration out of the way, it's time to get to
90 90
 
91 91
 Before we get too carried away with building the endpoint controller, we need to give some thought to what our API will look like. 
92 92
 
93
-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 looking something like this:
93
+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:
94 94
 
95 95
 ```json
96 96
 {
@@ -99,19 +99,19 @@ What we want is to handle GET requests for /hello-world, optionally with a name
99 99
 }
100 100
 ```
101 101
 	
102
-The id field is a unique identifier for the saying, and content is the textual representation of the saying.
102
+The id field is a unique identifier for the greeting, and content is the textual representation of the greeting.
103 103
 
104
-To model this representation, we’ll create a representation class:
104
+To model the greeting representation, we’ll create a representation class:
105 105
 
106 106
 ```java
107 107
 package hello;
108 108
 
109
-public class Saying {
109
+public class Greeting {
110 110
 
111 111
 	private final long id;
112 112
 	private final String content;
113 113
 
114
-	public Saying(long id, String content) {
114
+	public Greeting(long id, String content) {
115 115
 	this.id = id;
116 116
 	this.content = content;
117 117
 	}
@@ -144,14 +144,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
144 144
 
145 145
 @Controller
146 146
 @RequestMapping("/hello-world")
147
-public class HelloWorldResource {
147
+public class HelloWorldController {
148 148
 	
149 149
 	private static final String template = "Hello, %s!";
150 150
 	private final AtomicLong counter = new AtomicLong();
151 151
 
152 152
 	@RequestMapping(method=RequestMethod.GET)
153
-	public @ResponseBody Saying sayHello(@RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
154
-		return new Saying(counter.incrementAndGet(), String.format(template, name));
153
+	public @ResponseBody Greeting sayHello(@RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
154
+		return new Greeting(counter.incrementAndGet(), String.format(template, name));
155 155
 	}
156 156
 	
157 157
 }

+ 1
- 1
build.gradle Visa fil

@@ -6,7 +6,7 @@ repositories { mavenCentral() }
6 6
 
7 7
 dependencies {
8 8
 	compile "org.springframework:spring-webmvc:3.2.2.RELEASE"
9
-	compile "org.codehaus.jackson:jackson-mapper-asl:1.9.9"
9
+	compile "com.fasterxml.jackson.core:jackson-core:2.1.4"
10 10
 	providedCompile "javax.servlet:servlet-api:2.5"
11 11
 }
12 12
 

+ 0
- 23
src/main/java/hello/HelloWorldResource.java Visa fil

@@ -1,23 +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 HelloWorldResource {
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 Saying sayHello(@RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
20
-		return new Saying(counter.incrementAndGet(), String.format(template, name));
21
-	}
22
-	
23
-}

+ 0
- 21
src/main/java/hello/Saying.java Visa fil

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