Search in sources :

Example 1 with DefaultPicoContainer

use of org.picocontainer.DefaultPicoContainer in project sonarqube by SonarSource.

the class TaskContainerImpl method createContainer.

/**
   * Creates a PicContainer which extends the specified ComponentContainer <strong>but is not referenced in return</strong>
   * and lazily starts its components.
   */
private static MutablePicoContainer createContainer(ComponentContainer parent) {
    ComponentMonitor componentMonitor = new NullComponentMonitor();
    ReflectionLifecycleStrategy lifecycleStrategy = new ReflectionLifecycleStrategy(componentMonitor, "start", "stop", "close") {

        @Override
        public boolean isLazy(ComponentAdapter<?> adapter) {
            return adapter.getComponentImplementation().getAnnotation(EagerStart.class) == null;
        }
    };
    return new DefaultPicoContainer(new OptInCaching(), lifecycleStrategy, parent.getPicoContainer(), componentMonitor);
}
Also used : OptInCaching(org.picocontainer.behaviors.OptInCaching) DefaultPicoContainer(org.picocontainer.DefaultPicoContainer) NullComponentMonitor(org.picocontainer.monitors.NullComponentMonitor) ComponentMonitor(org.picocontainer.ComponentMonitor) NullComponentMonitor(org.picocontainer.monitors.NullComponentMonitor) ReflectionLifecycleStrategy(org.picocontainer.lifecycle.ReflectionLifecycleStrategy) ComponentAdapter(org.picocontainer.ComponentAdapter)

Example 2 with DefaultPicoContainer

use of org.picocontainer.DefaultPicoContainer in project jbehave-core by jbehave.

the class CoreStoriesUsingPico method createPicoContainer.

private PicoContainer createPicoContainer() {
    MutablePicoContainer container = new DefaultPicoContainer(new Caching().wrap(new ConstructorInjection()));
    container.addComponent(TradingService.class);
    container.addComponent(TraderSteps.class);
    container.addComponent(BeforeAfterSteps.class);
    container.addComponent(AndSteps.class);
    container.addComponent(CalendarSteps.class);
    container.addComponent(PendingSteps.class);
    container.addComponent(PriorityMatchingSteps.class);
    container.addComponent(SandpitSteps.class);
    container.addComponent(SearchSteps.class);
    return container;
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) DefaultPicoContainer(org.picocontainer.DefaultPicoContainer) Caching(org.picocontainer.behaviors.Caching) ConstructorInjection(org.picocontainer.injectors.ConstructorInjection)

Example 3 with DefaultPicoContainer

use of org.picocontainer.DefaultPicoContainer in project sonarqube by SonarSource.

the class MigrationContainerImpl method createContainer.

/**
   * Creates a PicContainer which extends the specified ComponentContainer <strong>but is not referenced in return</strong>.
   */
private static MutablePicoContainer createContainer(ComponentContainer parent) {
    ComponentMonitor componentMonitor = new NullComponentMonitor();
    ReflectionLifecycleStrategy lifecycleStrategy = new ReflectionLifecycleStrategy(componentMonitor, "start", "stop", "close") {

        @Override
        public boolean isLazy(ComponentAdapter<?> adapter) {
            return true;
        }
    };
    return new DefaultPicoContainer(new OptInCaching(), lifecycleStrategy, parent.getPicoContainer(), componentMonitor);
}
Also used : OptInCaching(org.picocontainer.behaviors.OptInCaching) DefaultPicoContainer(org.picocontainer.DefaultPicoContainer) NullComponentMonitor(org.picocontainer.monitors.NullComponentMonitor) ComponentMonitor(org.picocontainer.ComponentMonitor) NullComponentMonitor(org.picocontainer.monitors.NullComponentMonitor) ReflectionLifecycleStrategy(org.picocontainer.lifecycle.ReflectionLifecycleStrategy) ComponentAdapter(org.picocontainer.ComponentAdapter)

Aggregations

DefaultPicoContainer (org.picocontainer.DefaultPicoContainer)3 ComponentAdapter (org.picocontainer.ComponentAdapter)2 ComponentMonitor (org.picocontainer.ComponentMonitor)2 OptInCaching (org.picocontainer.behaviors.OptInCaching)2 ReflectionLifecycleStrategy (org.picocontainer.lifecycle.ReflectionLifecycleStrategy)2 NullComponentMonitor (org.picocontainer.monitors.NullComponentMonitor)2 MutablePicoContainer (org.picocontainer.MutablePicoContainer)1 Caching (org.picocontainer.behaviors.Caching)1 ConstructorInjection (org.picocontainer.injectors.ConstructorInjection)1