com.intellij.openapi.components.BaseComponent Java Examples

The following examples show how to use com.intellij.openapi.components.BaseComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockProject.java    From aem-ide-tooling-4-intellij with Apache License 2.0 4 votes vote down vote up
@Override
public BaseComponent getComponent(@NotNull String s) {
    return null;
}
 
Example #2
Source File: StringUtilsTest.java    From EclipseCodeFormatter with Apache License 2.0 4 votes vote down vote up
@Override
public BaseComponent getComponent(String name) {
	return null;
}
 
Example #3
Source File: ComponentManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void loadClasses(@Nonnull ComponentConfig config, List<Class> notLazyServices, InjectingContainerBuilder builder) {
  ClassLoader loader = config.getClassLoader();

  try {
    final Class interfaceClass = Class.forName(config.getInterfaceClass(), false, loader);
    final Class implementationClass = Comparing.equal(config.getInterfaceClass(), config.getImplementationClass()) ? interfaceClass : Class.forName(config.getImplementationClass(), false, loader);

    InjectingPoint<Object> point = builder.bind(interfaceClass);

    // force singleton
    point.forceSingleton();
    // to impl class
    point.to(implementationClass);
    // post processor
    point.injectListener((startTime, componentInstance) -> {
      if (myChecker.containsKey(interfaceClass)) {
        throw new IllegalArgumentException("Duplicate init of " + interfaceClass);
      }
      myChecker.put(interfaceClass, componentInstance);

      if (componentInstance instanceof Disposable) {
        Disposer.register(ComponentManagerImpl.this, (Disposable)componentInstance);
      }

      boolean isStorableComponent = initializeIfStorableComponent(componentInstance, false, false);

      if (componentInstance instanceof BaseComponent) {
        try {
          ((BaseComponent)componentInstance).initComponent();

          if (!isStorableComponent) {
            LOG.warn("Not storable component implement initComponent() method, which can moved to constructor, component: " + componentInstance.getClass().getName());
          }
        }
        catch (BaseComponent.DefaultImplException ignored) {
          // skip default impl
        }
      }

      long ms = (System.nanoTime() - startTime) / 1000000;
      if (ms > 10 && logSlowComponents()) {
        LOG.info(componentInstance.getClass().getName() + " initialized in " + ms + " ms");
      }
    });

    myComponentClassToConfig.put(implementationClass, config);

    notLazyServices.add(interfaceClass);
  }
  catch (Throwable t) {
    handleInitComponentError(t, null, config);
  }
}