Java Code Examples for org.springframework.beans.factory.parsing.ComponentDefinition#getBeanDefinitions()

The following examples show how to use org.springframework.beans.factory.parsing.ComponentDefinition#getBeanDefinitions() . 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: EventPublicationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void beanEventReceived() throws Exception {
	ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
	assertTrue(componentDefinition1 instanceof BeanComponentDefinition);
	assertEquals(1, componentDefinition1.getBeanDefinitions().length);
	BeanDefinition beanDefinition1 = componentDefinition1.getBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Rob Harrop"),
			beanDefinition1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
	assertEquals(1, componentDefinition1.getBeanReferences().length);
	assertEquals("testBean2", componentDefinition1.getBeanReferences()[0].getBeanName());
	assertEquals(1, componentDefinition1.getInnerBeanDefinitions().length);
	BeanDefinition innerBd1 = componentDefinition1.getInnerBeanDefinitions()[0];
	assertEquals(new TypedStringValue("ACME"),
			innerBd1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
	assertTrue(componentDefinition1.getSource() instanceof Element);

	ComponentDefinition componentDefinition2 = this.eventListener.getComponentDefinition("testBean2");
	assertTrue(componentDefinition2 instanceof BeanComponentDefinition);
	assertEquals(1, componentDefinition1.getBeanDefinitions().length);
	BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Juergen Hoeller"),
			beanDefinition2.getPropertyValues().getPropertyValue("name").getValue());
	assertEquals(0, componentDefinition2.getBeanReferences().length);
	assertEquals(1, componentDefinition2.getInnerBeanDefinitions().length);
	BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Eva Schallmeiner"),
			innerBd2.getPropertyValues().getPropertyValue("name").getValue());
	assertTrue(componentDefinition2.getSource() instanceof Element);
}
 
Example 2
Source File: UtilNamespaceHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testEvents() {
	ComponentDefinition propertiesComponent = this.listener.getComponentDefinition("myProperties");
	assertNotNull("Event for 'myProperties' not sent", propertiesComponent);
	AbstractBeanDefinition propertiesBean = (AbstractBeanDefinition) propertiesComponent.getBeanDefinitions()[0];
	assertEquals("Incorrect BeanDefinition", PropertiesFactoryBean.class, propertiesBean.getBeanClass());

	ComponentDefinition constantComponent = this.listener.getComponentDefinition("min");
	assertNotNull("Event for 'min' not sent", propertiesComponent);
	AbstractBeanDefinition constantBean = (AbstractBeanDefinition) constantComponent.getBeanDefinitions()[0];
	assertEquals("Incorrect BeanDefinition", FieldRetrievingFactoryBean.class, constantBean.getBeanClass());
}
 
Example 3
Source File: EventPublicationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void beanEventReceived() throws Exception {
	ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
	assertTrue(componentDefinition1 instanceof BeanComponentDefinition);
	assertEquals(1, componentDefinition1.getBeanDefinitions().length);
	BeanDefinition beanDefinition1 = componentDefinition1.getBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Rob Harrop"),
			beanDefinition1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
	assertEquals(1, componentDefinition1.getBeanReferences().length);
	assertEquals("testBean2", componentDefinition1.getBeanReferences()[0].getBeanName());
	assertEquals(1, componentDefinition1.getInnerBeanDefinitions().length);
	BeanDefinition innerBd1 = componentDefinition1.getInnerBeanDefinitions()[0];
	assertEquals(new TypedStringValue("ACME"),
			innerBd1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
	assertTrue(componentDefinition1.getSource() instanceof Element);

	ComponentDefinition componentDefinition2 = this.eventListener.getComponentDefinition("testBean2");
	assertTrue(componentDefinition2 instanceof BeanComponentDefinition);
	assertEquals(1, componentDefinition1.getBeanDefinitions().length);
	BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Juergen Hoeller"),
			beanDefinition2.getPropertyValues().getPropertyValue("name").getValue());
	assertEquals(0, componentDefinition2.getBeanReferences().length);
	assertEquals(1, componentDefinition2.getInnerBeanDefinitions().length);
	BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Eva Schallmeiner"),
			innerBd2.getPropertyValues().getPropertyValue("name").getValue());
	assertTrue(componentDefinition2.getSource() instanceof Element);
}
 
Example 4
Source File: UtilNamespaceHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testEvents() {
	ComponentDefinition propertiesComponent = this.listener.getComponentDefinition("myProperties");
	assertNotNull("Event for 'myProperties' not sent", propertiesComponent);
	AbstractBeanDefinition propertiesBean = (AbstractBeanDefinition) propertiesComponent.getBeanDefinitions()[0];
	assertEquals("Incorrect BeanDefinition", PropertiesFactoryBean.class, propertiesBean.getBeanClass());

	ComponentDefinition constantComponent = this.listener.getComponentDefinition("min");
	assertNotNull("Event for 'min' not sent", propertiesComponent);
	AbstractBeanDefinition constantBean = (AbstractBeanDefinition) constantComponent.getBeanDefinitions()[0];
	assertEquals("Incorrect BeanDefinition", FieldRetrievingFactoryBean.class, constantBean.getBeanClass());
}
 
