de.ruedigermoeller.fastcast.config.FCLocalClusterConf Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fast-cast Show documentation
Show all versions of fast-cast Show documentation
a fast brokerless messaging library based on reliable UDP multicast
package de.ruedigermoeller.fastcast.config;
import de.ruedigermoeller.fastcast.transport.FCSocketConf;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.Node;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
/**
* Created with IntelliJ IDEA.
* User: moelrue
* Date: 9/17/13
* Time: 4:32 PM
* To change this template use File | Settings | File Templates.
*/
public class FCLocalClusterConf {
HashMap interfaces = new HashMap<>();
HashMap transports[];
HashMap [] topics;
public HashMap getInterfaces() {
return interfaces;
}
public void setInterfaces(HashMap interfaces) {
this.interfaces = interfaces;
}
public HashMap[] getTransports() {
return transports;
}
public void setTransports(HashMap[] transports) {
this.transports = transports;
}
public HashMap[] getTopics() {
return topics;
}
public void setTopics(HashMap[] topics) {
this.topics = topics;
}
public static FCLocalClusterConf read(String finam) throws IOException {
Yaml yaml = new Yaml(new Constructor(){
@Override
protected Class> getClassForNode(Node node) {
String name = node.getTag().getValue();
if ( "!topic".equals(name)) {
return FCTopicConf.class;
}
if ( "!socket".equals(name) ) {
return FCSocketConf.class;
}
return super.getClassForNode(node);
}
});
FileReader reader = new FileReader(finam);
FCLocalClusterConf conf = (FCLocalClusterConf) yaml.loadAs(reader, FCLocalClusterConf.class);
reader.close();
return conf;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy