在会话超时时设置Liferay

在会话超时时设置Liferay

本文介绍了在会话超时时设置Liferay Hook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个Java中的Hook,如果Liferay 5.2.3 Portal的会话超时则会执行。

I want to write a Hook in Java that is executed if the session of my Liferay 5.2.3 Portal times out.

我设法编写一个Hook,只要用户点击logout链接,就会执行Hook,并在 liferay-hook.xml中使用以下设置

I managed to write a Hook that is executed whenever the user clicks the logout link with the following setup in the liferay-hook.xml:

<hook>
    <event>
        <event-class>com.extensions.hooks.LogoutHook</event-class>
        <event-type>logout.events.pre</event-type>
    </event>
</hook>

然而,如果会话超时,则不会调用Logout Hook,但我需要执行相同的操作超时的方法。我没有找到会话超时的事件类型。

However the Logout Hook does not get called if the session times out, but I need to execute the same method on a timeout. I did not find an event-type for a session timeout.

当会话超时并且识别用户ID时,是否有办法执行Java方法结束会话?

Is there a way to execute a Java-Method when the session times out and identify the User-ID of the ended session?

推荐答案

有一个事件将在会话到期/ TimeOut 事件时触发用户会话,

There is an event which will be triggered upon Session Expiry/TimeOut event of User Session,

# Servlet session destroy event
servlet.session.destroy.events = com.extensions.hooks.CustomPreSessionExpireAction

您可以在添加该属性的liferay-hook.xml portal.properties [写在钩子中]或 portal-ext.properties

You can either add this property in liferay-hook.xml or portal.properties [Written in Hook] or portal-ext.properties.

和可以用作,

public class CustomPreSessionExpireAction extends SessionAction {

    @Override
    public void run(HttpSession session) throws ActionException {
        //Code
    }
}

但是,我们可以这里只使用 HttpSession 。所以,你需要找出在这里获得 userId 的方法。

However, We can only use HttpSession here. So, you need to figure out the way to get userId here.

谢谢

这篇关于在会话超时时设置Liferay Hook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 21:50