/**
   * {@inheritDoc}
   *
   * @see org.picocontainer.Startable#start()
   */
  public void start() {
    if (logger.isInfoEnabled()) {
      logger.info("Starting Container " + delegate);
    }

    delegate.start();
  }
  private void startSystemWithXmlSerializer() {

    MutablePicoContainer container = new PicoBuilder().withLifecycle().withCaching().build();
    container.addComponent(directory);
    container.addComponent(JavaPersistenceManager.class);
    container.addComponent(XmlPersistenceManager.class);
    container.addComponent(PersistenceConverter.class);
    container.start();

    persistence = container.getComponent(DestinationPersistenceManager.class);
  }
  private void startSystemWithXmlSerializerWillFailAfterWritingTheFirstEvent() {
    MutablePicoContainer container = new PicoBuilder().withLifecycle().withCaching().build();
    container.addComponent(directory);
    container.addComponent(JavaPersistenceManager.class);
    container.addComponent(XmlSerializerWillFailAfterWritingTheFirstEvent.class);
    container.addComponent(PersistenceConverter.class);

    try {
      container.start();
      fail("Must throw exception");
    } catch (Exception e) {
      assertEquals("Premeditate error writing event", e.getCause().getMessage());
    }

    persistence = container.getComponent(DestinationPersistenceManager.class);
  }
Пример #4
0
  private MutablePicoContainer createSessionContainer(HttpSession session) {
    MutablePicoContainer sessionContainer =
        new DefaultPicoContainer(
            new Caching(),
            new JavaEE5LifecycleStrategy(new NullComponentMonitor()),
            this.appContainer);

    sessionContainer.addComponent(HttpSession.class, session);
    session.setAttribute(CONTAINER_SESSION_KEY, sessionContainer);

    if (logger.isDebugEnabled()) {
      logger.debug("Session components are " + sessionScoped);
    }

    for (Map.Entry<Class<?>, Class<?>> entry : sessionScoped.entrySet()) {
      sessionContainer.addComponent(entry.getKey(), entry.getValue());
    }

    registerComponentFactories(sessionContainer, componentFactoryRegistry.getSessionMap());

    sessionContainer.start();
    return sessionContainer;
  }
Пример #5
0
  public final void start(ServletContext context) {
    ComponentRegistry componentRegistry = getComponentRegistry();
    registerBundledComponents(componentRegistry);

    this.picoContainer.addComponent(context);

    Scanner scanner = new ReflectionsScanner(context);

    this.picoContainer.addComponent(scanner);

    registerAnnotatedComponents(scanner, componentRegistry);

    getComponentRegistry().init();

    StereotypedComponentRegistrar componentRegistrar =
        picoContainer.getComponent(StereotypedComponentRegistrar.class);
    componentRegistrar.registerFrom(scanner);

    registerCustomComponents(picoContainer, scanner);

    picoContainer.start();

    registerCacheComponents();
  }