package com.usoft.credit.config;

import com.usoft.credit.util.ContextUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 注册Spring上下文对象
 * @author liuam
 * @since 2018/6/25 0025 下午 15:09
 */
@Component
public class ApplicationContextRegister implements ApplicationContextAware {

    private static Logger logger = Logger.getLogger(ApplicationContextRegister.class);

    /**
     * 将上下文对象保存到ContextUtils中
     * @param applicationContext
     * @throws BeansException
     */
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        ContextUtils.setApplicationContext(applicationContext);
        logger.debug("ApplicationContext registed");
    }
}
