Spring Framework AbstractBeanFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AbstractBeanFactory class.

This code example shows how to use the following methods:getBean, getBean, getType
 
	private static final Resource CONTEXT = qualifiedResource(PropertyPathFactoryBeanTests.class, "context.xml");
 
	@Test
	public void testPropertyPathFactoryBeanWithSingletonResult() { 
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
		assertEquals(new Integer(12), xbf.getBean("propertyPath1"));
		assertEquals(new Integer(11), xbf.getBean("propertyPath2"));
		assertEquals(new Integer(10), xbf.getBean("tb.age"));
		assertEquals(ITestBean.class, xbf.getType("otb.spouse"));
		Object result1 = xbf.getBean("otb.spouse");
		Object result2 = xbf.getBean("otb.spouse");
		assertTrue(result1 instanceof TestBean);
		assertTrue(result1 == result2);
		assertEquals(99, ((TestBean) result1).getAge());
	} 
 
	@Test
	public void testPropertyPathFactoryBeanWithPrototypeResult() { 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getRegisteredScope, getRegisteredScopeNames, registerScope
 
	private DefaultListableBeanFactory beanFactory;
 
	@Before 
	public void setUp() { 
		beanFactory = new DefaultListableBeanFactory();
		Scope scope = new NoOpScope() {
			private int index;
			private List<TestBean> objects = new LinkedList<TestBean>(); {
				objects.add(new TestBean());
				objects.add(new TestBean());
			} 
			@Override 
			public Object get(String name, ObjectFactory<?> objectFactory) {
				if (index >= objects.size()) {
					index = 0;
				} 
				return objects.get(index++);
			} 
		}; 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
	private static final ClassPathResource TESTBEAN_CONTEXT = new ClassPathResource(CLASSNAME + "-testbean.xml", CLASS);
 
	/* SPR-2108 */ 
	@Test
	public void testProxyAssignable() throws Exception {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
		Object baseMap = bf.getBean("singletonMap");
		assertTrue(baseMap instanceof Map);
	} 
 
	@Test
	public void testSimpleProxy() throws Exception {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
		Object simpleMap = bf.getBean("simpleMap");
		assertTrue(simpleMap instanceof Map);
		assertTrue(simpleMap instanceof HashMap);
	} 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBeanNamesForType, getBean
		if (beanFactory == null)
		{ 
			initSpring(); 
		} 
 
		String[] beanNamesForType = beanFactory.getBeanNamesForType(cl);
		if (beanNamesForType.length ==0) 
		{ 
			return null; 
		} 
		return beanFactory.getBean (beanNamesForType[0], cl);
	} 
	 
	public static Collection<AbstractStorageFacet> getStorageBeans()
	{ 
		if (beanFactory == null)
		{ 
			initSpring(); 
		} 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
 
    @Test
    public void testBeansAvailableInContext() { 
        assertNotNull(beanFactory);
        assertNotNull(disruptorCommandBus);
        Object repo1 = beanFactory.getBean("myAggregateRepository");
        Object repo2 = beanFactory.getBean("myOtherAggregateRepository");
        assertTrue(repo1 instanceof Repository);
        assertTrue(repo2 instanceof Repository);
        assertNotSame(repo1, repo2);
    } 
 
    @Test
    public void testBeanProperties() { 
        GenericBeanDefinition beanDefinition = (GenericBeanDefinition)
                beanFactory.getBeanDefinition("disruptorCommandBus");
        // no setter injection 
        assertEquals(0, beanDefinition.getPropertyValues().size());
        assertEquals(3, beanDefinition.getConstructorArgumentValues().getArgumentCount());
        assertEquals("stop", beanDefinition.getDestroyMethodName());
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:destroyBean, isPrototype
  public Object getInstance(String bean, Object context) {
    return context;
  } 
 
  public void releaseContext(String bean, Object context) {
    if (factory.isPrototype(bean)) {
      factory.destroyBean(bean, context);
    } 
  } 
 
  public void close() { 
    factory.destroySingletons();
  } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
                "oracle.jms.AQjmsConnectionFactory", 
                bean.getClass().getName());
    } 
 
    public void testAqConnectionFactoryDefinitionWithQueueType() throws Exception {
        Object bean = this.beanFactory.getBean("aqQueueConnectionFactory");
        assertEquals("not the correct class",
                "oracle.jms.AQjmsQueueConnectionFactory", 
                bean.getClass().getName());
    } 
 
    public void testAqConnectionFactoryDefinitionWithTopicType() throws Exception {
        Object bean = this.beanFactory.getBean("aqTopicConnectionFactory");
        assertEquals("not the correct class",
                "oracle.jms.AQjmsTopicConnectionFactory", 
                bean.getClass().getName());
    } 
} 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
	} 
 
	@Override 
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if (!this.capturedAutoChannelCandidates && this.beanFactory != null) {
			Object autoCreateChannelCandidates = beanFactory.getBean("$autoCreateChannelCandidates");
			if (autoCreateChannelCandidates != null){
					@SuppressWarnings("unchecked") 
					Collection<String> autoCreateChannelCandidatesNames =
									(Collection<String>) new DirectFieldAccessor(autoCreateChannelCandidates).getPropertyValue("channelNames");
					this.siBeanNames.addAll(autoCreateChannelCandidatesNames);
			} 
			this.capturedAutoChannelCandidates = true;
		} 
		if (bean instanceof MBeanExporter && !(bean instanceof IntegrationMBeanExporter)) {
			MBeanExporter mbeanExporter = (MBeanExporter) bean;
			DirectFieldAccessor mbeDfa = new DirectFieldAccessor(mbeanExporter);
			@SuppressWarnings("unchecked") 
			Set<String> excludedNames = (Set<String>) mbeDfa.getPropertyValue(EXCLUDED_BEANS_PROPERTY_NAME);
			if (excludedNames != null) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:containsBean
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if (bean instanceof Job) {
			Job job = (Job) bean;
			try { 
				String groupName = this.groupName;
				if (beanFactory != null && beanFactory.containsBean(beanName)) {
					groupName = getGroupName(beanFactory.getBeanDefinition(beanName), job);
				} 
				job = groupName==null ? job : new GroupAwareJob(groupName, job);
				ReferenceJobFactory jobFactory = new ReferenceJobFactory(job);
				String name = jobFactory.getJobName();
				logger.debug("Registering job: " + name);
				jobRegistry.register(jobFactory);
				jobNames.add(name);
			} 
			catch (DuplicateJobException e) {
				throw new FatalBeanException("Cannot register job configuration", e);
			} 
			return job;
		} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isBeanNameInUse
		return this.beanFactory.getBeanDefinition(beanName);
	} 
 
	@Override 
	public boolean isBeanNameInUse(String beanName) {
		return this.beanFactory.isBeanNameInUse(beanName);
	} 
 
	@Override 
	public void registerAlias(String beanName, String alias) {
		this.beanFactory.registerAlias(beanName, alias);
	} 
 
	@Override 
	public void removeAlias(String alias) {
		this.beanFactory.removeAlias(alias);
	} 
 
	@Override 
	public boolean isAlias(String beanName) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java