Example usage for javax.servlet.http HttpSessionEvent getSession

List of usage examples for javax.servlet.http HttpSessionEvent getSession

Introduction

In this page you can find the example usage for javax.servlet.http HttpSessionEvent getSession.

Prototype

public HttpSession getSession() 

Source Link

Document

Return the session that changed.

Usage

From source file:org.hdiv.listener.InitListener.java

/**
 * For each user session, a new cipher key is created if the cipher strategy has been chosen, and a new cache is
 * created to store the data to be validated.
 * /*from  www. j  av  a  2  s  .co  m*/
 * @see javax.servlet.http.HttpSessionListener#void (javax.servlet.http.HttpSessionEvent)
 */
public void sessionCreated(HttpSessionEvent httpSessionEvent) {

    ServletContext servletContext = httpSessionEvent.getSession().getServletContext();

    if (!this.servletContextInitialized) {
        this.initServletContext(servletContext);
    }

    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

    this.initStrategies(wac, httpSessionEvent.getSession());
    this.initCache(wac, httpSessionEvent.getSession());
    this.initPageIdGenerator(wac, httpSessionEvent.getSession());
    this.initHDIVStateParameters(wac, httpSessionEvent.getSession());

    if (log.isInfoEnabled()) {
        log.info("HDIV's session created:" + httpSessionEvent.getSession().getId());
    }

}

From source file:de.interseroh.report.webapp.SessionListener.java

@Override
public void sessionCreated(HttpSessionEvent event) {
    ApplicationContext applicationContext = getApplicationContext(event);
    Environment env = applicationContext.getEnvironment();

    String timeout = env.getProperty("session.timeout.interval");

    if (timeout == null || timeout.equals("")) {
        // Default seconds 21600 == 6 hours
        timeout = DEFAULT_TIMEOUT_INTERVAL;
    }//  ww  w . j a  va2  s. c  om

    event.getSession().setMaxInactiveInterval(Integer.parseInt(timeout));

    if (logger.isDebugEnabled()) {
        logger.debug("Session created, timeout: " + timeout);
    }
}

From source file:org.hdiv.listener.InitListener.java

/**
 * @see javax.servlet.http.HttpSessionListener#void (javax.servlet.http.HttpSessionEvent)
 *///from w  w  w  . ja  v  a 2 s . c o  m
public void sessionDestroyed(HttpSessionEvent event) {

    if (log.isInfoEnabled()) {
        log.info("HDIV's session destroyed:" + event.getSession().getId());
    }
}

From source file:de.zib.gndms.kit.monitor.GroovyMonitor.java

public synchronized void sessionWillPassivate(HttpSessionEvent event) {
    final HttpSession evSession = event.getSession();
    if (evSession != null) {
        evSession.removeAttribute(getToken());
    }/*from   w w w  . j  ava 2s . co  m*/
}

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

public void sessionCreated(HttpSessionEvent event) {

    /*if (PropsValues.SESSION_DISABLED) {
       return;/*from w  w w  . j av  a 2  s  . c  om*/
    }*/
    //hoan
    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.SESSION_DISABLED))) {
        return;
    }
    //hoan
    HttpSession ses = event.getSession();

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

    // Process session created events

    try {
        /*EventsProcessor.process(
        PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
        PropsValues.SERVLET_SESSION_CREATE_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_CREATE_EVENTS,
                PropsUtil.getArray("SERVLET_SESSION_CREATE_EVENTS"), ses };
        PortalClassInvoker.invoke(false, methodProcess, argsProcess);
        /*EventsProcessorUtil.process(
              PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
              PropsValues.SERVLET_SESSION_CREATE_EVENTS, ses);*/
        //hoan      
    } catch (ActionException ae) {
        _log.error(ae, ae);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.icesoft.faces.util.event.servlet.ContextEventRepeater.java

public void sessionCreated(final HttpSessionEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session Created event: " + event.getSession().getId());
    }/*from   w  w  w  . j  ava 2s.c  o m*/
}

From source file:com.icesoft.faces.util.event.servlet.ContextEventRepeater.java

/**
 * Fires a new <code>SessionDestroyedEvent</code>, based on the received
 * <code>event</code>, to all registered listeners. </p>
 *
 * @param event the HTTP session event.//from   w  w  w . j  a  v  a  2  s  . co  m
 */
public void sessionDestroyed(final HttpSessionEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session Destroyed event: " + event.getSession().getId());
    }
    // #3073 directly invoke method on SessionDispatcher for all sessions
    // (Not just wrapped ones)
    SessionDispatcherListener.sessionDestroyed(event);
    SessionDestroyedEvent sessionDestroyedEvent = new SessionDestroyedEvent(event);
    synchronized (LISTENERS) {
        Iterator _listeners = LISTENERS.keySet().iterator();
        while (_listeners.hasNext()) {
            ((ContextEventListener) _listeners.next()).sessionDestroyed(sessionDestroyedEvent);
        }
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace("ICEfaces ID: " + sessionDestroyedEvent.getICEfacesID());
    }
}

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

public void sessionDestroyed(HttpSessionEvent event) {
    /*if (PropsValues.SESSION_DISABLED) {
    return;//from  w w  w. j a  v a  2s .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();
    }
}

From source file:org.apache.drill.cv.exec.server.rest.CvDrillWebServer.java

/**
 * @return A {@link SessionHandler} which contains a {@link HashSessionManager}
 *//*from  ww  w .j a v a2s .  c om*/
private SessionHandler createSessionHandler(final SecurityHandler securityHandler) {
    SessionManager sessionManager = new HashSessionManager();
    sessionManager.setMaxInactiveInterval(config.getInt(ExecConstants.HTTP_SESSION_MAX_IDLE_SECS));
    sessionManager.addEventListener(new HttpSessionListener() {
        @Override
        public void sessionCreated(HttpSessionEvent se) {
            // No-op
        }

        @Override
        public void sessionDestroyed(HttpSessionEvent se) {
            final HttpSession session = se.getSession();
            if (session == null) {
                return;
            }

            final Object authCreds = session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
            if (authCreds != null) {
                final SessionAuthentication sessionAuth = (SessionAuthentication) authCreds;
                securityHandler.logout(sessionAuth);
                session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
            }
        }
    });

    return new SessionHandler(sessionManager);
}

From source file:org.hdiv.listener.InitWebSphereListener.java

/**
 * HDIV state parameter initialization./*from  w w w . j  a va 2 s . c om*/
 * @param wac web application context
 * @param httpSessionEvent http session event
 * @since HDIV 1.1
 */
private void initHDIVState(WebApplicationContext wac, HttpSessionEvent httpSessionEvent) {

    String hdivParameterName = null;

    Boolean isRandomName = (Boolean) wac.getBean("randomName");
    if (Boolean.TRUE.equals(isRandomName)) {
        hdivParameterName = HDIVUtil.createRandomToken(Integer.MAX_VALUE);
    } else {
        hdivParameterName = (String) wac.getBean("hdivParameter");
    }

    httpSessionEvent.getSession().setAttribute(Constants.HDIV_PARAMETER, hdivParameterName);
}