TODO:配置
This commit is contained in:
parent
f8dddd0fe4
commit
3d7ffe0c52
|
@ -29,8 +29,54 @@ import com.google.api.client.http.InputStreamContent;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
private static Config cnf = new Config();
|
||||
public static Config GetConfig() {
|
||||
private Config() throws NacosException, IOException {
|
||||
String serverAddr = "192.168.1.113:8848";
|
||||
String dataId = "dataflow";
|
||||
String group = "yuandian";
|
||||
|
||||
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
|
||||
ConfigService configService = NacosFactory.createConfigService(properties);
|
||||
String content = configService.getConfig(dataId, group, 5000);
|
||||
|
||||
|
||||
|
||||
Prop.load(new StringReader(content));
|
||||
|
||||
System.out.println(cnf);
|
||||
|
||||
configService.addListener(dataId, group, new Listener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
System.out.println("recieve:" + configInfo);
|
||||
try {
|
||||
Prop.load(new StringReader(configInfo));
|
||||
System.out.println(cnf);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getExecutor() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Properties Prop ;
|
||||
|
||||
private static Config cnf ;
|
||||
public Config(Properties prop) {
|
||||
Prop = prop;
|
||||
}
|
||||
|
||||
public static Config GetConfig() throws NacosException, IOException {
|
||||
if(cnf == null) {
|
||||
cnf = new Config();
|
||||
}
|
||||
return cnf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user