Overriding Liferay Startup Events

2019-04-10 04:25发布

问题:

I have a question with respect to Liferay Startup Events.

In Liferay documentation it is given:

Startup Events

Input a list of comma delimited class names that extend com.liferay.portal.struts.SimpleAction. These classes will run at the specified event.

Could anybody please tell me what is the difference between global.startup.events and application.startup.events and could any body tell me in what case do we need to override them?

And should both these start up events extend com.liferay.portal.struts.SimpleAction?? and I couldn't find anything inside the SimpleAction except this:

public abstract class SimpleAction {

    public abstract void run(String[] ids) throws ActionException;

    }
}

I also wanted to know this class contains nothing, how does Liferay knows what XML files to read and process?

Thanks

回答1:

global.startup.events - run once for global server

application.startup.events - run for every portal instance at startup. If you have one portal instance at your server (normal case) - here is no difference between this properties. I use application.startup.events.

Extend the com.liferay.portal.kernel.events.SimpleAction class and impliment run-methode, that will call by liferay startup. For this purpose create a hook plugin and register in liferay-hook.xml the property file, e.g.:

<hook>
    <portal-properties>portal-myext.properties</portal-properties>
</hook>

Create portal-myext.properties in classpath and set your startup action:

application.startup.events=com.my.actions.MyStartupAction

The action MyStartupAction must be in the same classpath, hence same hook-plugin.