Linked models provide a mechanism for the WebApp developer to reuse and share model functionality among other WebApps.
By linking a model, you expose to the model requesting the linking the linked-in model's public functionality, such as methods or pages.
To add a linked model, you use the Linked Model builder to specify which model to link in. The Linked Model builder adds a named slot into your model, which contains information about the model being linked in. The example below shows model A
linking in model B
as the local linked model reference name.
does not get instantiated until it is actually called.
The name of the builder is used as the prefix name that must be used to access the linked model functionality. For example, if you added a linked model where you have specified LM1
as the builder name, you refer to a page in that model by using the Linked Model builder name, a period (.
) separator, and the page name.
You also use a similar format for calling methods on the linked model.
String value = webAppAccess.callMethod("LM1.doWork");
When models are linked in, you can create a single instance of the model that is shared within a session or specify that the linked model is not shared within the session. If the linked model is not shared, multiple instances of the model are created if it is used by more than one Linked Model builder.
Linked models: non-session singleton
When a linked model is specified to be Non-Session Singleton, multiple instances of this model are created for a given requester session.
Linked models: session singleton
When a linked model is specified to be Session Singleton, only one instance of this model is created for a given session.
WebAppAccess of a linked model
A WebAppAccess of a linked model can be used to set or change the instantiated model that is associated with a linked model slot.
Freeing linked models
In some cases you may want to free the reference to a linked model so that the JVM garbage collection will reclaim the memory used by the linked model.
Parent topic: WebAppAccess