package com.eactive.eai.custom;

import org.springframework.beans.factory.InitializingBean;

import com.eactive.eai.common.util.Logger;
import com.eactive.eai.transformer.message.ISO8583MessageFactory;

/**
 * 이곳에서 Custermizing 대상 class 및 변수의 초기화 작업을 수행한다.
 */
public class CustomizingAppInitializer implements InitializingBean {
	static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);

	public static final String MESSAGE_TYPE_H2H = "H2H";
	public static final String LAYOUT_TYPE_H2H = "ISO8583H2H";
	public static final String ISO8583_H2H_CLASS_NAME = "com.eactive.eai.custom.transformer.message.ISO8583H2HMessage";
	
	public static final String MESSAGE_TYPE_SVL = "SVL";
	public static final String LAYOUT_TYPE_SVL = "ISO8583SVL";
	public static final String ISO8583_SVL_CLASS_NAME = "com.eactive.eai.custom.transformer.message.ISO8583SilverlakeMessage";

	@Override
	public void afterPropertiesSet() throws Exception {
		/*
		 * @formatter:off
		 * Custom ISO8583 메시지 추가시
		 * - ONLWeb: Custom Mesaage java 추가, 아래 맵에 추가
		 * - EMSWeb: Custom Mesaage java 추가, 아래 맵에 추가(로그조회시 parsing 위해)
		 * @formatter:on
		 */
		ISO8583MessageFactory.ISO8583_MESSAGE_TYPE_CLASS_MAP.put(MESSAGE_TYPE_H2H, ISO8583_H2H_CLASS_NAME);
		ISO8583MessageFactory.ISO8583_MESSAGE_TYPE_CLASS_MAP.put(MESSAGE_TYPE_SVL, ISO8583_SVL_CLASS_NAME);
		ISO8583MessageFactory.ISO8583_LAYOUT_TYPE_CLASS_MAP.put(LAYOUT_TYPE_H2H, ISO8583_H2H_CLASS_NAME);
		ISO8583MessageFactory.ISO8583_LAYOUT_TYPE_CLASS_MAP.put(LAYOUT_TYPE_SVL, ISO8583_SVL_CLASS_NAME);
		logger.info("ISO8583MessageFactory registered - {} = {}", MESSAGE_TYPE_H2H, ISO8583_H2H_CLASS_NAME);
		logger.info("ISO8583MessageFactory registered - {} = {}", MESSAGE_TYPE_SVL, ISO8583_SVL_CLASS_NAME);
		logger.info("ISO8583MessageFactory registered - {} = {}", LAYOUT_TYPE_H2H, ISO8583_H2H_CLASS_NAME);
		logger.info("ISO8583MessageFactory registered - {} = {}", LAYOUT_TYPE_SVL, ISO8583_SVL_CLASS_NAME);
	}
}
