Beispiel #1
0
 /*
  * Spring
  */
 @Test
 public void spring() {
   final BeanFactory factory = new XmlBeanFactory(new ClassPathResource("spring.xml"));
   final SuperManager mgr = (SuperManager) factory.getBean("SuperManager");
   mgr.manage1();
   mgr.manage2();
 }
Beispiel #2
0
 /*
  * Guice
  */
 @Test
 public void guice() {
   final Injector injector = Guice.createInjector(new GuiceBinderModule());
   final SuperManager mgr = injector.getInstance(SuperManager.class);
   mgr.manage1();
   mgr.manage2();
 }
Beispiel #3
0
  /*
   * PicoContainer
   */
  @Test
  public void picocontainer() {
    final MutablePicoContainer pico = new DefaultPicoContainer();
    pico.registerComponentImplementation(SuperManager.class);
    pico.registerComponentInstance(new OutputManager1(new OutputHelper(new SystemOutOutput())));
    pico.registerComponentInstance(new OutputManager2(new OutputHelper(new LoggerOutput())));
    pico.registerComponentImplementation(ComputationManager.class);
    pico.registerComponentImplementation(ComputationHelper.class);

    final SuperManager mgr = (SuperManager) pico.getComponentInstance(SuperManager.class);
    mgr.manage1();
    mgr.manage2();
  }