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.dms.sys.web.app.ContextListener.java

/**
 * Session destroyed listener.// w  w w.ja va  2 s  .  c o  m
 *
 * @param event the event
 */
public void sessionDestroyed(HttpSessionEvent event) {
    if (logger.isDebugEnabled())
        logger.debug("HTTP session destroyed: " + event.getSession().getId());
}

From source file:com.bluexml.xforms.controller.navigation.NavigationSessionListener.java

public void sessionCreated(HttpSessionEvent httpsessionevent) {
    sessions.put(httpsessionevent.getSession().getId(), httpsessionevent.getSession());
}

From source file:org.apache.openejb.arquillian.tests.listenerenventry.PojoServletSessionListener.java

public void sessionCreated(HttpSessionEvent event) {
    final String name = "OpenEJB";
    final HttpSession context = event.getSession();

    if (car != null) {
        context.setAttribute(ContextAttributeName.KEY_Car.name(), car.drive(name));
    }//from  w w  w .  j av  a  2 s  .  c om
    if (localCompany != null) {
        context.setAttribute(ContextAttributeName.KEY_LocalEjb.name(), "Local: " + localCompany.employ(name));
    }
    if (market != null) {
        context.setAttribute(ContextAttributeName.KEY_Market.name(), market.shop(name));
    }
    if (connectionPool != null) {
        context.setAttribute(ContextAttributeName.KEY_ConnPool.name(), "Connection Pool: " + connectionPool);
    }
    if (startCount != null) {
        context.setAttribute(ContextAttributeName.KEY_StartCount.name(),
                "Start Expressions.Count: " + startCount);
    }
    if (initSize != null) {
        context.setAttribute(ContextAttributeName.KEY_InitSize.name(), "Init Size: " + initSize);
    }
    if (totalQuantity != null) {
        context.setAttribute(ContextAttributeName.KEY_TotalQuantity.name(), "Total Quantity: " + totalQuantity);
    }
    if (enableEmail != null) {
        context.setAttribute(ContextAttributeName.KEY_EnableEmail.name(), "Enable Email: " + enableEmail);
    }
    if (optionDefault != null) {
        context.setAttribute(ContextAttributeName.KEY_DefaultOption.name(), "Option Default: " + optionDefault);
    }
    if (StringUtils.isNotEmpty(returnEmail) && returnEmail.equals("tomee@apache.org")) {
        context.setAttribute(ContextAttributeName.KEY_ReturnEmail.name(), returnEmail);
    }
    if (auditWriter != null) {
        context.setAttribute(ContextAttributeName.KEY_AuditWriter.name(), auditWriter.getClass().getName());
    }
    if (defaultCode != null) {
        context.setAttribute(ContextAttributeName.KEY_DefaultCode.name(), "DefaultCode: " + defaultCode);
    }
}

From source file:com.nec.harvest.servlet.listener.HarvestSessionListener.java

/**
 * This method is called , when a new session is created
 *///from  www.  ja va 2  s.  co  m
@Override
public void sessionCreated(HttpSessionEvent event) {
    activeSessions++;

    // ???????
    logger.info("A HttpSession [{}] is going to be created", event.getSession().getId());
}

From source file:com.sun.socialsite.web.listeners.SessionListener.java

public void sessionDestroyed(HttpSessionEvent se) {

    log.debug(String.format("sessionDestroyed(%s)", se.getSession().getId()));
    activeSessions.remove(se.getSession().getId());

    for (Object listener : getListeners(se.getSession())) {
        if (listener instanceof HttpSessionListener) {
            ((HttpSessionListener) listener).sessionDestroyed(se);
        }// www .jav  a 2  s .  c  o m
    }

}

From source file:com.sun.socialsite.web.listeners.SessionListener.java

public void sessionCreated(HttpSessionEvent se) {

    log.debug(String.format("sessionCreated(%s)", se.getSession().getId()));
    activeSessions.put(se.getSession().getId(), se.getSession());

    if (sessionTimeout != null) {
        se.getSession().setMaxInactiveInterval(sessionTimeout);
    }/*from   w  ww . jav a 2s .c  o  m*/

    for (Object listener : getListeners(se.getSession())) {
        if (listener instanceof HttpSessionListener) {
            ((HttpSessionListener) listener).sessionCreated(se);
        }
    }

}

From source file:com.sun.socialsite.web.listeners.SessionListener.java

public void sessionDidActivate(HttpSessionEvent se) {

    log.debug(String.format("sessionDidActivate(%s)", se.getSession().getId()));
    activeSessions.put(se.getSession().getId(), se.getSession());

    for (Object listener : getListeners(se.getSession())) {
        if (listener instanceof HttpSessionActivationListener) {
            ((HttpSessionActivationListener) listener).sessionDidActivate(se);
        }/* w  ww .  ja v  a2 s.co  m*/
    }

}

From source file:com.sun.socialsite.web.listeners.SessionListener.java

public void sessionWillPassivate(HttpSessionEvent se) {

    log.debug(String.format("sessionWillPassivate(%s)", se.getSession().getId()));
    activeSessions.remove(se.getSession().getId());

    for (Object listener : getListeners(se.getSession())) {
        if (listener instanceof HttpSessionActivationListener) {
            ((HttpSessionActivationListener) listener).sessionWillPassivate(se);
        }/*from   w  ww .  j a va2s.  com*/
    }

}

From source file:com.bluexml.xforms.controller.navigation.NavigationSessionListener.java

public void sessionDestroyed(HttpSessionEvent httpsessionevent) {
    String sessionId = httpsessionevent.getSession().getId();
    navigations.remove(sessionId);//from  w  ww . jav a 2 s.c  o m
    sessions.remove(sessionId);
    servletURLs.remove(sessionId);
}

From source file:org.kuali.coeus.sys.framework.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  . ja va2 s.  c om
protected void logSessionEnd(HttpSessionEvent event) {
    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);
}