REST Service
Request : 3Tier Architecture
=> Client Tier(Java Server, c# Application), BusinessLogic Tier(REST Web), Database Tier(Oracle)
Env : JDK1.8, Tomcat8, Eclipse, Gradle, SpringFrame4
Client Tier(JavaServer) : User RestTemplate in SpringFramework4
BusinessLogic Tier(REST Web) : Use the @RestController in SprinFramework4
Ref : https://spring.io/guides/gs/rest-service/
src/main/java/hello/GreetingController.java
package hello;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}
}
|