Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext.refresh()


        new AnnotationConfigApplicationContext();
    ctx.register(FirstDao.class);
    ctx.register(SecondDao.class);
    ctx.register(FirstService.class);
    ctx.register(SecondService.class);
    ctx.refresh();
  }

}
View Full Code Here


  @Test
  public void repro() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(MyComponent.class);
    ctx.register(MyConfig.class);
    ctx.refresh();
    System.out.println(ctx.getBean(MyComponent.class).beans);
  }

  static class MyComponent {
    @Autowired
View Full Code Here

public class Spr10918Test {
    @Test
    public void shouldInvokeRegistrarOnlyOnce() {
        final AnnotationConfigApplicationContext myContext = new AnnotationConfigApplicationContext();
        myContext.scan(getClass().getPackage().getName());
        myContext.refresh();
        assertThat(TestImport.theInvocations, is(1));
    }
}
View Full Code Here

  @Test
  public void testPlainObjectSucess() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Baz.class);
    ctx.refresh();

    Baz bean = ctx.getBean(Baz.class);
    Assert.assertEquals(bean.getClass(), Baz.class);
    Assert.assertEquals(1, bean.getValueCounter());
    ctx.getBeanFactory().autowireBeanProperties(unwrapAopProxyIfNecessary(bean), AUTOWIRE_BY_NAME, false);
View Full Code Here

  @Test
  public void testJdkProxyObjectFail() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(BarImpl.class, APC_Config.class);
    ctx.refresh();

    Bar bean = ctx.getBean(Bar.class);
    Assert.assertTrue(AopUtils.isJdkDynamicProxy(bean));
    Assert.assertEquals(1, bean.getValueCounter());
    ctx.getBeanFactory().autowireBeanProperties(unwrapAopProxyIfNecessary(bean), AUTOWIRE_BY_NAME, false);
View Full Code Here

  @Test
  public void testCglibProxyObjectFail() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Foo.class, APC_Config.class);
    ctx.refresh();

    Foo bean = ctx.getBean(Foo.class);
    Assert.assertTrue(AopUtils.isCglibProxy( bean ));
    Assert.assertEquals(1, bean.getValueCounter());
    ctx.getBeanFactory().autowireBeanProperties(unwrapAopProxyIfNecessary(bean), AUTOWIRE_BY_NAME, false);
View Full Code Here

    ConfigurableApplicationContext parent = new GenericApplicationContext();
    parent.refresh();

    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.setParent(parent);
    child.refresh();

    ConfigurableEnvironment env = child.getBean(ConfigurableEnvironment.class);
    assertThat("UNKNOWN ENV", env, anyOf(sameInstance(parent.getEnvironment()), sameInstance(child.getEnvironment())));
    assertThat("EXPECTED CHILD CTX ENV", env, sameInstance(child.getEnvironment()));
  }
View Full Code Here

  @Test
  public void repro() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("org.springframework.context.annotation.configuration.spr8955");
    ctx.refresh();
    //ctx.containsBean("child");
  }

}
View Full Code Here

  @Test
  public void repro() throws IOException, InterruptedException, ExecutionException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class);
    ctx.refresh();
    AsyncProcess bean = ctx.getBean(AsyncProcess.class);
    assertThat(AopUtils.isAopProxy(bean), is(true));
    Future<String> result = bean.findBalanceAsync("123");
    assertThat(result.get().contains("ppte-"), is(true));
  }
View Full Code Here

  {
    super.init();

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("org.wicketTutorial.ejbBean");
    ctx.refresh();
   
    getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx));
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.