Liferay:在-LocalServiceUtil可用时执行操作 [英] Liferay: perform an action when a -LocalServiceUtil is available
问题描述
我已经使用服务生成器实现了功能性的Liferay服务,我想尽快调用-LocalServiceUtil
类上的方法.我希望在启动服务以及重新部署服务时执行此任务.
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.
即使-LocalServiceUtil
类上的所有方法都是静态的,但如果调用的时间过早,它们也会抛出BeanLocatorException
.
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:尚未为servlet上下文portal-navigation-impl设置BeanLocator
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set for servlet context portal-navigation-impl
是否有任何方法可以在-LocalServiceImpl
实例上调用方法,否则我可以做到这一点?
Is there any way to call a method on the -LocalServiceImpl
instance or otherwise so that I can do this?
谢谢
推荐答案
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.
否则,请创建一个依赖于当前使用的钩子.该操作也将重新启动,但仅在提供* -LocalService的挂钩已启动后才能运行. (在liferay-plugin-package.properties
中用键required-deployment-context
声明依赖关系-这是从内存中获取的-如果我错了,有人可以纠正我的意思.)
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.)
这篇关于Liferay:在-LocalServiceUtil可用时执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!