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);
}
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);
}
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());
}
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);
}
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));
}
Aggregations