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

net.dongliu.prettypb.rpc.config.ConfigServerProvider Maven / Gradle / Ivy

There is a newer version: 0.3.5
Show newest version
package net.dongliu.prettypb.rpc.config;


import net.dongliu.prettypb.rpc.protocol.ServerInfo;

import java.util.*;

/**
 * provide rpc servers by manual set
 *
 * @author dongliu
 */
public class ConfigServerProvider extends ServerProvider {

    private List serverInfoList;

    public ConfigServerProvider() {
        serverInfoList = new ArrayList<>();
    }

    public ConfigServerProvider(ServerInfo... serverInfos) {
        serverInfoList = Arrays.asList(serverInfos);
    }

    /**
     * add new server
     */
    public void addServer(ServerInfo serverInfo) {
        this.serverInfoList.add(serverInfo);
        serverChangedNotifier.notifyAdd(serverInfo);
    }

    /**
     * remove server
     */
    public void removeServer(ServerInfo serverInfo) {
        this.serverInfoList.remove(serverInfo);
        serverChangedNotifier.notifyRemove(serverInfo);
    }

    @Override
    public Collection availableServers() {
        return Collections.unmodifiableList(serverInfoList);
    }

    @Override
    public void close() throws Exception {

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy