Java Code Examples for org.springframework.beans.factory.parsing.CompositeComponentDefinition#getNestedComponents()
The following examples show how to use
org.springframework.beans.factory.parsing.CompositeComponentDefinition#getNestedComponents() .
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: AopNamespaceHandlerEventTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPointcutEvents() { this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 1, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); PointcutComponentDefinition pcd = null; for (ComponentDefinition componentDefinition : nestedComponentDefs) { if (componentDefinition instanceof PointcutComponentDefinition) { pcd = (PointcutComponentDefinition) componentDefinition; break; } } assertNotNull("PointcutComponentDefinition not found", pcd); assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); }
Example 2
Source File: AopNamespaceHandlerEventTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testPointcutEvents() { this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 1, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); PointcutComponentDefinition pcd = null; for (ComponentDefinition componentDefinition : nestedComponentDefs) { if (componentDefinition instanceof PointcutComponentDefinition) { pcd = (PointcutComponentDefinition) componentDefinition; break; } } assertNotNull("PointcutComponentDefinition not found", pcd); assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); }
Example 3
Source File: AopNamespaceHandlerEventTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testPointcutEvents() throws Exception { this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 1, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); PointcutComponentDefinition pcd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof PointcutComponentDefinition) { pcd = (PointcutComponentDefinition) componentDefinition; break; } } assertNotNull("PointcutComponentDefinition not found", pcd); assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); }
Example 4
Source File: AopNamespaceHandlerEventTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAdvisorEventsWithPointcutRef() { this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 3, nestedComponentDefs.length); AdvisorComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AdvisorComponentDefinition) { acd = (AdvisorComponentDefinition) componentDefinition; break; } } assertNotNull("AdvisorComponentDefinition not found", acd); assertEquals(1, acd.getBeanDefinitions().length); assertEquals(2, acd.getBeanReferences().length); assertTrue("No advice bean found", componentDefinitions[1] instanceof BeanComponentDefinition); BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1]; assertEquals("countingAdvice", adviceDef.getBeanName()); }
Example 5
Source File: AopNamespaceHandlerEventTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAdvisorEventsWithDirectPointcut() { this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); AdvisorComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AdvisorComponentDefinition) { acd = (AdvisorComponentDefinition) componentDefinition; break; } } assertNotNull("AdvisorComponentDefinition not found", acd); assertEquals(2, acd.getBeanDefinitions().length); assertEquals(1, acd.getBeanReferences().length); assertTrue("No advice bean found", componentDefinitions[1] instanceof BeanComponentDefinition); BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1]; assertEquals("countingAdvice", adviceDef.getBeanName()); }
Example 6
Source File: AopNamespaceHandlerEventTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAdvisorEventsWithPointcutRef() { this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 3, nestedComponentDefs.length); AdvisorComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AdvisorComponentDefinition) { acd = (AdvisorComponentDefinition) componentDefinition; break; } } assertNotNull("AdvisorComponentDefinition not found", acd); assertEquals(1, acd.getBeanDefinitions().length); assertEquals(2, acd.getBeanReferences().length); assertTrue("No advice bean found", componentDefinitions[1] instanceof BeanComponentDefinition); BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1]; assertEquals("countingAdvice", adviceDef.getBeanName()); }
Example 7
Source File: AopNamespaceHandlerEventTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAdvisorEventsWithDirectPointcut() { this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); AdvisorComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AdvisorComponentDefinition) { acd = (AdvisorComponentDefinition) componentDefinition; break; } } assertNotNull("AdvisorComponentDefinition not found", acd); assertEquals(2, acd.getBeanDefinitions().length); assertEquals(1, acd.getBeanReferences().length); assertTrue("No advice bean found", componentDefinitions[1] instanceof BeanComponentDefinition); BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1]; assertEquals("countingAdvice", adviceDef.getBeanName()); }
Example 8
Source File: AopNamespaceHandlerEventTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAdvisorEventsWithPointcutRef() throws Exception { this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 3, nestedComponentDefs.length); AdvisorComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AdvisorComponentDefinition) { acd = (AdvisorComponentDefinition) componentDefinition; break; } } assertNotNull("AdvisorComponentDefinition not found", acd); assertEquals(1, acd.getBeanDefinitions().length); assertEquals(2, acd.getBeanReferences().length); assertTrue("No advice bean found", componentDefinitions[1] instanceof BeanComponentDefinition); BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1]; assertEquals("countingAdvice", adviceDef.getBeanName()); }
Example 9
Source File: AopNamespaceHandlerEventTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAdvisorEventsWithDirectPointcut() throws Exception { this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); AdvisorComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AdvisorComponentDefinition) { acd = (AdvisorComponentDefinition) componentDefinition; break; } } assertNotNull("AdvisorComponentDefinition not found", acd); assertEquals(2, acd.getBeanDefinitions().length); assertEquals(1, acd.getBeanReferences().length); assertTrue("No advice bean found", componentDefinitions[1] instanceof BeanComponentDefinition); BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1]; assertEquals("countingAdvice", adviceDef.getBeanName()); }
Example 10
Source File: AopNamespaceHandlerEventTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testAspectEvent() { this.reader.loadBeanDefinitions(CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 5, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); AspectComponentDefinition acd = null; for (ComponentDefinition componentDefinition : nestedComponentDefs) { if (componentDefinition instanceof AspectComponentDefinition) { acd = (AspectComponentDefinition) componentDefinition; break; } } assertNotNull("AspectComponentDefinition not found", acd); BeanDefinition[] beanDefinitions = acd.getBeanDefinitions(); assertEquals(5, beanDefinitions.length); BeanReference[] beanReferences = acd.getBeanReferences(); assertEquals(6, beanReferences.length); Set<String> expectedReferences = new HashSet<>(); expectedReferences.add("pc"); expectedReferences.add("countingAdvice"); for (BeanReference beanReference : beanReferences) { expectedReferences.remove(beanReference.getBeanName()); } assertEquals("Incorrect references found", 0, expectedReferences.size()); for (int i = 1; i < componentDefinitions.length; i++) { assertTrue(componentDefinitions[i] instanceof BeanComponentDefinition); } ComponentDefinition[] nestedComponentDefs2 = acd.getNestedComponents(); assertEquals("Inner PointcutComponentDefinition not found", 1, nestedComponentDefs2.length); assertTrue(nestedComponentDefs2[0] instanceof PointcutComponentDefinition); PointcutComponentDefinition pcd = (PointcutComponentDefinition) nestedComponentDefs2[0]; assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); }
Example 11
Source File: AopNamespaceHandlerEventTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void testAspectEvent() { this.reader.loadBeanDefinitions(CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 5, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); AspectComponentDefinition acd = null; for (ComponentDefinition componentDefinition : nestedComponentDefs) { if (componentDefinition instanceof AspectComponentDefinition) { acd = (AspectComponentDefinition) componentDefinition; break; } } assertNotNull("AspectComponentDefinition not found", acd); BeanDefinition[] beanDefinitions = acd.getBeanDefinitions(); assertEquals(5, beanDefinitions.length); BeanReference[] beanReferences = acd.getBeanReferences(); assertEquals(6, beanReferences.length); Set<String> expectedReferences = new HashSet<>(); expectedReferences.add("pc"); expectedReferences.add("countingAdvice"); for (BeanReference beanReference : beanReferences) { expectedReferences.remove(beanReference.getBeanName()); } assertEquals("Incorrect references found", 0, expectedReferences.size()); for (int i = 1; i < componentDefinitions.length; i++) { assertTrue(componentDefinitions[i] instanceof BeanComponentDefinition); } ComponentDefinition[] nestedComponentDefs2 = acd.getNestedComponents(); assertEquals("Inner PointcutComponentDefinition not found", 1, nestedComponentDefs2.length); assertTrue(nestedComponentDefs2[0] instanceof PointcutComponentDefinition); PointcutComponentDefinition pcd = (PointcutComponentDefinition) nestedComponentDefs2[0]; assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); }
Example 12
Source File: AopNamespaceHandlerEventTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void testAspectEvent() throws Exception { this.reader.loadBeanDefinitions(CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 5, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0]; assertEquals("aop:config", compositeDef.getName()); ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents(); assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length); AspectComponentDefinition acd = null; for (int i = 0; i < nestedComponentDefs.length; i++) { ComponentDefinition componentDefinition = nestedComponentDefs[i]; if (componentDefinition instanceof AspectComponentDefinition) { acd = (AspectComponentDefinition) componentDefinition; break; } } assertNotNull("AspectComponentDefinition not found", acd); BeanDefinition[] beanDefinitions = acd.getBeanDefinitions(); assertEquals(5, beanDefinitions.length); BeanReference[] beanReferences = acd.getBeanReferences(); assertEquals(6, beanReferences.length); Set<String> expectedReferences = new HashSet<String>(); expectedReferences.add("pc"); expectedReferences.add("countingAdvice"); for (int i = 0; i < beanReferences.length; i++) { BeanReference beanReference = beanReferences[i]; expectedReferences.remove(beanReference.getBeanName()); } assertEquals("Incorrect references found", 0, expectedReferences.size()); for (int i = 1; i < componentDefinitions.length; i++) { assertTrue(componentDefinitions[i] instanceof BeanComponentDefinition); } ComponentDefinition[] nestedComponentDefs2 = acd.getNestedComponents(); assertEquals("Inner PointcutComponentDefinition not found", 1, nestedComponentDefs2.length); assertTrue(nestedComponentDefs2[0] instanceof PointcutComponentDefinition); PointcutComponentDefinition pcd = (PointcutComponentDefinition) nestedComponentDefs2[0]; assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); }