Initializer Framework

The initializer framework is part of the application startup layer of PIM Core with respect to both the application server and the rich client. An initializer basically represents logic for starting up a certain component, e.g. initializing an in-memory cache, so is executed at most once during a node's life-cycle. In order to provide a certain order the startup logic is executed in and to guarantee that certain components are already existent, each initializer is executed in the context of a so-called start level. For instance, the persistence layer's initializer must be executed before the HPM repository is loaded etc.

Extension Point

Initializers are contributed to extension point com.heiler.ppm.init.core.initializers, whereas the following information needs to be provided:

  • id - The unique identifier of the initializer.

  • class - The class implementing the Initializer interface, containing the actual startup logic.

  • start-level - The level it is to be executed in, given the following order and levels:

    • STD_BOOT: Marks the initial level for booting the PIM Core platform.

    • STD_READ_ONLY_00 - STD_READ_ONLY_90: Marks standard start up levels for initialization logic which only reads from the DB and does NOT alter data.

    • STD_READ_WRITE_00 - STD_READ_WRITE_90: Marks standard start up levels for initialization logic which can also write to the DB.

    • CUSTOM_00 - CUSTOM_40: Initializers for custom startup logic can use these levels.

    • STD_READY: Marks the initialization to be finished.

  • type - The type of the initializer, given the following modes:

    • SERVER (default): Initializer is executed every time a server is started. Applicable for components which have to be started and available on all server instances.

    • CLUSTER_SINGLETON: Initializer is executed only once for the entire server cluster. Applicable for components with static initialization logic which is only needed to be executed once in the network life cycle (both single and multi-server environment).

    • CLUSTER_SINGLETON_WITH_FAILOVER: Initializer is executed only once at a time, but is executed on a different server when the previous node failed and is not available anymore. Applicable for components which have a kind of "singleton service" character for the server cluster in a multi-server environment. Component's functionality must be taken over by another instance in case of failure.

  • nodeRole (optional) - Role which the server instance must have in order to execute the corresponding initializer. This can be set in order to confine initialization logic only on server instances with a dedicated role.

Note that custom initializers are only allowed to use the CUSTOM_XX start-levels! Otherwise the initialization order is going to be jeopardized and correct application startup cannot be guaranteed.

Disposers

When orderly shutting down a server instance, some components need to dispose the resources they occupied and might need to do additional cleanup logic. The right means for such tasks is inherently provided by the initializer framework as well. Contributed initializer classes can be extended with cleanup logic by implementing the Disposer interface. When doing so, the platform container keeps such instances in the correct order during startup and reversely executes the disposal logic when shutting down the server.