package com.appleframework.boot.config;

import org.apache.log4j.Logger;

import com.appleframework.boot.core.Container;
import com.appleframework.boot.utils.SystemPropertiesUtils;
import com.appleframework.config.core.factory.ConfigurerFactory;

/**
 * SpringContainer. (SPI, Singleton, ThreadSafe)
 * 
 * @author Cruise.Xu
 */
public class ConfigContainer implements Container {
	
	private static Logger logger = Logger.getLogger(ConfigContainer.class);
	
	private static final String SYSTEM_PROPERTIES_FILE = "system.properties";

	private static long startTime = System.currentTimeMillis();
    
	private ConfigurerFactory factory;
	
	public void start() {
		if(null != factory) {
			factory.setLoadRemote(true);
			factory.init();
		}
	}

    public void stop() {
    }
    
    public void restart() {
    }
    
    public boolean isRunning() {
    	return true;
    }
    
	public ConfigContainer(String configContainer) {
		try {
			Class<?> clazz = Class.forName(configContainer);
			factory = (ConfigurerFactory) clazz.newInstance();
			factory.setSystemPropertyFile(SYSTEM_PROPERTIES_FILE);
		} catch (Exception e) {
			logger.error("The container instance is error : " + e.getMessage());
		}
	}

	@Override
	public String getName() {
    	return SystemPropertiesUtils.getApplicationName();
	}
    
	@Override
	public String getType() {
		return "ConfigContainer";
	}

	@Override
	public long getStartTime() {
		return startTime;
	}

	public void setFactory(ConfigurerFactory factory) {
		this.factory = factory;
	}

}
@@ -543,16 +543,79 @@
 rties%22;%0D
+%0A%09%0D%0A%09private static String CONTAINER_NAME = %22ConfigContainer%22;%0D
 %0A%0D%0A%09priv
@@ -1371,50 +1371,22 @@
 urn 
-SystemPropertiesUtils.getApplicationName()
+CONTAINER_NAME
 ;%0D%0A%09

升级log4j版本