Java Code Examples for org.springframework.beans.factory.access.BeanFactoryReference#getFactory()
The following examples show how to use
org.springframework.beans.factory.access.BeanFactoryReference#getFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextSingletonBeanFactoryLocatorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override @Test public void testBasicFunctionality() { ContextSingletonBeanFactoryLocator facLoc = new ContextSingletonBeanFactoryLocator( "classpath*:" + ClassUtils.addResourcePathToPackagePath(CLASS, CONTEXT)); basicFunctionalityTest(facLoc); BeanFactoryReference bfr = facLoc.useBeanFactory("a.qualified.name.of.some.sort"); BeanFactory fac = bfr.getFactory(); assertTrue(fac instanceof ApplicationContext); assertEquals("a.qualified.name.of.some.sort", ((ApplicationContext) fac).getId()); assertTrue(((ApplicationContext) fac).getDisplayName().contains("a.qualified.name.of.some.sort")); BeanFactoryReference bfr2 = facLoc.useBeanFactory("another.qualified.name"); BeanFactory fac2 = bfr2.getFactory(); assertEquals("another.qualified.name", ((ApplicationContext) fac2).getId()); assertTrue(((ApplicationContext) fac2).getDisplayName().contains("another.qualified.name")); assertTrue(fac2 instanceof ApplicationContext); }
Example 2
Source File: ComponentLoaderImpl.java From zstack with Apache License 2.0 | 5 votes |
public ComponentLoaderImpl () { checkInit(); BeanFactoryLocator factoryLocator = ContextSingletonBeanFactoryLocator .getInstance(String.format("classpath:%s", CoreGlobalProperty.BEAN_REF_CONTEXT_CONF)); BeanFactoryReference ref = factoryLocator.useBeanFactory("parentContext"); ioc = ref.getFactory(); }
Example 3
Source File: EtlExecutorBean.java From scriptella-etl with Apache License 2.0 | 5 votes |
/** * 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). */ @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); }