IDEA Plugin Dev - Service


A service is a plugin component loaded on demand, when your plugin calls the getService method of the ServiceManager class.

Only one instance of a service is loaded even though the service is called several times.

A service must have the interface and implementation classes specified in the plugin.xml file.

The service implementation class is used for service instantiation.


Three types of services:

  • application level services,
  • project level services
  • and module level services.



To declare a service, you can use the following extension points in the IDEA core:

  • applicationService: designed to declare an application level service.
  • projectService: designed to declare a project level service.
  • moduleService: designed to declare a module level service.

To declare a service:

  • Add the appropriate child element (<applicationService>, <projectService> or <moduleService>) to the <extensions> section of the plugin.xml file.
  • For the newly added child element, set the following attributes:
    • serviceInterface: specifies the service interface class.
    • serviceImplementation: specifies the service implementation class.

Note that the interface and implementation classes can be the same.

To clarify the service declaration procedure, consider the following fragment of the plugin.xml file:

<extensions defaultExtensionNs="com.intellij">
  <!-- Declare the application level service -->
  <applicationService serviceInterface="Mypackage.MyServiceInterfaceClass" serviceImplementation="Mypackage.MyServiceImplClass" />

  <!-- Declare the project level service -->
  <projectService serviceInterface="Mypackage.MyProjectServiceInterfaceClass" serviceImplementation="Mypackage.MyProjectServiceImplClass" />


To instantiate your service, in Java code, use the following syntax:

MyServiceImplClass service = ServiceManager.getService(MyServiceImplClass.class);

Documentation / Reference

Powered by ComboStrap