use of org.springframework.beans.factory.support.DefaultListableBeanFactory in project zeppelin by apache.
the class LensBootstrap method getLensJLineShellComponent.
public LensJLineShellComponent getLensJLineShellComponent() {
GenericApplicationContext ctx = (GenericApplicationContext) getApplicationContext();
RootBeanDefinition rbd = new RootBeanDefinition();
rbd.setBeanClass(LensJLineShellComponent.class);
DefaultListableBeanFactory bf = (DefaultListableBeanFactory) ctx.getBeanFactory();
bf.registerBeanDefinition(LensJLineShellComponent.class.getSimpleName(), rbd);
return ctx.getBean(LensJLineShellComponent.class);
}
use of org.springframework.beans.factory.support.DefaultListableBeanFactory in project spring-framework by spring-projects.
the class AbstractBeanFactoryBasedTargetSourceCreator method getInternalBeanFactoryForBean.
/**
* Return the internal BeanFactory to be used for the specified bean.
* @param beanName the name of the target bean
* @return the internal BeanFactory to be used
*/
protected DefaultListableBeanFactory getInternalBeanFactoryForBean(String beanName) {
synchronized (this.internalBeanFactories) {
DefaultListableBeanFactory internalBeanFactory = this.internalBeanFactories.get(beanName);
if (internalBeanFactory == null) {
internalBeanFactory = buildInternalBeanFactory(this.beanFactory);
this.internalBeanFactories.put(beanName, internalBeanFactory);
}
return internalBeanFactory;
}
}
use of org.springframework.beans.factory.support.DefaultListableBeanFactory in project spring-framework by spring-projects.
the class TopLevelAopTagTests method testParse.
@Test
public void testParse() throws Exception {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(CONTEXT);
assertTrue(beanFactory.containsBeanDefinition("testPointcut"));
}
use of org.springframework.beans.factory.support.DefaultListableBeanFactory in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method testAutowireBeanByNameWithNoDependencyCheck.
@Test
public void testAutowireBeanByNameWithNoDependencyCheck() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
lbf.registerBeanDefinition("spous", bd);
DependenciesBean bean = (DependenciesBean) lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
assertNull(bean.getSpouse());
}
use of org.springframework.beans.factory.support.DefaultListableBeanFactory in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method testPrototypeFactoryBeanIgnoredByNonEagerTypeMatching.
@Test
public void testPrototypeFactoryBeanIgnoredByNonEagerTypeMatching() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
Properties p = new Properties();
p.setProperty("x1.(class)", DummyFactory.class.getName());
// Reset static state
DummyFactory.reset();
p.setProperty("x1.(singleton)", "false");
p.setProperty("x1.singleton", "false");
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
assertTrue("prototype not instantiated", !DummyFactory.wasPrototypeCreated());
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertEquals(0, beanNames.length);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertEquals(0, beanNames.length);
assertFalse(lbf.containsSingleton("x1"));
assertTrue(lbf.containsBean("x1"));
assertTrue(lbf.containsBean("&x1"));
assertFalse(lbf.isSingleton("x1"));
assertFalse(lbf.isSingleton("&x1"));
assertTrue(lbf.isPrototype("x1"));
assertTrue(lbf.isPrototype("&x1"));
assertTrue(lbf.isTypeMatch("x1", TestBean.class));
assertFalse(lbf.isTypeMatch("&x1", TestBean.class));
assertTrue(lbf.isTypeMatch("&x1", DummyFactory.class));
assertTrue(lbf.isTypeMatch("&x1", ResolvableType.forClass(DummyFactory.class)));
assertTrue(lbf.isTypeMatch("&x1", ResolvableType.forClassWithGenerics(FactoryBean.class, Object.class)));
assertFalse(lbf.isTypeMatch("&x1", ResolvableType.forClassWithGenerics(FactoryBean.class, String.class)));
assertEquals(TestBean.class, lbf.getType("x1"));
assertEquals(DummyFactory.class, lbf.getType("&x1"));
assertTrue("prototype not instantiated", !DummyFactory.wasPrototypeCreated());
}
Aggregations