diff --git a/buildUML/basics/getting-service.puml b/buildUML/basics/getting-service.puml new file mode 100644 index 000000000..036a4b2e5 --- /dev/null +++ b/buildUML/basics/getting-service.puml @@ -0,0 +1,53 @@ +@startuml +: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 Light Service) then (yes) +else (no) + if (Is 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 \ No newline at end of file diff --git a/images/basics/plugin_structure/img/getting_service.svg b/images/basics/plugin_structure/img/getting_service.svg new file mode 100644 index 000000000..cb2ffb8cc --- /dev/null +++ b/images/basics/plugin_structure/img/getting_service.svg @@ -0,0 +1,150 @@ + + +In any thread.Get on demand only.Do not cache result.Do not request in constructor unless needed.getServiceReturnnullnoIs Service Declaration FoundyesnoIs Light ServiceyesIs Container Active?activedisposed or dispose in progresssynchronized on service classIs Initializing?yesnoThrowPluginExceptionCyclic Service Initializationnon cancelableAvoid getting other services to reduce initialization tree.As less dependencies, as more faster and reliable.Create InstanceRegister to be Disposed on Container Disposeif ImplementsDisposableLoad Persistent Stateif ImplementsPersistentStateComponentnoIs Created and Initialized?yesThrowProcessCanceledExceptionnoIs Created and Initialized?yesReturn Instance \ No newline at end of file diff --git a/topics/basics/plugin_structure/plugin_services.md b/topics/basics/plugin_structure/plugin_services.md index 1fac41e01..803d92bee 100644 --- a/topics/basics/plugin_structure/plugin_services.md +++ b/topics/basics/plugin_structure/plugin_services.md @@ -99,6 +99,12 @@ val projectService = project.service() + + +![Getting Service](getting_service.svg) + + + ## Project Service Sample This minimal sample shows [Light Service](#light-services) `ProjectService` interacting with another project level service `AnotherService` (not shown here).