package com.eactive.eai.agent.restrict;

import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommandException;
import com.eactive.eai.common.restrict.RestrictInfoManager;
import com.eactive.eai.common.util.Logger;

/**
 * 거래통제 Reload 커맨트
 * 
 * @Author : S010795
 * @Date : 2019. 5. 15.
 * @Version :
 */
public class ReloadRestrictInfoCommand extends Command {
	private static final long serialVersionUID = 1L;

	public ReloadRestrictInfoCommand() {
		super("ReloadRestrictInfoCommand");
	}

	public Object execute() throws CommandException {
		Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
		if (logger.isWarn())
			logger.warn(this.name + " is executed");

		try {
			RestrictInfoManager manager = RestrictInfoManager.getInstance();
			manager.reload();
			if (logger.isWarn())
				logger.warn(this.name + "] all rule Reload.");
		} catch (Exception e) {
			String rspErrorCode = "RECEAIMCM002";
			String msg = makeException(rspErrorCode, e);
			if (logger.isError())
				logger.error(msg, e);
			throw new CommandException(msg);
		}
		return "success";

	}

//	   public static void main(String args[]) throws Exception {
//	   test();
//}

// private static void test() throws Exception {
//        Command command = new ReloadRestrictInfoCommand();
//        command.setArgs("ALL");
//        AgentUtil.broadcast(command);
//        
//    }
}
