Liferay DXP Startup Phases

Knowing Liferay’s startup phases helps you troubleshoot startup failures. By learning the phase triggered events, you can listen for phases and act on them. This article describes the startup phases and identifies how to implement actions for phase events.

Startup consists of these main phases:

  1. Portal Context Initialization Phase: focuses on low level tasks without a web context.

  2. Main Servlet Initialization Phase: focuses on the portlet container and the Liferay DXP web application’s UI features such as Struts, Themes, and more.

The Portal Context Initialization Phase sets the stage for the Main Servlet Initialization Phase.

Portal Context Initialization Phase

The Portal Context Initialization phase runs first with these tasks:

  1. Set up low level utilities such as logging and those in PortalUtil and InitUtil.

  2. OSGi framework is initialized.

  3. Spring Phase 1: INFRASTRUCTURE beans specified by the Spring context files listed in Portal property spring.infrastructure.configs are loaded.

  4. INFRASTRUCTURE beans are published as OSGi services.

  5. OSGi framework starts.

    1. Static bundles are installed and started.
    2. Dynamic bundles are started.
  6. OSGi framework starts the runtime.

  7. Spring Phase 2: MAIN

    1. Load Spring beans specified by the Spring context files listed in Portal property spring.configs.
    2. A ModuleServiceLifecycle event service with a service property module.service.lifecycle value spring.initialized (i.e., SPRING_INITIALIZED) registers.
  8. MAIN Spring beans are published as OSGi services.

Main Servlet Initialization Phase

Here’s the phase’s activity sequence:

  1. The ModuleServiceLifecycle event service is updated with the service property module.service.lifecycle value database.initialized (i.e., DATABASE_INITIALIZED).

  2. The Global Startup event fires.

  3. For each portal instance, the Application Startup events fire.

  4. The ModuleServiceLifecycle event service is updated with the service property module.service.lifecycle value portal.initialized (i.e., PORTAL_INITIALIZED).

Now that you’re acquainted with the startup phases, you can concentrate on the events they fire.

Acting on Events

The ways to act on events depends on the event type. These subsections describe the event types.

ModuleServiceLifecycle Events

You can wait for and act on ModuleServiceLifecycle event services.

Portal Startup Events

In your liferay-portal-ext.properties file, you can override the following properties and add your own LifecycleAction classes to the list of action classes to invoke on the events.

Global Startup Event runs once when Liferay DXP initializes. The global.startup.events property defines the event’s default actions.

Application Startup Events runs once for each Site instance Liferay DXP initializes. The application.startup.events property defines the event’s default actions.

Waiting on Lifecycle Events

OSGi Services and Dependency Injection with Declarative Services

« Introduction to Back-EndThird Party Packages Portal Exports »
この記事は役に立ちましたか?
1人中1人がこの記事が役に立ったと言っています