Search in sources :

Example 1 with OptInCaching

use of org.picocontainer.behaviors.OptInCaching 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 OptInCaching

use of org.picocontainer.behaviors.OptInCaching 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)

Example 3 with OptInCaching

use of org.picocontainer.behaviors.OptInCaching in project sonarqube by SonarSource.

the class ComponentContainer method createPicoContainer.

public static MutablePicoContainer createPicoContainer() {
    ReflectionLifecycleStrategy lifecycleStrategy = new ReflectionLifecycleStrategy(new NullComponentMonitor(), "start", "stop", "close") {

        @Override
        public void start(Object component) {
            Profiler profiler = Profiler.createIfTrace(Loggers.get(ComponentContainer.class));
            profiler.start();
            super.start(component);
            profiler.stopTrace(component.getClass().getCanonicalName() + " started");
        }
    };
    return new ExtendedDefaultPicoContainer(new OptInCaching(), lifecycleStrategy, null);
}
Also used : OptInCaching(org.picocontainer.behaviors.OptInCaching) Profiler(org.sonar.api.utils.log.Profiler) NullComponentMonitor(org.picocontainer.monitors.NullComponentMonitor) ReflectionLifecycleStrategy(org.picocontainer.lifecycle.ReflectionLifecycleStrategy)

Aggregations

OptInCaching (org.picocontainer.behaviors.OptInCaching)3 ReflectionLifecycleStrategy (org.picocontainer.lifecycle.ReflectionLifecycleStrategy)3 NullComponentMonitor (org.picocontainer.monitors.NullComponentMonitor)3 ComponentAdapter (org.picocontainer.ComponentAdapter)2 ComponentMonitor (org.picocontainer.ComponentMonitor)2 DefaultPicoContainer (org.picocontainer.DefaultPicoContainer)2 Profiler (org.sonar.api.utils.log.Profiler)1