Custom startup actions

It is often necessary to define a startup action. For example to verify whether the portal is correctly configured. The following portal properties offer the chance to define custom startup actions which will be executed during portal startup and each deployment of your startup action.

global.startup.events
application.startup.events
Using global.startup.events you can define a action running once while actions defined using application.startup.events run for every portal instance. Since global.startup.events describes an event, intercepting Liferay statup, you will need to define your class in an ext-plugin. Whereas application.startup.events can be defined in a hook-plugin. Your custom startup action has to extend com.liferay.portal.kernel.events.SimpleAction and override a run-method. Example: In portal.properties:
application.startup.events=de.blogspot.blog.liferay.StartupEvent
The appropriate startup class:
package de.blogspot.blog.liferay;

import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.events.SimpleAction;

public class StartupEvent extends SimpleAction{
    @Override
    public void run(String[] ids) throws ActionException {
     System.out.println("Liferay-Blog.blogspot.de");
    }
}

Leave a Reply