Example usage for com.liferay.portal.kernel.util PropsKeys SERVLET_SESSION_DESTROY_EVENTS

List of usage examples for com.liferay.portal.kernel.util PropsKeys SERVLET_SESSION_DESTROY_EVENTS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys SERVLET_SESSION_DESTROY_EVENTS.

Prototype

String SERVLET_SESSION_DESTROY_EVENTS

To view the source code for com.liferay.portal.kernel.util PropsKeys SERVLET_SESSION_DESTROY_EVENTS.

Click Source Link

Usage

From source file:com.vportal.portal.servlet.PortalSessionListener.java

License:Open Source License

public void sessionDestroyed(HttpSessionEvent event) {
    /*if (PropsValues.SESSION_DISABLED) {
    return;/*from   ww w  . j a v a 2  s . c  o  m*/
    }*/
    //hoan
    if (GetterUtil.getBoolean(PropsUtil.get("SESSION_DISABLED"))) {
        return;
    }
    //hoan

    HttpSession ses = event.getSession();

    MethodKey method = new MethodKey("com.liferay.portal.kernel.util.Validator.PortalSessionContext", "remove",
            String.class);
    Object[] args = new Object[] { ses.getId() };
    try {
        PortalClassInvoker.invoke(false, method, args);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    //PortalSessionContext.remove(ses.getId());

    try {
        Long userIdObj = (Long) ses.getAttribute(WebKeys.USER_ID);

        if (userIdObj == null) {
            _log.warn("User id is not in the session");
        } else {
            long userId = userIdObj.longValue();

            if (CompanyThreadLocal.getCompanyId() == 0) {
                setCompanyId(userId);
            }

            //MailSessionLock.cleanUp(ses);
            MethodKey methodSignOut = new MethodKey("com.liferay.portal.liveusers.LiveUsers", "signOut",
                    long.class, String.class, String.class);
            Object[] argsSignOut = new Object[] { CompanyThreadLocal.getCompanyId(), userId, ses.getId() };
            PortalClassInvoker.invoke(false, methodSignOut, argsSignOut);
            //LiveUsers.signOut(CompanyThreadLocal.getCompanyId(), userId, ses.getId());
        }

    } catch (IllegalStateException ise) {
        _log.warn("Please upgrade to a servlet 2.4 compliant container");
    } catch (Exception e) {
        _log.error(e, e);
    }
    //ses.removeAttribute(WebKeys.PORTLET_SESSION_TRACKER);
    //ses.removeAttribute(WebKeys.REVERSE_AJAX);

    //MessagingUtil.closeXMPPConnection(ses);

    // Process session destroyed events

    try {
        /*EventsProcessor.process(
        PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
        PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/
        //hoan
        MethodKey methodProcess = new MethodKey("com.liferay.portal.events.EventsProcessorUtil", "process",
                String.class, String.class, HttpSession.class);
        Object[] argsProcess = new Object[] { PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
                PropsUtil.getArray(PropsKeys.SERVLET_SESSION_DESTROY_EVENTS), ses };
        PortalClassInvoker.invoke(false, methodProcess, argsProcess);

        /*EventsProcessorUtil.process(
              PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
              PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/
        //hoan

    } catch (ActionException ae) {
        _log.error(ae, ae);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}