Example usage for org.springframework.context.annotation AnnotationConfigUtils registerAnnotationConfigProcessors

List of usage examples for org.springframework.context.annotation AnnotationConfigUtils registerAnnotationConfigProcessors

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigUtils registerAnnotationConfigProcessors.

Prototype

public static void registerAnnotationConfigProcessors(BeanDefinitionRegistry registry) 

Source Link

Document

Register all relevant annotation post processors in the given registry.

Usage

From source file:com.enonic.cms.server.service.portal.mvc.controller.XmlWebApplicationContextLoader.java

public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {
    if (logger.isDebugEnabled()) {
        logger.debug("Loading ApplicationContext for locations ["
                + StringUtils.arrayToCommaDelimitedString(locations) + "].");
    }//from w w w  . j av  a 2 s . c  om
    GenericApplicationContext context = new GenericWebApplicationContext();
    prepareContext(context);
    customizeBeanFactory(context.getDefaultListableBeanFactory());
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    customizeContext(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:org.joinfaces.annotations.JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java

@Test
public void testViewScopedClass() {
    GenericApplicationContext acx = new GenericApplicationContext();
    AnnotationConfigUtils.registerAnnotationConfigProcessors(acx);

    acx.registerBeanDefinition("viewScopedClass",
            new AnnotatedGenericBeanDefinition(new StandardAnnotationMetadata(ViewScopedClass.class)));
    acx.registerBeanDefinition("scopedBeansConfiguration",
            new RootBeanDefinition(ScopedBeansConfiguration.class));
    acx.addBeanFactoryPostProcessor(new JsfCdiToSpringBeanFactoryPostProcessor());
    acx.refresh();// www  .  j a va 2 s .com

    assertThat(acx.getBeanDefinition("viewScopedClass").getScope()).isEqualTo(JsfCdiToSpring.VIEW);
    assertThat(acx.getBeanDefinition("viewScopedBean").getScope()).isEqualTo(JsfCdiToSpring.VIEW);
}

From source file:ch.nydi.spring.context.support.TestGenericXmlContextLoader.java

/**
 * {@inheritDoc}//from w w  w .j  av a2 s .co m
 */
@Override
public final ConfigurableApplicationContext loadContext(final String... locations) throws Exception {

    final DefaultListableBeanFactory beanFactory = new PrimaryResolverListableBeanFactory();
    beanFactory.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
    beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());

    final GenericApplicationContext context = new GenericApplicationContext(beanFactory);
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:com.wbss.mycoffee.in.helper.spring.WebContextLoader.java

@Override
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {

    final GenericWebApplicationContext webContext = new GenericWebApplicationContext();
    SERVLET_CONTEXT.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext);
    webContext.setServletContext(SERVLET_CONTEXT);
    createBeanDefinitionReader(webContext).loadBeanDefinitions(mergedConfig.getLocations());
    AnnotationConfigUtils.registerAnnotationConfigProcessors(webContext);
    webContext.refresh();// w  w w. j  ava  2 s .c om
    webContext.registerShutdownHook();
    return webContext;
}

From source file:com.autentia.wuija.spring.TestContextLoader.java

@Override
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("Loading ApplicationContext for locations ["
                + StringUtils.arrayToCommaDelimitedString(locations) + "].");
    }/*  ww w .ja  v  a 2  s.  c o  m*/

    final GenericWebApplicationContext context = new GenericWebApplicationContext();

    customizeBeanFactory(context.getDefaultListableBeanFactory());
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    customizeContext(context);

    context.refresh();
    context.registerShutdownHook();

    return context;
}

From source file:org.rosenvold.spring.convention.ConventionContextLoader.java

public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {
    ConventionBeanFactory conventionBeanFactory = new ConventionBeanFactory(createNameToClassResolver(),
            createCandidateEvaluator());
    GenericApplicationContext context = new GenericApplicationContext(conventionBeanFactory);
    prepareContext(context);//  w  w w  .  ja v  a2s . c  om
    customizeBeanFactory(context.getDefaultListableBeanFactory());
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    customizeContext(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:com.geodevv.testing.irmina.IrminaContextLoader.java

@Override
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(String.format("Loading ApplicationContext for merged context configuration [%s].",
                mergedConfig));//from   ww  w .ja va  2 s .  co  m
    }

    context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles());
    loadBeanDefinitions(context, mergedConfig);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();
    context.registerShutdownHook();

    return context;
}

From source file:fr.letitzen.demo.web.GenericWebXmlContextLoader.java

public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles());
    prepareContext(context);//from w  ww .  j  av a2 s  .  c o  m
    new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:org.joinfaces.annotations.JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java

@Test
public void testSessionScopedClass() {
    GenericApplicationContext acx = new GenericApplicationContext();
    AnnotationConfigUtils.registerAnnotationConfigProcessors(acx);

    acx.registerBeanDefinition("sessionScopedClass",
            new AnnotatedGenericBeanDefinition(new StandardAnnotationMetadata(SessionScopedClass.class)));
    acx.registerBeanDefinition("scopedBeansConfiguration",
            new RootBeanDefinition(ScopedBeansConfiguration.class));
    acx.addBeanFactoryPostProcessor(new JsfCdiToSpringBeanFactoryPostProcessor());
    acx.refresh();//from   ww  w .ja  v  a 2 s  . co m

    assertThat(acx.getBeanDefinition("sessionScopedClass").getScope()).isEqualTo(JsfCdiToSpring.SESSION);
    assertThat(acx.getBeanDefinition("sessionScopedBean").getScope()).isEqualTo(JsfCdiToSpring.SESSION);
}

From source file:darks.orm.spring.MapperClassDefinitionScanner.java

@Override
public int scan(String... basePackages) {
    int beanCountAtScanStart = this.registry.getBeanDefinitionCount();
    doScan(basePackages);/*from w  ww .ja  v  a  2s  .  c om*/
    AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry);
    return this.registry.getBeanDefinitionCount() - beanCountAtScanStart;
}