diff --git a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/User.java b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/User.java index d1db62d4de8..0ab8215f9d5 100644 --- a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/User.java +++ b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/User.java @@ -20,7 +20,7 @@ public Integer getId() { return id; } - public void setId(Integer id) { + public void setId(final Integer id) { this.id = id; } @@ -28,7 +28,7 @@ public String getName() { return name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -36,7 +36,7 @@ public String getEmail() { return email; } - public void setEmail(String email) { + public void setEmail(final String email) { this.email = email; } } diff --git a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/UserRepository.java b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/UserRepository.java index 5a312c6bb9c..aee13253624 100644 --- a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/UserRepository.java +++ b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/entities/UserRepository.java @@ -5,4 +5,4 @@ // This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository // CRUD refers Create, Read, Update, Delete -public interface UserRepository extends CrudRepository {} +public interface UserRepository extends CrudRepository {} diff --git a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/MySQLResource.java b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/DBResource.java similarity index 74% rename from dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/MySQLResource.java rename to dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/DBResource.java index d7ff943a7e6..a9f822323a0 100644 --- a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/MySQLResource.java +++ b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/DBResource.java @@ -10,19 +10,20 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller // This means that this class is a Controller -@RequestMapping(path = "/demo") // This means URL's start with /demo (after Application path) -public class MySQLResource { +@RequestMapping(path = "/user") // This means URL's start with /demo (after Application path) +public class DBResource { @Autowired // This means to get the bean called userRepository // Which is auto-generated by Spring, we will use it to handle the data private UserRepository userRepository; @GetMapping(path = "/add") // Map ONLY GET Requests - public @ResponseBody String addNewUser(@RequestParam String name, @RequestParam String email) { + public @ResponseBody String addNewUser( + @RequestParam final String name, @RequestParam final String email) { // @ResponseBody means the returned String is the response, not a view name // @RequestParam means it is a parameter from the GET or POST request - User n = new User(); + final User n = new User(); n.setName(name); n.setEmail(email); userRepository.save(n); @@ -34,4 +35,10 @@ public class MySQLResource { // This returns a JSON or XML with the users return userRepository.findAll(); } + + @GetMapping(path = "/get") + public @ResponseBody User getUser(@RequestParam final int id) { + // This returns a JSON or XML with the users + return userRepository.findOne(id); + } } diff --git a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/HelloResource.java b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/HelloResource.java deleted file mode 100644 index c53e2dded31..00000000000 --- a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/HelloResource.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.datadoghq.examples.resources; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/") -public class HelloResource { - - @RequestMapping(method = RequestMethod.GET) - public String test() { - - return "Hello world!"; - } -} diff --git a/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/HomeResource.java b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/HomeResource.java new file mode 100644 index 00000000000..c0fbc74f19e --- /dev/null +++ b/dd-trace-examples/spring-boot-jdbc/src/main/java/com/datadoghq/examples/resources/HomeResource.java @@ -0,0 +1,25 @@ +package com.datadoghq.examples.resources; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/") +public class HomeResource { + + @RequestMapping(method = RequestMethod.GET) + public String test() { + + final StringBuilder template = new StringBuilder(); + + template.append("Demo links"); + template.append(""); + + return template.toString(); + } +}