Example usage for org.springframework.context.support StaticApplicationContext containsBean

List of usage examples for org.springframework.context.support StaticApplicationContext containsBean

Introduction

In this page you can find the example usage for org.springframework.context.support StaticApplicationContext containsBean.

Prototype

@Override
    public boolean containsBean(String name) 

Source Link

Usage

From source file:scriptella.driver.spring.EtlExecutorBean.java

/**
 * This method obtains a global ThreadLocal class independent of the classloader (JVM-scope singleton).
 * The easiest solution is to use System.getProperties().get/put, but this solution violate
 * Properties contract and have other drawbacks.
 * <p>Current solution relies on the idea behind
 * {@link org.springframework.beans.factory.access.SingletonBeanFactoryLocator}. See also bug #4648
 *
 * @return Global ThreadLocal (JVM-scope singleton).
 *//*from w  w  w  .  ja v  a 2  s .c  o  m*/
@SuppressWarnings("unchecked")
private static ThreadLocal<BeanFactory> getGlobalThreadLocal() {
    BeanFactoryLocator locator = SingletonBeanFactoryLocator.getInstance(BEAN_FACTORY_XML_PATH);
    BeanFactoryReference ref = locator.useBeanFactory(FACTORY_BEAN_NAME);
    StaticApplicationContext ctx = (StaticApplicationContext) ref.getFactory();
    if (!ctx.containsBean(THREAD_LOCAL_BEAN_NAME)) {
        ctx.registerSingleton(THREAD_LOCAL_BEAN_NAME, ThreadLocal.class);
    }
    return (ThreadLocal) ctx.getBean(THREAD_LOCAL_BEAN_NAME);
}