Skip to content

Instantly share code, notes, and snippets.

@spencergibb
Created April 23, 2015 20:21
Show Gist options
  • Save spencergibb/35b866d178e3977aba3b to your computer and use it in GitHub Desktop.
Save spencergibb/35b866d178e3977aba3b to your computer and use it in GitHub Desktop.
DummyController.java
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