All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.ruedigermoeller.fastcast.config.FCLocalClusterConf Maven / Gradle / Ivy

There is a newer version: 3.10
Show newest version
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