Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext register

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext register

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext register.

Prototype

public void register(Class<?>... annotatedClasses) 

Source Link

Document

Register one or more annotated classes to be processed.

Usage

From source file:org.springframework.integration.configuration.EnableIntegrationTests.java

@Test
public void testParentChildAnnotationConfiguration() {
    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.register(ChildConfiguration.class);
    child.setParent(this.context);
    child.refresh();/*w  w w  .ja  v  a2s.  c  o  m*/
    AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
    ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
    assertTrue(foo.getChannelInterceptors().contains(baz));
    assertFalse(this.output.getChannelInterceptors().contains(baz));
    child.close();
}

From source file:org.springframework.integration.configuration.EnableIntegrationTests.java

@Test
public void testParentChildAnnotationConfigurationFromAnotherPackage() {
    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.register(org.springframework.integration.configuration2.ChildConfiguration.class);
    child.setParent(this.context);
    child.refresh();/*from  w  w  w .ja  va2  s. c o  m*/
    AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
    ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
    assertTrue(foo.getChannelInterceptors().contains(baz));
    assertFalse(this.output.getChannelInterceptors().contains(baz));
    child.close();
}