Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext


  /**
   * @param args
   * @throws InterruptedException
   */
  public static void main(String[] args) throws InterruptedException {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
    context.registerShutdownHook();
   
    while(true) {
      Thread.sleep(Long.MAX_VALUE);
    }
  }
View Full Code Here


     * 根据一批Spring配置文件初始化spring实例提供者。
     *
     * @param annotatedClasses
     */
    public SpringInstanceProvider(Class<?>... annotatedClasses) {
        applicationContext = new AnnotationConfigApplicationContext(annotatedClasses);
    }
View Full Code Here

    //TODO: unit tests throw warnings because no such initialization like this has taken place.
    //TODO: figure out how to make the unit tests not complain
    PropertyConfigurator.configure(PropertiesLoader.loadProperties(PROPERTIES_FILE_PATH));

    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    applicationContext.register(DependencyConfig.class);
    applicationContext.refresh();
   
    logger.info("Initializing game engine.");

    Engine engine = applicationContext.getBean(Engine.class);
    engine.run();

  }
View Full Code Here

    }
  }

  @Test
  public void withACAC() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("com.example");
    ctx.refresh();
  }
View Full Code Here

  public void run() throws InterruptedException {
    AnnotationConfigApplicationContext[] contexts = new AnnotationConfigApplicationContext[App.NUMBER_OF_THREAD];
    Thread[] threads = new Thread[App.NUMBER_OF_THREAD];

    for (int i = 0; i < App.NUMBER_OF_THREAD; i++) {
      contexts[i] = new AnnotationConfigApplicationContext();
      contexts[i].register(BeansDefinition.class);
      threads[i] = new Thread(new Appl(contexts[i]));
    }

    for (int i = 0; i < App.NUMBER_OF_THREAD; i++) {
View Full Code Here

public class ConfigTest {

  @Test
  public void testConfig() throws Exception {
    AbstractApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
    assertNotNull(context.getBean(Service.class));
    context.close();
  }
View Full Code Here

public class HighLevelContextTest {

  @Test
  public void contextBuilds() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(HighLevelContext.class);
    ctx.refresh();
  }
View Full Code Here

public class LowLevelContextTest {

  @Test
  public void contextBuilds() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(LowLevelContext.class);
    ctx.refresh();
  }
View Full Code Here

    @Test // this fails
    public void testAppConfigWithComponentScan()
    {
        // use the java config class with @ComponentScan annotation
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfigWithComponentScan.class);
        CustomerDAO dao = ctx.getBean(CustomerDAO.class);
        assertNotNull(dao);
    }
View Full Code Here

    @Test // this works
    public void testAppConfigWithoutComponentScan()
    {
        // use the java config with componentScan taken from external resource
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfigWithoutComponentScan.class);
        CustomerDAO dao = ctx.getBean(CustomerDAO.class);
        assertNotNull(dao);
    }
View Full Code Here

TOP

Related Classes of org.springframework.context.annotation.AnnotationConfigApplicationContext

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.