package com.brilliance.isc.common.validator.es.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 获取SpringBean工具类
 * @author fukai
 */
@Component("es-SpringUtils")
public class EsSpringUtils implements ApplicationContextAware {

    private static ApplicationContext applicationContext;


    public static <T> T getBean(String name){
       return (T) applicationContext.getBean(name);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        EsSpringUtils.applicationContext = applicationContext;
    }
}
