Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.ConfigurationClassPostProcessor$EnhancedConfigurationBeanPostProcessor


  protected DefaultListableBeanFactory getBeanFactory() {

    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.registerBeanDefinition("testConfig", new RootBeanDefinition(TestConfig.class));

    ConfigurationClassPostProcessor processor = new ConfigurationClassPostProcessor();
    processor.postProcessBeanDefinitionRegistry(beanFactory);

    return beanFactory;
  }
View Full Code Here


    if (customScope != null) {
      beanFactory.registerScope(SCOPE, customScope);
    }
    beanFactory.registerBeanDefinition("config", new RootBeanDefinition(configClass));
    GenericApplicationContext ctx = new GenericApplicationContext(beanFactory);
    ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor());
    ctx.refresh();
    return ctx;
  }
View Full Code Here

  }

  private AbstractBeanDefinition beanDef(Class<?> configClass) {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("config", new RootBeanDefinition(configClass));
    ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
    pp.postProcessBeanFactory(factory);
    return (AbstractBeanDefinition) factory.getBeanDefinition("foo");
  }
View Full Code Here

  private void assertAdviceWasApplied(Class<?> configClass) {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
        new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class));
    GenericApplicationContext ctx = new GenericApplicationContext(factory);
    ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor());
    ctx.registerBeanDefinition("config", new RootBeanDefinition(configClass));
    ctx.refresh();

    TestBean testBean = ctx.getBean("testBean", TestBean.class);
    assertThat(testBean.getName(), equalTo("name"));
View Full Code Here

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    for (Class<?> configClass : configClasses) {
      String configBeanName = configClass.getName();
      factory.registerBeanDefinition(configBeanName, new RootBeanDefinition(configClass));
    }
    ConfigurationClassPostProcessor ccpp = new ConfigurationClassPostProcessor();
    ccpp.postProcessBeanDefinitionRegistry(factory);
    ccpp.postProcessBeanFactory(factory);
    RequiredAnnotationBeanPostProcessor rapp = new RequiredAnnotationBeanPostProcessor();
    rapp.setBeanFactory(factory);
    factory.addBeanPostProcessor(rapp);
    factory.freezeConfiguration();
    return factory;
View Full Code Here

  private DefaultListableBeanFactory processConfigurationClasses(Class<?>... classes) {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    for (Class<?> clazz : classes) {
      beanFactory.registerBeanDefinition(clazz.getSimpleName(), new RootBeanDefinition(clazz));
    }
    ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
    pp.postProcessBeanFactory(beanFactory);
    return beanFactory;
  }
View Full Code Here

  public void testProcessImportsWithAsm() {
    int configClasses = 2;
    int beansInClasses = 2;
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigurationWithImportAnnotation.class.getName()));
    ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
    pp.postProcessBeanFactory(beanFactory);
    assertThat(beanFactory.getBeanDefinitionCount(), equalTo(configClasses + beansInClasses));
  }
View Full Code Here

  @Test
  public void testImportAnnotationWithMultipleArgumentsResultingInOverriddenBeanDefinition() {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.registerBeanDefinition("config", new RootBeanDefinition(
        WithMultipleArgumentsThatWillCauseDuplication.class));
    ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
    pp.postProcessBeanFactory(beanFactory);
    assertThat(beanFactory.getBeanDefinitionCount(), equalTo(4));
    assertThat(beanFactory.getBean("foo", ITestBean.class).getName(), equalTo("foo2"));
  }
View Full Code Here

      return;
    }
   
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

    ConfigurationClassPostProcessor processor = new ConfigurationClassPostProcessor();
    DelegatingSourceExtractor sourceExtractor = new DelegatingSourceExtractor(project.getProject());

    processor.setEnvironment(new ToolingAwareEnvironment());
    processor.setSourceExtractor(sourceExtractor);
    processor.setMetadataReaderFactory(new CachingJdtMetadataReaderFactory(project, classLoader));
    processor.setProblemReporter(new JdtAnnotationMetadataProblemReporter(postProcessingContext));
    processor.setResourceLoader(new DefaultResourceLoader(classLoader));

    ReaderEventListenerForwardingBeanDefinitionRegistry registry = new ReaderEventListenerForwardingBeanDefinitionRegistry(
        postProcessingContext.getBeanDefinitionRegistry(), postProcessingContext
            .getBeansConfigRegistrySupport(), sourceExtractor);
    registry.setBeanClassLoader(classLoader);
   
    processor.processConfigBeanDefinitions(registry);
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.annotation.ConfigurationClassPostProcessor$EnhancedConfigurationBeanPostProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.