package com.pack;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

import com.pack.service.CommandService;
import com.pack.service.PackUtilService;
import com.taurus.core.routes.Extension;
import com.taurus.core.routes.Routes;

public class MainServer extends Extension {
	
	public static Element packConfig;
	public static Element ossListConfig;
	public static String probjectName;
	public MainServer() {
		super();
		String path = System.getProperty("WORKDIR");
		File file = new File(path+"/config/pack-config.xml");
		if(file.exists()) {
			try {
				InputStream is = new FileInputStream(file);
				SAXBuilder builder = new SAXBuilder();
				Document document = builder.build(is);
				packConfig = document.getRootElement();
				ossListConfig = packConfig.getChild("oss-list");
				probjectName = packConfig.getChildTextTrim("project-name");
			}catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	}

	

	
	@Override
	public void configRoute(Routes me) {
		
		me.add("cmd", CommandService.class);
		me.add("pack", PackUtilService.class);
	}

	@Override
	public void onStart() {


	}

	@Override
	public void onStop() {
		// TODO Auto-generated method stub
		

	}

}
