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:org.uimafit.spring.SpringContextResourceManagerTest.java

private ApplicationContext getApplicationContext() {
    final GenericApplicationContext ctx = new GenericApplicationContext();
    AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
    ctx.registerBeanDefinition("springBean", BeanDefinitionBuilder.genericBeanDefinition(String.class)
            .addConstructorArgValue("BEAN").getBeanDefinition());
    ctx.refresh();//from  w  w  w  . j a  v  a 2s . c om
    return ctx;
}

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

public ApplicationContext loadContext(String... locations) throws Exception {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    prepareContext(context);//from w  w  w  .jav a2  s  .c  o m
    new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:org.parancoe.web.test.junit4.WebXmlContextLoader.java

/**
 * Loads a Spring ApplicationContext from the supplied
 * <code>locations</code>. and creates a standard {@link GenericWebApplicationContext} instance.
 *
 * @return a new application context/*from  w  w w .  java 2 s  .  c  o m*/
 * @see org.springframework.test.context.ContextLoader#loadContext
 * @see GenericWebApplicationContext
 * @see #createBeanDefinitionReader(GenericApplicationContext)
 * @see BeanDefinitionReader
 */
@Override
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {
    if (logger.isDebugEnabled()) {
        logger.debug("Loading ApplicationContext for locations [{}].",
                StringUtils.arrayToCommaDelimitedString(locations));
    }
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    MockServletContext servletContext = new MockServletContext();
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
    context.setServletContext(servletContext);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:org.uimafit.spring.UimaFactoryInjectionTest.java

private ApplicationContext getApplicationContext() {
    final GenericApplicationContext ctx = new GenericApplicationContext();
    AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
    ctx.registerBeanDefinition("otherBean", BeanDefinitionBuilder.genericBeanDefinition(String.class)
            .addConstructorArgValue("BEAN").getBeanDefinition());

    ctx.registerBeanDefinition("analysisEngineFactory",
            BeanDefinitionBuilder.genericBeanDefinition(AnalysisEngineFactory_impl.class).getBeanDefinition());
    ctx.registerBeanDefinition("casConsumerFactory",
            BeanDefinitionBuilder.genericBeanDefinition(CasConsumerFactory_impl.class).getBeanDefinition());
    ctx.registerBeanDefinition("casInitializerFactory",
            BeanDefinitionBuilder.genericBeanDefinition(CasInitializerFactory_impl.class).getBeanDefinition());
    ctx.registerBeanDefinition("collectionReaderFactory", BeanDefinitionBuilder
            .genericBeanDefinition(CollectionReaderFactory_impl.class).getBeanDefinition());
    ctx.registerBeanDefinition("customResourceFactory",
            BeanDefinitionBuilder.genericBeanDefinition(CustomResourceFactory_impl.class).getBeanDefinition());
    ctx.refresh();//from  w  ww. j  a  va  2 s.  co  m
    return ctx;
}

From source file:mx.edu.um.mateo.general.test.GenericWebXmlContextLoader.java

@Override
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles());
    prepareContext(context);/*from  ww w  .j ava  2s. co  m*/
    new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
}

From source file:com.sinosoft.one.mvc.scanning.context.MvcAppContext.java

/** MvcBeanFactory???Mvc? */
protected void prepareBeanFactoryByMvc(ConfigurableListableBeanFactory beanFactory) {
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
    AnnotationConfigUtils.registerAnnotationConfigProcessors(registry);
}

From source file:com.gzj.tulip.load.context.RoseAppContext.java

/** RoseBeanFactory???Rose? */
protected void prepareBeanFactoryByRose(ConfigurableListableBeanFactory beanFactory) {
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
    AnnotationConfigUtils.registerAnnotationConfigProcessors(registry);
}

From source file:com.laxser.blitz.scanning.context.BlitzAppContext.java

/** BlitzBeanFactory???Blitz? */
protected void prepareBeanFactoryByBlitz(ConfigurableListableBeanFactory beanFactory) {
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
    AnnotationConfigUtils.registerAnnotationConfigProcessors(registry);
}

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

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

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

    assertThat(acx.getBeanDefinition("noScopedClass").getScope()).isEqualTo("");
    assertThat(acx.getBeanDefinition("noScopedBean").getScope()).isEqualTo("");

}

From source file:com.example.springsecurity.web.controllers.GenericWebContextLoader.java

protected void loadBeanDefinitions(GenericWebApplicationContext context, String[] locations) {
    new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    context.refresh();/*from w w  w  . j ava  2  s . com*/
    context.registerShutdownHook();
}