package com.kmall.api.service.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author huangyaqin
 * @since 1.0
 * 2018-10-24
 */
@Component
public class CommonPropertiesBuilder {
    private static final Logger logger = LoggerFactory.getLogger(CommonPropertiesBuilder.class);

    @Autowired
    @Qualifier("commonProperties")
    private CommonProperties commonProperties;

    private static CommonProperties commonProp;

    /**
     * Bean 向静态变量赋值
     */
    @PostConstruct
    private void init(){
        logger.info("CommonProperties初始化开始......");
        commonProp = commonProperties;
    }

    public static CommonProperties instance(){
        logger.info("CommonProperties实例返回");
        return commonProp;
    }

}
