Add the appropriate child element (, or ) to the section of the plugin.xml file. 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" />
</extensions>
Get
To instantiate your service, in Java code, use the following syntax:
MyServiceImplClass service = ServiceManager.getService(MyServiceImplClass.class);
Documentation / Reference