2 ############################
3 Registering Models with OSGi
4 ############################
6 The OSGi framework activates the *OSGiModelRuntime* component, who initiates:
8 * **YangModuleInfoScanner** - tracks bundles and attempts to retrieve *YangModuleInfo*, which it then feeds to *YangModuleInfoRegistry*
9 * **YangModuleInfoRegistry** - updates *SchemaContext* each time new *YangModuleInfo* is added/removed
11 The diagram below shows the process of registering the modules found in a recently tracked bundle.
12 The **YangModuleInfoScanner** collects the *ModuleInfo*-s from that bundle and forwards them to the **YangModuleInfoRegistry**.
13 From there the **ModuleInfoSnapshotResolver** checks for existing registration of each *YangModuleInfo*
14 and if exists, it reuses, otherwise creates a fresh registration with the help of *YangTextSchemaContextResolver*.
16 After each *ModuleInfo* is registered, the **YangModuleInfoScanner** initiates a snapshot update
17 on the **YangModuleInfoRegistry**. During the snapshot capture, the *EffectiveSchemaContext*
18 is updated and preserved within that snapshot.
23 boundary " " <<OSGi Tracker>>
24 participant OSGiModelRuntime as "OSGiModelRuntime"
25 participant YangModuleInfoScanner as "YangModuleInfoScanner"
26 participant YangModuleInfoRegistry as "YangModuleInfoRegistry"
27 participant ModuleInfoSnapshotResolver as "ModuleInfoSnapshotResolver"
28 participant YangTextSchemaContextResolver as "YangTextSchemaContextResolver"
30 -> OSGiModelRuntime : OSGi Component activation
31 activate OSGiModelRuntime
33 OSGiModelRuntime -> YangModuleInfoScanner: Initialize YangModuleInfoScanner as BundleTracker
34 activate YangModuleInfoScanner
36 OSGiModelRuntime -> YangModuleInfoRegistry: Initialize YangModuleInfoRegistry
37 activate YangModuleInfoRegistry
39 deactivate OSGiModelRuntime
40 deactivate YangModuleInfoScanner
41 deactivate YangModuleInfoRegistry
43 " " -> YangModuleInfoScanner : Bundle registered
44 activate YangModuleInfoScanner
46 YangModuleInfoScanner -> YangModuleInfoScanner: Load the services \nfrom the bundle \nthat was recently tracked.
48 YangModuleInfoScanner -> YangModuleInfoScanner: Collect YangModuleInfo-s \nfrom loaded services
50 YangModuleInfoScanner -> YangModuleInfoRegistry: Register collected ModuleInfos
51 activate YangModuleInfoRegistry
53 YangModuleInfoRegistry -> ModuleInfoSnapshotResolver: Register ModuleInfos
54 activate ModuleInfoSnapshotResolver
56 alt No previous Registration for the ModuleInfo => create a fresh Registration
57 ModuleInfoSnapshotResolver -> YangTextSchemaContextResolver : Register provided ModuleInfo
58 activate YangTextSchemaContextResolver
60 YangTextSchemaContextResolver --> ModuleInfoSnapshotResolver: Return fresh Registration
61 deactivate YangTextSchemaContextResolver
63 ModuleInfoSnapshotResolver -> YangModuleInfoRegistry: Return fresh Registration
64 else Registration for provided ModuleInfo exists
65 ModuleInfoSnapshotResolver -> YangModuleInfoRegistry : Return existing Registration
66 deactivate ModuleInfoSnapshotResolver
69 YangModuleInfoRegistry -> YangModuleInfoScanner: Return Registration
71 YangModuleInfoScanner -> YangModuleInfoRegistry : Scanner update
73 YangModuleInfoRegistry -> ModuleInfoSnapshotResolver : Take a snapshot
74 activate ModuleInfoSnapshotResolver
76 ModuleInfoSnapshotResolver -> YangTextSchemaContextResolver : Ask for new schema context
77 activate YangTextSchemaContextResolver
79 YangTextSchemaContextResolver -> YangTextSchemaContextResolver : Create EffectiveModelContext \nfrom registered sources
81 YangTextSchemaContextResolver -> ModuleInfoSnapshotResolver : Return created schema context
82 deactivate YangTextSchemaContextResolver
84 ModuleInfoSnapshotResolver -> YangModuleInfoRegistry : Return a snapshot with the created schema context
85 deactivate ModuleInfoSnapshotResolver
87 YangModuleInfoRegistry -> YangModuleInfoRegistry : Save the snapshot
89 YangModuleInfoRegistry -> YangModuleInfoScanner : Done
90 deactivate YangModuleInfoRegistry
92 YangModuleInfoScanner -> " " : Return Registration
93 deactivate YangModuleInfoRegistry
96 deactivate YangModuleInfoRegistry
97 deactivate YangModuleInfoScanner
100 The diagram below shows all relevant components and their relations.
105 class "OSGiModuleRuntime" as runtime {
108 class "YangModuleInfoScanner" as bundleTracker {
109 Registration addingBundle()
110 void modifiedBundle()
113 class "YangModuleInfoRegistry" as registry {
114 Registration registerBundle()
116 void enableScannerAndUpdate()
117 void scannerShutdown()
119 class "ModuleInfoSnapshotResolver" as resolver {
120 List<Registration> registerModuelInfos()
121 ModuleInfoSnapshot takeSnapshot()
123 class "YangTextSchemaContextResolver" as textResolver {
124 YangTextSchemaSourceRegistration registerSource()
125 EffectiveModelContext getEffectiveModelContext()
128 runtime -- bundleTracker : initiates
129 runtime -- registry : initiates
132 resolver -- textResolver