ebb32ed1b09916e4fc6b58ee5bb7f84eb1062548
[JavaForFun] /
1 package de.spring.webservices.rest.controller;
2
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.web.bind.annotation.RequestBody;
5 import org.springframework.web.bind.annotation.RequestMapping;
6 import org.springframework.web.bind.annotation.RequestMethod;
7 import org.springframework.web.bind.annotation.RestController;
8
9 import de.spring.stomp.services.RestGreetingService;
10
11
12 @RestController
13 public class RestGreetingController {
14         private final RestGreetingService restGreetingService;
15
16     @Autowired
17     public RestGreetingController(RestGreetingService restGreetingService) {
18         this.restGreetingService = restGreetingService;
19     }
20
21     // Sending data to /topic/greeting from REST service.
22         // POST http://localhost:8080/spring-stomp-server/greetings
23     
24         @RequestMapping(path="/greetings", method=RequestMethod.POST)
25     public void handle(@RequestBody String greeting) {
26                 
27                 // STOMP clients subscribed to /topic/greeting will receive the data sent by the convertAndSend method.
28                 restGreetingService.doGreetings(greeting);
29     }
30
31 }