@startuml !include jb-plantuml-theme.puml :getService; note right In any thread. Get on demand only. Do not cache result. Do not request in constructor unless needed. end note if (Is [[http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_services.html?search=ser#light-service Light Service]]) then (yes) else (no) if (Is [[http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_services.html?search=ser#how-to-declare-a-service Service Declaration]] Found) then (yes) else (no) :Return ""null""; detach endif endif if (Is Created and Initialized?) then (yes) else (no) if (Is Container Active?) then (active) partition "synchronized on service class" { if (Is Created and Initialized?) then (yes) else (no) if (Is Initializing?) then (yes) :Throw ""PluginException"" Cyclic Service Initialization; detach else (no) partition "non cancelable" { :Create Instance] note right Avoid getting other services to reduce initialization tree. As less dependencies, as more faster and reliable. end note :Register to be Disposed on Container Dispose if Implements ""Disposable""] :Load Persistent State if Implements ""PersistentStateComponent""] } endif endif } else (disposed or dispose in progress) :Throw ""ProcessCanceledException""; detach endif endif :Return Instance; @enduml