Java 类com.intellij.util.pico.DefaultPicoContainer 实例源码

项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
@NotNull
@Override
public final <T> List<T> getComponentInstancesOfType(@NotNull Class<T> baseClass) {
  List<T> result = null;
  // we must use instances only from our adapter (could be service or extension point or something else)
  for (ComponentAdapter componentAdapter : ((DefaultPicoContainer)getPicoContainer()).getComponentAdapters()) {
    if (componentAdapter instanceof ComponentConfigComponentAdapter && ReflectionUtil.isAssignable(baseClass, componentAdapter.getComponentImplementation())) {
      //noinspection unchecked
      T instance = (T)((ComponentConfigComponentAdapter)componentAdapter).myInitializedComponentInstance;
      if (instance != null) {
        if (result == null) {
          result = new ArrayList<T>();
        }
        result.add(instance);
      }
    }
  }
  return ContainerUtil.notNullize(result);
}
项目:consulo    文件:MockComponentManager.java   
public MockComponentManager(@Nullable PicoContainer parent, @Nonnull Disposable parentDisposable) {
  myPicoContainer = new DefaultPicoContainer(parent) {
    private final Set<Object> myDisposableComponents = ContainerUtil.newConcurrentSet();

    @Override
    @Nullable
    public Object getComponentInstance(final Object componentKey) {
      final Object o = super.getComponentInstance(componentKey);
      if (o instanceof Disposable && o != MockComponentManager.this) {
        if (myDisposableComponents.add(o))
          Disposer.register(MockComponentManager.this, (Disposable)o);
      }
      return o;
    }
  };
  myPicoContainer.registerComponentInstance(this);
  Disposer.register(parentDisposable, this);
}
项目:intellij-ce-playground    文件:EditorTypedHandlerBean.java   
public TypedActionHandler getHandler(TypedActionHandler originalHandler) {
  if (myHandler == null) {
    try {
      DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer());
      container.registerComponentInstance(originalHandler);
      myHandler = instantiate(implementationClass, container);
    }
    catch(Exception e) {
      LOG.error(e);
      return null;
    }
  }
  return myHandler;
}
项目:intellij-ce-playground    文件:EditorActionHandlerBean.java   
public EditorActionHandler getHandler(EditorActionHandler originalHandler) {
  if (myHandler == null) {
    try {
      DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer());
      container.registerComponentInstance(originalHandler);
      myHandler = instantiate(implementationClass, container);
    }
    catch(Exception e) {
      LOG.error(e);
      return null;
    }
  }
  return myHandler;
}
项目:intellij-ce-playground    文件:ExtensionsAreaImpl.java   
public ExtensionsAreaImpl(String areaClass, AreaInstance areaInstance, PicoContainer parentPicoContainer, @NotNull LogProvider logger) {
  myCreationTrace = DEBUG_REGISTRATION ? new Throwable("Area creation trace") : null;
  myAreaClass = areaClass;
  myAreaInstance = areaInstance;
  myPicoContainer = new DefaultPicoContainer(parentPicoContainer);
  myLogger = logger;
  initialize();
}
项目:intellij-ce-playground    文件:HeavyTestFixtureBuilderImpl.java   
public HeavyTestFixtureBuilderImpl(HeavyIdeaTestFixtureImpl fixture, final Map<Class<? extends ModuleFixtureBuilder>, Class<? extends ModuleFixtureBuilder>> providers) {
  myFixture = fixture;
  myProviders = providers;

  myContainer = new DefaultPicoContainer();
  myContainer.registerComponentInstance(this);
}
项目:intellij-ce-playground    文件:MockComponentManager.java   
public MockComponentManager(@Nullable PicoContainer parent, @NotNull Disposable parentDisposable) {
  myPicoContainer = new DefaultPicoContainer(parent) {
    @Override
    @Nullable
    public Object getComponentInstance(final Object componentKey) {
      final Object o = super.getComponentInstance(componentKey);
      registerComponentInDisposer(o);
      return o;
    }
  };

  myPicoContainer.registerComponentInstance(this);
  Disposer.register(parentDisposable, this);
}
项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
protected void createComponents(@Nullable ProgressIndicator indicator) {
  DefaultPicoContainer picoContainer = (DefaultPicoContainer)getPicoContainer();
  for (ComponentAdapter componentAdapter : picoContainer.getComponentAdapters()) {
    if (componentAdapter instanceof ComponentConfigComponentAdapter) {
      componentAdapter.getComponentInstance(picoContainer);
      if (indicator != null) {
        indicator.checkCanceled();
      }
    }
  }
}
项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
@Nullable
private ComponentConfigComponentAdapter getComponentAdapter(@NotNull Class<?> componentImplementation) {
  for (ComponentAdapter componentAdapter : ((DefaultPicoContainer)getPicoContainer()).getComponentAdapters()) {
    if (componentAdapter instanceof ComponentConfigComponentAdapter && componentAdapter.getComponentImplementation() == componentImplementation) {
      return ((ComponentConfigComponentAdapter)componentAdapter);
    }
  }
  return null;
}
项目:intellij    文件:TestUtils.java   
@NotNull
public static MockProject mockProject(
    @Nullable PicoContainer container, Disposable parentDisposable) {
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  container = container != null ? container : new DefaultPicoContainer();
  return new MockProject(container, parentDisposable);
}
项目:google-cloud-intellij    文件:TestUtils.java   
/** Construct a mock project. */
@NotNull
public static MockProject mockProject(@Nullable PicoContainer container) {
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  container = container != null ? container : new DefaultPicoContainer();
  return new MockProject(container, getParentDisposableForCleanup());
}
项目:consulo    文件:HeavyTestFixtureBuilderImpl.java   
public HeavyTestFixtureBuilderImpl(HeavyIdeaTestFixtureImpl fixture, final Map<Class<? extends ModuleFixtureBuilder>, Class<? extends ModuleFixtureBuilder>> providers) {
  myFixture = fixture;
  myProviders = providers;

  myContainer = new DefaultPicoContainer();
  myContainer.registerComponentInstance(this);
}
项目:consulo    文件:EditorTypedHandlerBean.java   
public TypedActionHandler getHandler(TypedActionHandler originalHandler) {
  if (myHandler == null) {
    try {
      DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer());
      container.registerComponentInstance(originalHandler);
      myHandler = instantiate(implementationClass, container);
    }
    catch(Exception e) {
      LOG.error(e);
      return null;
    }
  }
  return myHandler;
}
项目:consulo    文件:EditorActionHandlerBean.java   
public EditorActionHandler getHandler(EditorActionHandler originalHandler) {
  if (myHandler == null) {
    try {
      DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer());
      container.registerComponentInstance(originalHandler);
      myHandler = instantiate(implementationClass, container);
    }
    catch(Exception e) {
      LOG.error(e);
      return null;
    }
  }
  return myHandler;
}
项目:consulo    文件:ExtensionsAreaImpl.java   
public ExtensionsAreaImpl(String areaClass, AreaInstance areaInstance, PicoContainer parentPicoContainer, @Nonnull LogProvider logger) {
  myCreationTrace = DEBUG_REGISTRATION ? new Throwable("Area creation trace") : null;
  myAreaClass = areaClass;
  myAreaInstance = areaInstance;
  myPicoContainer = new DefaultPicoContainer(parentPicoContainer);
  myLogger = logger;
  initialize();
}
项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
@NotNull
protected MutablePicoContainer createPicoContainer() {
  return myParentComponentManager == null ? new DefaultPicoContainer() : new DefaultPicoContainer(myParentComponentManager.getPicoContainer());
}