1 package de.spring.webservices.rest.controller;
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;
9 import de.spring.stomp.services.RestGreetingService;
13 public class RestGreetingController {
14 private final RestGreetingService restGreetingService;
17 public RestGreetingController(RestGreetingService restGreetingService) {
18 this.restGreetingService = restGreetingService;
21 // Sending data to /topic/greeting from REST service.
22 // POST http://localhost:8080/spring-stomp-server/greetings
24 @RequestMapping(path="/greetings", method=RequestMethod.POST)
25 public void handle(@RequestBody String greeting) {
27 // STOMP clients subscribed to /topic/greeting will receive the data sent by the convertAndSend method.
28 restGreetingService.doGreetings(greeting);