use of org.picocontainer.PicoContainer in project intellij-community by JetBrains.
the class ServiceManager method doGetService.
@Nullable
private static <T> T doGetService(ComponentManager componentManager, @NotNull Class<T> serviceClass) {
PicoContainer picoContainer = componentManager.getPicoContainer();
@SuppressWarnings("unchecked") T instance = (T) picoContainer.getComponentInstance(serviceClass.getName());
if (instance == null) {
instance = componentManager.getComponent(serviceClass);
if (instance != null) {
Application app = ApplicationManager.getApplication();
String message = serviceClass.getName() + " requested as a service, but it is a component - convert it to a service or change call to " + (componentManager == app ? "ApplicationManager.getApplication().getComponent()" : "project.getComponent()");
if (app.isUnitTestMode()) {
LOG.error(message);
} else {
LOG.warn(message);
}
}
}
return instance;
}
use of org.picocontainer.PicoContainer in project intellij-community by JetBrains.
the class ThreadLocalAnnotatorMap method cloneTemplates.
@SuppressWarnings("unchecked")
@NotNull
private List<V> cloneTemplates(@NotNull Collection<V> templates) {
List<V> result = new ArrayList<>(templates.size());
PicoContainer container = ApplicationManager.getApplication().getPicoContainer();
for (V template : templates) {
Class<? extends V> aClass = (Class<? extends V>) template.getClass();
V clone = (V) new CachingConstructorInjectionComponentAdapter(aClass.getName(), aClass).getComponentInstance(container);
result.add(clone);
}
return result;
}
Aggregations