|
| 1 | +/* |
| 2 | + * Copyright 2012-2015 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package sample.metrics.redis; |
| 18 | + |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.Map; |
| 21 | + |
| 22 | +import org.hibernate.validator.constraints.NotBlank; |
| 23 | +import org.springframework.beans.factory.annotation.Autowired; |
| 24 | +import org.springframework.context.annotation.Description; |
| 25 | +import org.springframework.stereotype.Controller; |
| 26 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 27 | +import org.springframework.web.bind.annotation.RequestMethod; |
| 28 | +import org.springframework.web.bind.annotation.ResponseBody; |
| 29 | + |
| 30 | +@Controller |
| 31 | +@Description("A controller for handling requests for hello messages") |
| 32 | +public class SampleController { |
| 33 | + |
| 34 | + @Autowired |
| 35 | + private HelloWorldService helloWorldService; |
| 36 | + |
| 37 | + @RequestMapping(value = "/", method = RequestMethod.GET) |
| 38 | + @ResponseBody |
| 39 | + public Map<String, String> hello() { |
| 40 | + return Collections.singletonMap("message", |
| 41 | + this.helloWorldService.getHelloMessage()); |
| 42 | + } |
| 43 | + |
| 44 | + protected static class Message { |
| 45 | + |
| 46 | + @NotBlank(message = "Message value cannot be empty") |
| 47 | + private String value; |
| 48 | + |
| 49 | + public String getValue() { |
| 50 | + return this.value; |
| 51 | + } |
| 52 | + |
| 53 | + public void setValue(String value) { |
| 54 | + this.value = value; |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | +} |
0 commit comments