package com.tofly.base.config;

import org.springframework.context.ApplicationContext;

/**
 * ApplicationContext 持有者
 */
public enum ApplicationContextHolder {

    INSTANCE;

    private ApplicationContext applicationContext;

    /**
     * 赋值
     * @param applicationContext
     */
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    /**
     * 获取bean
     * @param cls
     * @return
     */
    public Object getBean(Class<?> cls) {
        return this.applicationContext.getBean(cls);
    }
}
