1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| @Component("annotatedBean") public class AnnotatedBean {
private static final Logger logger = LoggerFactory.getLogger(AnnotatedBean.class);
private int timeout; private int batch; private String dubboApplicationName; private List<JsonBean> jsonBeans;
@ApolloJsonValue("${jsonBeanProperty:[]}") private List<JsonBean> anotherJsonBeans;
@Value("${batch:100}") public void setBatch(int batch) { logger.info("updating batch, old value: {}, new value: {}", this.batch, batch); System.out.println(String.format("updating batch, old value: %s, new value: %s", this.batch, batch)); this.batch = batch; }
@Value("${timeout:200}") public void setTimeout(int timeout) { logger.info("updating timeout, old value: {}, new value: {}", this.timeout, timeout); System.out.println(String.format("updating timeout, old value: %s, new value: %s", this.timeout, timeout)); this.timeout = timeout; }
@Value("${dubbo.application.name}") public void setDubboApplicationName(String dubboApplicationName) { this.dubboApplicationName = dubboApplicationName; }
public String getDubboApplicationName() { return dubboApplicationName; }
@ApolloJsonValue("${jsonBeanProperty:[]}") public void setJsonBeans(List<JsonBean> jsonBeans) { logger.info("updating json beans, old value: {}, new value: {}", this.jsonBeans, jsonBeans); System.out.println(String.format("updating json beans, old value: %s, new value: %s", this.jsonBeans, jsonBeans)); this.jsonBeans = jsonBeans; }
public int getTimeout() { return timeout; }
public int getBatch() { return batch; }
@Override public String toString() { return String.format("[AnnotatedBean] timeout: %d, batch: %d, jsonBeans: %s", timeout, batch, jsonBeans); }
private static class JsonBean { private String someString; private int someInt;
@Override public String toString() { return "JsonBean{" + "someString='" + someString + '\'' + ", someInt=" + someInt + '}'; } } }
|