package org.kne.cloud.network.klalb;

import java.io.FileReader;
import java.net.UnknownHostException;
import java.util.ArrayList;

import org.kne.cloud.network.MultiProtocolSocketAddress;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;

import java.io.File;
import java.io.FileNotFoundException;

public class KLALBConfig extends ArrayList<KLALBConfigItem>{

	public KLALBConfig(){
	}
	public static KLALBConfig getDefault(){
		KLALBConfig config=new KLALBConfig();
		config.add(new KLALBControllerConfigItem());
		return config;
	}
	public static void main(String[] args) throws UnknownHostException, JsonSyntaxException, JsonIOException, FileNotFoundException {
		GsonBuilder gb=new GsonBuilder().setPrettyPrinting();
		MultiProtocolSocketAddress.registerToGsonBuilder(gb);
		KLALBConfigItem.registerToGsonBuilder(gb);
		Gson gson=gb.create();
		KLALBConfig kc=gson.fromJson(new FileReader(new File("klalb-config.json")),KLALBConfig.class);
		System.out.println(kc);
		String s=gson.toJson(kc);
		System.out.println(s);
		
	}

	
}
