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.apache.roller.weblogger.ui.core.RollerSession.java

/** Create session's Roller instance */
public void sessionCreated(HttpSessionEvent se) {
    RollerSession rollerSession = new RollerSession();
    se.getSession().setAttribute(ROLLER_SESSION, rollerSession);
}

From source file:net.big_oh.common.web.listener.session.SimpleSessionTrackingListener.java

public void sessionCreated(HttpSessionEvent se) {
    Map<HttpSession, Object> sessions = getSessionsCollectionForServletContext(
            se.getSession().getServletContext());

    sessions.put(se.getSession(), getObjectToAssociateWithSession(se.getSession()));

    logger.info("Registered the creation of a new HttpSession: " + se.getSession().getId());
}

From source file:net.big_oh.common.web.listener.session.SimpleSessionTrackingListener.java

public void sessionDestroyed(HttpSessionEvent se) {
    Map<HttpSession, Object> sessions = getSessionsCollectionForServletContext(
            se.getSession().getServletContext());

    sessions.remove(se.getSession());/* w ww  .j  a  va  2 s .  com*/

    logger.info("Registered the destruction of an HttpSession: " + se.getSession().getId());
}

From source file:de.appsolve.padelcampus.listener.SessionEventListener.java

@Override
public void sessionDestroyed(HttpSessionEvent se) {
    if (activeSessions > 0) {
        activeSessions--;//ww w. j  a v a  2 s . c  o m
    }
    initDependencies(se.getSession().getServletContext());
    LocalDateTime now = new LocalDateTime();
    Booking booking = sessionUtil.getBooking(se.getSession());
    if (booking != null) {
        if (booking.getId() != null) {
            //get latest booking from DB
            booking = bookingBaseDAO.findById(booking.getId());
        }
        cancelBooking(booking, now);
    }

    //also look for other blocking bookings that might no have been deleted
    LocalDateTime maxAge = now.minusSeconds(se.getSession().getMaxInactiveInterval());
    List<Booking> findBlockedBookings = bookingBaseDAO.findUnpaidBlockingBookings();
    for (Booking blockingBooking : findBlockedBookings) {
        cancelBooking(blockingBooking, maxAge);
    }
}

From source file:org.hdiv.listener.InitWebSphereListener.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.
 * //w w w. j av  a 2 s.c  om
 * @see javax.servlet.http.HttpSessionListener#void
 *      (javax.servlet.http.HttpSessionEvent)
 */
public void sessionCreated(HttpSessionEvent arg0) {

    ServletContext servletContext = arg0.getSession().getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

    this.initStrategies(wac, arg0);
    this.initCache(wac, arg0);
    this.initHDIVState(wac, arg0);

    //      HDIVUtil.setHttpSession(arg0.getSession());   

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

}

From source file:org.spirit.spring.BotListUserSessionListener.java

public void sessionCreated(HttpSessionEvent event) {
    final BotListCoreSettings coreSettings = getCoreSettings(event);
    if (coreSettings != null) {
        coreSettings.incActiveSessions();
        coreSettings.incLoggedInUsers(event.getSession());
    }//from w  ww  .jav a2 s  .c  o  m
}

From source file:org.spirit.spring.BotListUserSessionListener.java

public void sessionDestroyed(HttpSessionEvent event) {
    final BotListCoreSettings coreSettings = getCoreSettings(event);
    if (coreSettings != null) {
        coreSettings.decActiveSessions();
        coreSettings.decLoggedInUsers(event.getSession());
    }/*from  ww w. j  a  va  2  s. co m*/
}

From source file:it.scoppelletti.programmerpower.web.security.SingleSignOutSessionListener.java

/**
 * Termine di una sessione./*from  w w  w . java2  s  .  c o  m*/
 * 
 * @param event Evento.
 */
public void sessionDestroyed(HttpSessionEvent event) {
    if (mySessionStorage == null) {
        throw new PropertyNotSetException(toString(), "sessionMappingStorage");
    }

    try {
        mySessionStorage.removeBySessionById(event.getSession().getId());
    } catch (Exception ex) {
        // NOP
    }
}

From source file:nl.strohalm.cyclos.http.LifecycleListener.java

/**
 * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
 *///from   w w  w . j a v a2  s  .  c o m
@Override
public void sessionDestroyed(final HttpSessionEvent event) {
    final HttpSession session = event.getSession();
    final String sessionId = session == null ? null : session.getId();
    if (sessionId == null) {
        return;
    }

    // If there is an active transaction, use an transaction end listener to actually logout
    if (transactionHelper.hasActiveTransaction()) {
        CurrentTransactionData.addTransactionEndListener(new TransactionEndListener() {
            @Override
            protected void onTransactionEnd(final boolean commit) {
                doLogout(sessionId);
            }
        });
    } else {
        // Logout directly (this is in another TX)
        doLogout(sessionId);
    }
}

From source file:org.kuali.kra.web.listener.SessionLoggingListener.java

/**
 * Implementation for logging the end of an {@link HttpSession}. Override this if you want different logging at the end of the session.
 *
 * @param event the {@link HttpSessionEvent}
 *//*from w  w w  .  j a  va 2s  . c o m*/
protected void logSessionEnd(HttpSessionEvent event) {
    long startMem = Runtime.getRuntime().freeMemory();
    long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
    long originalMemory = (Long) event.getSession().getAttribute("startingMemory");

    String difference = "";
    if (originalMemory < usedMemory) {
        difference = "Memory usage increased by " + (usedMemory - originalMemory);
    } else {
        difference = "Memory usage decreased by " + (originalMemory - usedMemory);
    }

    LOG.info("Session was just destroyed : " + usedMemory + " memory used. Originally created with "
            + originalMemory + " memory used. " + difference);
}