Search in sources :

Example 1 with ComponentAdapter

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

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

use of org.picocontainer.ComponentAdapter in project intellij-community by JetBrains.

the class BookmarkManagerTest method testBookmarkLineRemove.

public void testBookmarkLineRemove() throws IOException {
    List<ComponentAdapter> adapters = getProject().getPicoContainer().getComponentAdaptersOfType(ChangeListManagerImpl.class);
    System.out.println(adapters.size() + " adapters:");
    for (ComponentAdapter adapter : adapters) {
        System.out.println(adapter);
    }
    @NonNls String text = "public class Test {\n" + "    public void test() {\n" + "        int i = 1;\n" + "    }\n" + "}";
    init(text, TestFileType.TEXT);
    addBookmark(2);
    Document document = myEditor.getDocument();
    myEditor.getSelectionModel().setSelection(document.getLineStartOffset(2) - 1, document.getLineEndOffset(2));
    delete();
    assertTrue(getManager().getValidBookmarks().isEmpty());
}
Also used : NonNls(org.jetbrains.annotations.NonNls) ComponentAdapter(org.picocontainer.ComponentAdapter)

Example 4 with ComponentAdapter

use of org.picocontainer.ComponentAdapter in project kotlin by JetBrains.

the class KtParsingTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initApplication();
    ComponentAdapter component = getApplication().getPicoContainer().getComponentAdapter(ProgressManager.class.getName());
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    myProject = new MockProjectEx(getTestRootDisposable());
    myPsiManager = new MockPsiManager(myProject);
    myFileFactory = new PsiFileFactoryImpl(myPsiManager);
    MutablePicoContainer appContainer = getApplication().getPicoContainer();
    registerComponentInstance(appContainer, MessageBus.class, MessageBusFactory.newMessageBus(getApplication()));
    registerComponentInstance(appContainer, SchemesManagerFactory.class, new MockSchemesManagerFactory());
    final MockEditorFactory editorFactory = new MockEditorFactory();
    registerComponentInstance(appContainer, EditorFactory.class, editorFactory);
    registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {

        @Override
        public Document fun(CharSequence charSequence) {
            return editorFactory.createDocument(charSequence);
        }
    }, HARD_REF_TO_DOCUMENT_KEY));
    registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager());
    registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
    registerApplicationService(DefaultASTFactory.class, new CoreASTFactory());
    registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
    registerApplicationService(ProgressManager.class, new CoreProgressManager());
    myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
    myProject.registerService(PsiManager.class, myPsiManager);
    this.registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
    for (ParserDefinition definition : myDefinitions) {
        addExplicitExtension(LanguageParserDefinitions.INSTANCE, definition.getFileNodeType().getLanguage(), definition);
    }
    if (myDefinitions.length > 0) {
        configureFromParserDefinition(myDefinitions[0], myFileExt);
    }
    // That's for reparse routines
    final PomModelImpl pomModel = new PomModelImpl(myProject);
    myProject.registerService(PomModel.class, pomModel);
    new TreeAspect(pomModel);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) MockFileDocumentManagerImpl(com.intellij.mock.MockFileDocumentManagerImpl) TreeAspect(com.intellij.pom.tree.TreeAspect) CachedValuesManagerImpl(com.intellij.util.CachedValuesManagerImpl) CoreASTFactory(com.intellij.core.CoreASTFactory) PsiBuilderFactoryImpl(com.intellij.lang.impl.PsiBuilderFactoryImpl) Function(com.intellij.util.Function) PsiCachedValuesFactory(com.intellij.psi.impl.PsiCachedValuesFactory) ProgressManager(com.intellij.openapi.progress.ProgressManager) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) ReferenceProvidersRegistryImpl(com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl) PsiFileFactoryImpl(com.intellij.psi.impl.PsiFileFactoryImpl) PomModelImpl(com.intellij.pom.core.impl.PomModelImpl) ComponentAdapter(org.picocontainer.ComponentAdapter)

Example 5 with ComponentAdapter

use of org.picocontainer.ComponentAdapter in project android by JetBrains.

the class IdeComponents method doReplaceService.

private static <T> void doReplaceService(@NotNull ComponentManager componentManager, @NotNull Class<T> serviceType, @NotNull T newServiceInstance) {
    DefaultPicoContainer picoContainer = (DefaultPicoContainer) componentManager.getPicoContainer();
    String componentKey = serviceType.getName();
    ComponentAdapter componentAdapter = picoContainer.unregisterComponent(componentKey);
    assert componentAdapter != null;
    picoContainer.registerComponentInstance(componentKey, newServiceInstance);
    assertSame(newServiceInstance, picoContainer.getComponentInstance(componentKey));
}
Also used : DefaultPicoContainer(com.intellij.util.pico.DefaultPicoContainer) ComponentAdapter(org.picocontainer.ComponentAdapter)

Aggregations

ComponentAdapter (org.picocontainer.ComponentAdapter)5 ComponentMonitor (org.picocontainer.ComponentMonitor)2 DefaultPicoContainer (org.picocontainer.DefaultPicoContainer)2 OptInCaching (org.picocontainer.behaviors.OptInCaching)2 ReflectionLifecycleStrategy (org.picocontainer.lifecycle.ReflectionLifecycleStrategy)2 NullComponentMonitor (org.picocontainer.monitors.NullComponentMonitor)2 CoreASTFactory (com.intellij.core.CoreASTFactory)1 PsiBuilderFactoryImpl (com.intellij.lang.impl.PsiBuilderFactoryImpl)1 MockFileDocumentManagerImpl (com.intellij.mock.MockFileDocumentManagerImpl)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 CoreProgressManager (com.intellij.openapi.progress.impl.CoreProgressManager)1 PomModelImpl (com.intellij.pom.core.impl.PomModelImpl)1 TreeAspect (com.intellij.pom.tree.TreeAspect)1 PsiCachedValuesFactory (com.intellij.psi.impl.PsiCachedValuesFactory)1 PsiFileFactoryImpl (com.intellij.psi.impl.PsiFileFactoryImpl)1 ReferenceProvidersRegistryImpl (com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl)1 CachedValuesManagerImpl (com.intellij.util.CachedValuesManagerImpl)1 Function (com.intellij.util.Function)1 DefaultPicoContainer (com.intellij.util.pico.DefaultPicoContainer)1 NonNls (org.jetbrains.annotations.NonNls)1