Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Out of four popular variants (Lazy Initialization, Virtual Proxy, Value Holder, Ghost) of the lazy loading design pattern, "Value Holder" and "Ghost" variants are adopted and used in the lazy loading implementation in WSO2 Carbon Framework.

Use of Value Holder

A value holder is an object, usually (but not necessarily) with a method by the name "getValue", which the clients invoke to obtain a reference to the real object corresponding to a parameter passed in the method. In WSO2 Application Server, the ValueHolder variant is used at the event of loading a tenant. The method call is as follow:

...

The "getTenantConfigurationContext" method is the equivalent of the "getValue" method in the ValueHolder variant. It takes a "tenantDomain" as a reference and returns the ConfigurationContext, if the tenant is already loaded. If the tenant domain doesn't have an Axis2 ConfigurationContext, the method will return a newly created one. Either way, when loading an entire AxisConfiguration, all artifacts belonging to that particular tenant are also loaded. A more efficient practice is to lazy load those artifacts by loading only when it is requested by the system or a tenant. It prevents processing overhead and unnecessary memory usage. This is where the Ghost variant of the lazy loading pattern is used.

Use of GhostDeployer and GhostDispatcher/GhostWebappDeployerValve

When the Application Server starts, you can see all the previously deployed services and Web Applications listed in its management console. However, these artifacts are only the Ghost instances, which maintain references to the actual Instances. GhostDeployer, which handles lazy loading of artifacts, holds a map of deployers for all artifact types.

...