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.kuali.coeus.sys.framework.listener.SessionLoggingListener.java

/**
 * Implementation for logging the start of an {@link HttpSession}. Override this if you want different logging at the start of the session.
 *
 * @param event the {@link HttpSessionEvent}
 *///from w  ww  . j  a v a2s  .co m
protected void logSessionStart(HttpSessionEvent event) {
    long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
    event.getSession().setAttribute("startingMemory", usedMemory);
    LOG.info("Session was just created : " + usedMemory + " memory used");
}

From source file:org.beanfuse.security.monitor.OnlineUserListener.java

/**
 * session? ?session//  ww w  . ja  v  a 2s .  c o  m
 */
public void sessionDestroyed(HttpSessionEvent event) {
    if (null == monitor) {
        WebApplicationContext wac = WebApplicationContextUtils
                .getRequiredWebApplicationContext(event.getSession().getServletContext());
        monitor = (SecurityMonitor) wac.getBean("securityMonitor", SecurityMonitor.class);
    }
    monitor.logout(event.getSession());
}

From source file:org.apache.roller.weblogger.ui.core.RollerSession.java

private void clearSession(HttpSessionEvent se) {
    HttpSession session = se.getSession();
    try {/*  ww w  .j ava2  s .  c  o  m*/
        session.removeAttribute(ROLLER_SESSION);
    } catch (Throwable e) {
        if (log.isDebugEnabled()) {
            // ignore purge exceptions
            log.debug("EXCEPTION PURGING session attributes", e);
        }
    }
}

From source file:org.musicrecital.webapp.listener.UserCounterListener.java

public void sessionDestroyed(HttpSessionEvent se) {
    Object obj = se.getSession().getAttribute(EVENT_KEY);
    if (obj != null) {
        se.getSession().removeAttribute(EVENT_KEY);
    }/*w  w  w  .  j a  v a  2 s .  co  m*/
}

From source file:org.jasig.cas.client.session.SingleSignOutHttpSessionListener.java

public void sessionDestroyed(final HttpSessionEvent event) {
    if (SESSION_MAPPING_STORAGE == null) {
        SESSION_MAPPING_STORAGE = getSessionMappingStorage();
    }//from  ww w.  j  a  v  a  2s .  c om
    final HttpSession session = event.getSession();

    SESSION_MAPPING_STORAGE.removeBySessionById(session.getId());
}

From source file:org.jaggeryjs.jaggery.core.listeners.WebAppSessionListener.java

@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
    ServletContext ctx = httpSessionEvent.getSession().getServletContext();

    List<Object> jsListeners = (List<Object>) ctx.getAttribute(JaggeryCoreConstants.JS_CREATED_LISTENERS);
    if (jsListeners == null) {
        return;/* w w  w. j  av a 2  s .  c om*/
    }

    JaggeryContext shared = WebAppManager.sharedJaggeryContext(ctx);
    Context cx = shared.getEngine().enterContext();
    JaggeryContext context = CommonManager.getJaggeryContext();
    if (CommonManager.getJaggeryContext() == null) {
        context = WebAppManager.clonedJaggeryContext(ctx);
        CommonManager.setJaggeryContext(context);
    }
    RhinoEngine engine = context.getEngine();
    ScriptableObject clonedScope = context.getScope();

    JavaScriptProperty session = new JavaScriptProperty("session");
    session.setValue(cx.newObject(clonedScope, "Session", new Object[] { httpSessionEvent.getSession() }));
    session.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(clonedScope, session);

    for (Object jsListener : jsListeners) {
        CommonManager.getCallstack(context).push((String) jsListener);
        try {
            ScriptReader sr = new ScriptReader(ctx.getResourceAsStream((String) jsListener)) {
                @Override
                protected void build() throws IOException {
                    try {
                        sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                    } catch (ScriptException e) {
                        throw new IOException(e);
                    }
                }
            };
            engine.exec(sr, clonedScope, null);
        } catch (ScriptException e) {
            log.error(e.getMessage(), e);
        } finally {
            CommonManager.getCallstack(context).pop();
        }
    }
    Context.exit();
}

From source file:org.jaggeryjs.jaggery.core.listeners.WebAppSessionListener.java

@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
    ServletContext ctx = httpSessionEvent.getSession().getServletContext();

    List<Object> jsListeners = (List<Object>) ctx.getAttribute(JaggeryCoreConstants.JS_DESTROYED_LISTENERS);
    if (jsListeners == null) {
        return;//from   ww  w  .ja v a 2  s.  co  m
    }

    JaggeryContext shared = WebAppManager.sharedJaggeryContext(ctx);
    Context cx = shared.getEngine().enterContext();
    JaggeryContext context = CommonManager.getJaggeryContext();
    if (CommonManager.getJaggeryContext() == null) {
        context = WebAppManager.clonedJaggeryContext(ctx);
        CommonManager.setJaggeryContext(context);
    }
    RhinoEngine engine = context.getEngine();
    ScriptableObject clonedScope = context.getScope();

    JavaScriptProperty session = new JavaScriptProperty("session");
    session.setValue(cx.newObject(clonedScope, "Session", new Object[] { httpSessionEvent.getSession() }));
    session.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(clonedScope, session);

    for (Object jsListener : jsListeners) {
        CommonManager.getCallstack(context).push((String) jsListener);
        try {
            ScriptReader sr = new ScriptReader(ctx.getResourceAsStream((String) jsListener)) {
                @Override
                protected void build() throws IOException {
                    try {
                        sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                    } catch (ScriptException e) {
                        throw new IOException(e);
                    }
                }
            };
            engine.exec(sr, clonedScope, null);
        } catch (ScriptException e) {
            log.error(e.getMessage(), e);
        } finally {
            CommonManager.getCallstack(context).pop();
        }
    }
    Context.exit();
}

From source file:org.netxilia.server.service.user.SessionListener.java

@Override
public void sessionDestroyed(HttpSessionEvent sessionEvent) {
    if (windowProcessor == null) {
        // not thread-safe but the same object is returned each time
        ServletContext servletContext = sessionEvent.getSession().getServletContext();
        ApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
        windowProcessor = springContext.getBean(IWindowProcessor.class);
    }//from w ww .  j av a 2 s  . c o  m
    windowProcessor.terminateSession(sessionEvent.getSession().getId());
}

From source file:org.dms.sys.web.app.ContextListener.java

/**
 * Session created listener./*from   w w  w .j a va  2  s. c om*/
 *
 * @param event the event
 */
public void sessionCreated(HttpSessionEvent event) {
    if (logger.isDebugEnabled())
        logger.debug("HTTP session created: " + event.getSession().getId());
}

From source file:jp.terasoluna.fw.web.HttpSessionListenerImpl.java

/**
 * <p>HTTPZbVCxg???B</p>//  w  w w. j a  v  a2s.c o  m
 * <p>
 *  ZbVRtfBNg
 *  ??A???B
 * </p>
 *
 * @param event ZbVCxg
 */
public void sessionDestroyed(HttpSessionEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("session destroyed.");
    }

    HttpSession session = event.getSession();
    File dir = FileUtil.getSessionDirectory(session.getId());
    if (dir.exists() && dir.isDirectory()) {
        if (FileUtil.removeSessionDirectory(session.getId())) {
            log.debug("\"" + dir.getPath() + "\" removed.");
        } else {
            log.error("can't remove \"" + dir.getPath() + "\".");
        }
    }
}