@Test public void addAppChangedListener() throws InterruptedException, IllegalAccessException, NoSuchFieldException { RadarClientConfig config = new RadarClientConfig(rgUrl); config.setHost("1.1.1.1"); DiscoveryClient client = DiscoveryClient.getInstance(); client.setConfig(config); Field field = client.getClass().getDeclaredField("config"); field.setAccessible(true); field.set(client, config); Map<String, String> testMap = new HashMap<>(); client.addAppChangedListener(new AppChangedListener() { @Override public void onAppChanged(AppChangedEvent changeEvent) { testMap.put("1", "2"); } }); client.getApp("1111"); Thread.sleep(1000); Assert.assertEquals("2", testMap.get("1")); }
public synchronized void addAppChangedListener(AppChangedListener changeListener) { if (changeListener != null) { subscribeAll(); changeListeners.add(changeListener); } }
DiscoveryClient { public synchronized void addAppChangedListener(AppChangedListener changeListener) { if (changeListener != null) { subscribeAll(); changeListeners.add(changeListener); } } }
DiscoveryClient { public synchronized void addAppChangedListener(AppChangedListener changeListener) { if (changeListener != null) { subscribeAll(); changeListeners.add(changeListener); } } private  DiscoveryClient(); }
DiscoveryClient { public synchronized void addAppChangedListener(AppChangedListener changeListener) { if (changeListener != null) { subscribeAll(); changeListeners.add(changeListener); } } private  DiscoveryClient(); static DiscoveryClient getInstance(); RadarInstance getInstanceRadar(); RadarClientConfig getConfig(); void setConfig(RadarClientConfig config); boolean isConfiged(); boolean isRegistered(); Map<String, RadarApp> getData(); void register(RadarInstance instanceRadar); synchronized void addAppChangedListener(AppChangedListener changeListener); Map<String, RadarApp> getApps(List<String> appIds); Map<String, RadarApp> getApps(); RadarApp getApp(String appId); void deregister(); AdjustResponse adjust(Boolean isUp); }
DiscoveryClient { public synchronized void addAppChangedListener(AppChangedListener changeListener) { if (changeListener != null) { subscribeAll(); changeListeners.add(changeListener); } } private  DiscoveryClient(); static DiscoveryClient getInstance(); RadarInstance getInstanceRadar(); RadarClientConfig getConfig(); void setConfig(RadarClientConfig config); boolean isConfiged(); boolean isRegistered(); Map<String, RadarApp> getData(); void register(RadarInstance instanceRadar); synchronized void addAppChangedListener(AppChangedListener changeListener); Map<String, RadarApp> getApps(List<String> appIds); Map<String, RadarApp> getApps(); RadarApp getApp(String appId); void deregister(); AdjustResponse adjust(Boolean isUp);  }