Java 类com.intellij.openapi.components.ServiceDescriptor 实例源码

项目:tools-idea    文件:ServiceManagerImpl.java   
protected void installEP(final ExtensionPointName<ServiceDescriptor> pointName, final ComponentManager componentManager) {
  myExtensionPointName = pointName;
  final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(pointName);
  assert extensionPoint != null;

  final MutablePicoContainer picoContainer = (MutablePicoContainer)componentManager.getPicoContainer();

  myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() {
    public void extensionAdded(@NotNull final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) {
      if (descriptor.overrides) {
        ComponentAdapter oldAdapter =
          picoContainer.unregisterComponent(descriptor.getInterface());// Allow to re-define service implementations in plugins.
        if (oldAdapter == null) {
          throw new RuntimeException("Service: " + descriptor.getInterface() + " doesn't override anything");
        }
      }

      picoContainer.registerComponent(new MyComponentAdapter(descriptor, pluginDescriptor, (ComponentManagerEx)componentManager));
    }

    public void extensionRemoved(@NotNull final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) {
      picoContainer.unregisterComponent(extension.getInterface());
    }
  };
  extensionPoint.addExtensionPointListener(myExtensionPointListener);
}
项目:intellij-ce-playground    文件:ServiceManagerImpl.java   
protected void installEP(@NotNull ExtensionPointName<ServiceDescriptor> pointName, @NotNull final ComponentManager componentManager) {
  LOG.assertTrue(myExtensionPointName == null, "Already called installEP with " + myExtensionPointName);
  myExtensionPointName = pointName;
  final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(pointName);
  final MutablePicoContainer picoContainer = (MutablePicoContainer)componentManager.getPicoContainer();

  myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() {
    @Override
    public void extensionAdded(@NotNull final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) {
      if (descriptor.overrides) {
        // Allow to re-define service implementations in plugins.
        ComponentAdapter oldAdapter = picoContainer.unregisterComponent(descriptor.getInterface());
        if (oldAdapter == null) {
          throw new RuntimeException("Service: " + descriptor.getInterface() + " doesn't override anything");
        }
      }

      if (!ComponentManagerImpl.isComponentSuitableForOs(descriptor.os)) {
        return;
      }

      // empty serviceImplementation means we want to unregister service
      if (!StringUtil.isEmpty(descriptor.getImplementation())) {
        picoContainer.registerComponent(new MyComponentAdapter(descriptor, pluginDescriptor, (ComponentManagerEx)componentManager));
      }
    }

    @Override
    public void extensionRemoved(@NotNull final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) {
      picoContainer.unregisterComponent(extension.getInterface());
    }
  };
  extensionPoint.addExtensionPointListener(myExtensionPointListener);
}
项目:intellij-ce-playground    文件:ServiceManagerImpl.java   
public List<ServiceDescriptor> getAllDescriptors() {
  ServiceDescriptor[] extensions = Extensions.getExtensions(myExtensionPointName);
  return Arrays.asList(extensions);
}
项目:intellij-ce-playground    文件:ServiceManagerImpl.java   
@Override
public void disposeComponent() {
  final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(myExtensionPointName);
  extensionPoint.removeExtensionPointListener(myExtensionPointListener);
}
项目:intellij-ce-playground    文件:ServiceManagerImpl.java   
public MyComponentAdapter(final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor, ComponentManagerEx componentManager) {
  myDescriptor = descriptor;
  myPluginDescriptor = pluginDescriptor;
  myComponentManager = componentManager;
  myDelegate = null;
}
项目:tools-idea    文件:ServiceManagerImpl.java   
public List<ServiceDescriptor> getAllDescriptors() {
  ServiceDescriptor[] extensions = Extensions.getExtensions(myExtensionPointName);
  return Arrays.asList(extensions);
}
项目:tools-idea    文件:ServiceManagerImpl.java   
public MyComponentAdapter(final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor, ComponentManagerEx componentManager) {
  myDescriptor = descriptor;
  myPluginDescriptor = pluginDescriptor;
  myComponentManager = componentManager;
  myDelegate = null;
}