package com.ag.secp.platform.spring;

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

/**
 * Created by shaoqiang on 16/7/13.
 */
public class SpringApplicationContext implements ApplicationContextAware {

    private static ApplicationContext appContext;

    // Private constructor prevents instantiation from other classes
    private SpringApplicationContext() {}


    public void setApplicationContext(ApplicationContext applicationContext)
            throws BeansException {
        appContext = applicationContext;

    }

    public static Object getBean(String beanName) {
        return appContext.getBean(beanName);
    }

    public static boolean isContainsMain(String beanName){
        return appContext.containsBeanDefinition(beanName);
    }

}