How to make application start up action hook in liferay DXP?

thumbnail
Abhishek Jain, modified 7 Years ago. Regular Member Posts: 226 Join Date: 8/20/16 Recent Posts

I want to ask - How to make application start up action hook in liferay DXP? Please help..

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

Actually it is easier than that...

Just create an @Component class. Inside of the class, add the following:

@Reference(target = ModuleServiceLifecycle.PORTAL_INITIALIZED, unbind = "-")
protected void setModuleServiceLifecycle(ModuleServiceLifecycle moduleServiceLifecycle) { }

Then build out your logic in an @Activate method. This method will only be invoked once the module has started, the module will only start after all references have been satisfied, and the PORTAL_INITIALIZED instance is only available to satisfy after the portal startup is complete.