简体   繁体   English

如何获取Liferay 6中Portlet的部署和加载过程的时间戳?

[英]How can I get the timestamp of deploying and loading process of a portlet in liferay 6?

My scenario is the next one, I want to get the current state of the portlets availables in the liferay portal, but the main idea is to generate a chart or some graphic resource and fill it with the information of the exact timestamp when the portlet started to being deployed and the timestamp when the portlet is fully loaded into the portal, right now I don't know how can I get these timestamps, I tried to read it from the catalina.out but for my project leader is not correct to do that. 我的场景是下一个场景,我想获取liferay门户中可用portlet的当前状态,但是主要思想是生成一个图表或一些图形资源,并在portlet启动时用确切的时间戳信息进行填充。 Portlet完全加载到门户时的部署和时间戳,现在我不知道如何获取这些时间戳,我试图从catalina.out中读取它,但是对于我的项目负责人而言,这样做是不正确的那。 thank you in advanced 谢谢高级

You have two options, create a HotDeployListener or listen to messagebus HOT_DEPLOY messages 您有两个选择,创建HotDeployListener或侦听messagebus HOT_DEPLOY消息

Option 1: HotDeployListener 选项1:HotDeployListener

When a portlet or any other plugin is deployed, Liferay executes a list of HotDeployListener listeners that are defined in hot.deploy.listeners property of portal.properties 部署Portlet或任何其他插件时,Liferay将执行portal.properties的hot.deploy.listeners属性中定义的HotDeployListener侦听器列表。

See default value in Hot Deploy section of portal.properties 请参阅portal.properties的“热部署”部分中的缺省值

The hot deploy listener receives a HotDeployEvent object that contains information about portlet is being deployed, for example servletcontext can be retrieved 热部署侦听器接收到HotDeployEvent对象,该对象包含有关正在部署的Portlet的信息, 例如可以检索servletcontext。

You have to implement your own HotDeployListener , see javadoc documentation and add it your portal-ext.properties. 您必须实现自己的HotDeployListener请参阅javadoc文档并将其添加到portal-ext.properties中。

You have to copy the default value of hot.deploy.listeners property to your portal-ext.properties and add to that list yours listener. 您必须将hot.deploy.listeners属性的默认值复制到portal-ext.properties并将其添加到该列表中。

For more information see documentation in portal.properties file: 有关更多信息,请参阅portal.properties文件中的文档:

Input a list of comma delimited class names that implement com.liferay.portal.kernel.deploy.hot.HotDeployListener. 输入以逗号分隔的类名称的列表,这些名称实现com.liferay.portal.kernel.deploy.hot.HotDeployListener。 These classes are used to process the deployment and undeployment of WARs at runtime. 这些类用于在运行时处理WAR的部署和取消部署。

The listeners are invoked in the order defined by this property. 侦听器按此属性定义的顺序调用。 PluginPackageHotDeployListener must always be invoked first. 必须始终首先调用PluginPackageHotDeployListener。 SpringHotDeployListener must always be invoked before ServletContextListenerHotDeployListener. 必须始终在ServletContextListenerHotDeployListener之前调用SpringHotDeployListener。 MessagingHotDeployListener must always be invoked last. 必须始终在最后调用MessagingHotDeployListener。

Option 2: listen to messagebus HOT_DEPLOY messages 选项2:收听messagebus HOT_DEPLOY消息

After portlet is deployed, a HOT_DEPLOY message is sent to Liferay message bus by the MessagingHotDeployListener, see: portal-impl/src/com/liferay/portal/deploy/hot/MessagingHotDeployListener.java#L70-L75 部署Portlet之后,MessagingHotDeployListener将HOT_DEPLOY消息发送到Liferay消息总线,请参阅: portal-impl / src / com / liferay / portal / deploy / hot / MessagingHotDeployListener.java#L70-L75

You can listen to that event creating a listener and call to MessageBusUtil.registerMessageListener(DestinationNames.HOT_DEPLOY, myListener) or MessageBusUtil.registerMessageListener("liferay/hot_deploy", myListener) . 您可以侦听该事件并创建一个侦听器,然后调用MessageBusUtil.registerMessageListener(DestinationNames.HOT_DEPLOY, myListener)MessageBusUtil.registerMessageListener("liferay/hot_deploy", myListener)

The listener must implement MessageListener interface, see javadoc documentation 侦听器必须实现MessageListener接口, 请参阅javadoc文档

For more information about Liferay messagebus see following links: 有关Liferay messagebus的更多信息,请参见以下链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM