Liferay: perform an action when a -LocalServiceUtil is available

廉价感情. 提交于 2019-12-23 05:47:12

问题


I have implemented a functional Liferay service using service builder and I want to call a method on the -LocalServiceUtil class just as soon as I possibly can. This is a task I wish to perform when the service starts and also when the service is redeployed.

Even though all the methods on the -LocalServiceUtil class are static, they will throw a BeanLocatorException if they are called too soon.

com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set for servlet context portal-navigation-impl

Is there any way to call a method on the -LocalServiceImpl instance or otherwise so that I can do this?

Thank you


回答1:


As you speak about the initialization order: I'm not 100% sure about this, but I'd write a startup action. This gets run everytime a hook (or plugin) starts up - including a redeploy. Sounds like what you want - and if the initialization order works, this is your solution.

Otherwise: Create a separate hook that's dependent on the one that you're currently using. That will be restarted as well, but only run once the hook providing the *-LocalService did already start up. (dependency is declared in liferay-plugin-package.properties, with the key required-deployment-context - this is from memory - somebody correct me if I'm wrong.)



来源:https://stackoverflow.com/questions/34684810/liferay-perform-an-action-when-a-localserviceutil-is-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!