-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathControllerSpring.java
More file actions
28 lines (23 loc) · 980 Bytes
/
ControllerSpring.java
File metadata and controls
28 lines (23 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package spring.basic;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.atomic.AtomicLong;
@RestController
public class ControllerSpring {
//
/**
* @ AtomicLong
* @Function: The AtomicLong class provides you with a long variable
* which can be read and written atomically, and
* which also contains advanced atomic operations like compareAndSet().
* @Proccess: Function is updating id, as well.
**/
private static final String template = "Hello, %s !";
private final AtomicLong counter = new AtomicLong();
@GetMapping("/hey")
public HelloSpring Greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
System.out.println("running");
return new HelloSpring(counter.incrementAndGet(), String.format(template, name));
}
}