/**
 * 版权所有 2003~2018多元世纪
 */
package com.muchinfo.mtp3century.utils;

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

@Component
public final class SpringBeanUtils implements ApplicationContextAware {
    private static ApplicationContext AC;

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

    public static <T> T getBean(Class<T> clazz) {
        return AC.getBean(clazz);
    }

    public static <T> T getBean(String beanName, Class<T> clazz) {
        return AC.getBean(beanName, clazz);
    }
}