Example 5
Source File: ContextDependencyLister.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void componentRegistered(
      ComponentDefinition paramComponentDefinition) {
   String name = paramComponentDefinition.getName();
   
   for(BeanDefinition bd : paramComponentDefinition.getBeanDefinitions()) {
      processBeanDefinition(name, bd);
   }
}
 
Example 6
Source File: EventPublicationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void beanEventReceived() throws Exception {
	ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
	assertTrue(componentDefinition1 instanceof BeanComponentDefinition);
	assertEquals(1, componentDefinition1.getBeanDefinitions().length);
	BeanDefinition beanDefinition1 = componentDefinition1.getBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Rob Harrop"),
			beanDefinition1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
	assertEquals(1, componentDefinition1.getBeanReferences().length);
	assertEquals("testBean2", componentDefinition1.getBeanReferences()[0].getBeanName());
	assertEquals(1, componentDefinition1.getInnerBeanDefinitions().length);
	BeanDefinition innerBd1 = componentDefinition1.getInnerBeanDefinitions()[0];
	assertEquals(new TypedStringValue("ACME"),
			innerBd1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
	assertTrue(componentDefinition1.getSource() instanceof Element);

	ComponentDefinition componentDefinition2 = this.eventListener.getComponentDefinition("testBean2");
	assertTrue(componentDefinition2 instanceof BeanComponentDefinition);
	assertEquals(1, componentDefinition1.getBeanDefinitions().length);
	BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Juergen Hoeller"),
			beanDefinition2.getPropertyValues().getPropertyValue("name").getValue());
	assertEquals(0, componentDefinition2.getBeanReferences().length);
	assertEquals(1, componentDefinition2.getInnerBeanDefinitions().length);
	BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0];
	assertEquals(new TypedStringValue("Eva Schallmeiner"),
			innerBd2.getPropertyValues().getPropertyValue("name").getValue());
	assertTrue(componentDefinition2.getSource() instanceof Element);
}
 
Example 7
Source File: UtilNamespaceHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testEvents() {
	ComponentDefinition propertiesComponent = this.listener.getComponentDefinition("myProperties");
	assertNotNull("Event for 'myProperties' not sent", propertiesComponent);
	AbstractBeanDefinition propertiesBean = (AbstractBeanDefinition) propertiesComponent.getBeanDefinitions()[0];
	assertEquals("Incorrect BeanDefinition", PropertiesFactoryBean.class, propertiesBean.getBeanClass());

	ComponentDefinition constantComponent = this.listener.getComponentDefinition("min");
	assertNotNull("Event for 'min' not sent", propertiesComponent);
	AbstractBeanDefinition constantBean = (AbstractBeanDefinition) constantComponent.getBeanDefinitions()[0];
	assertEquals("Incorrect BeanDefinition", FieldRetrievingFactoryBean.class, constantBean.getBeanClass());
}
 
Example 8
Source File: LoggingContextLoader.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void componentRegistered(ComponentDefinition componentDefinition) {
	log.info("Registered component [" + componentDefinition.getName() + "]");
	for (BeanDefinition bd : componentDefinition.getBeanDefinitions()) {
		String name = bd.getBeanClassName();
		if (bd instanceof BeanComponentDefinition) {
			name = ((BeanComponentDefinition) bd).getBeanName();
		}
		log.info("Registered bean definition: [" + name + "]" + " from " + bd.getResourceDescription());
	}
}
 
Example 9
Source File: LoggingApplicationContext.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void componentRegistered(ComponentDefinition componentDefinition) {
	log.info("Registered component [" + componentDefinition.getName() + "]");
	for (BeanDefinition bd : componentDefinition.getBeanDefinitions()) {
		String name = bd.getBeanClassName();
		if (bd instanceof BeanComponentDefinition) {
			name = ((BeanComponentDefinition) bd).getBeanName();
		}
		log.info("Registered bean definition: [" + name + "]" + " from " + bd.getResourceDescription());
	}
}
 
Example 10
Source File: JmsNamespaceHandlerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void validateComponentDefinition(ComponentDefinition compDef) {
	BeanDefinition[] beanDefs = compDef.getBeanDefinitions();
	for (BeanDefinition beanDef : beanDefs) {
		assertNotNull("BeanDefinition has no source attachment", beanDef.getSource());
	}
}
 
Example 11
Source File: JmsNamespaceHandlerTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void validateComponentDefinition(ComponentDefinition compDef) {
	BeanDefinition[] beanDefs = compDef.getBeanDefinitions();
	for (BeanDefinition beanDef : beanDefs) {
		assertNotNull("BeanDefinition has no source attachment", beanDef.getSource());
	}
}
 
Example 12
Source File: JmsNamespaceHandlerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private void validateComponentDefinition(ComponentDefinition compDef) {
	BeanDefinition[] beanDefs = compDef.getBeanDefinitions();
	for (BeanDefinition beanDef : beanDefs) {
		assertNotNull("BeanDefinition has no source attachment", beanDef.getSource());
	}
}