Created
          April 23, 2015 20:21 
        
      - 
      
- 
        Save spencergibb/35b866d178e3977aba3b to your computer and use it in GitHub Desktop. 
    DummyController.java
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.example.web; | |
| import com.example.common.CustomRemoteEvent; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.beans.factory.annotation.Value; | |
| import org.springframework.cloud.context.config.annotation.RefreshScope; | |
| import org.springframework.context.ApplicationContext; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| import org.springframework.web.bind.annotation.RestController; | |
| import java.util.HashMap; | |
| @Slf4j | |
| @RefreshScope | |
| @RestController | |
| @RequestMapping("/dummy") | |
| public class DummyController { | |
| @Value("${configuration.projectName}") | |
| private String projectName; | |
| @Value("${configuration.instance.id}") | |
| private String instanceId; | |
| @Autowired | |
| private ApplicationContext context; | |
| @RequestMapping("/name") | |
| public String projectName() { | |
| return this.projectName; | |
| } | |
| @RequestMapping("/foo") | |
| public void foo(){ | |
| log.info("Publishing custom event"); | |
| context.publishEvent(new CustomRemoteEvent(this, context.getId(), new HashMap<String, String>(){{ | |
| put("message", "this is a test!"); | |
| }})); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment