Java 类javax.servlet.http.HttpSessionEvent 实例源码

项目:tomcat7    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:lazycat    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[]) se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor) req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger()
                        .warn(sm.getString("cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:lemon    文件:SessionEventHttpSessionListenerAdapter.java   
public void onApplicationEvent(AbstractSessionEvent event) {
    if (this.listeners.isEmpty()) {
        return;
    }

    HttpSessionEvent httpSessionEvent = createHttpSessionEvent(event);

    for (HttpSessionListener listener : this.listeners) {
        if (event instanceof SessionDestroyedEvent) {
            listener.sessionDestroyed(httpSessionEvent);
        }
        else if (event instanceof SessionCreatedEvent) {
            listener.sessionCreated(httpSessionEvent);
        }
    }
}
项目:dswork    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event)
{
    System.out.println("sessionDestroyed:::" + event.getSession().getId());
    try
    {
        HttpSession session = event.getSession();
        String ticket = String.valueOf(session.getAttribute(SessionListener.DS_SSO_TICKET));
        if(!ticket.equals("null") && ticket.length() > 0)
        {
            ((AuthFactoryService)dswork.spring.BeanFactory.getBean(AuthFactoryService.class)).saveLogLogout(ticket, true, false);
            TicketService.removeSession(ticket);// 应该是超时
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}
项目:lams    文件:CometConnectionManagerValve.java   
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                req.getEvent().close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:lams    文件:SessionListener.java   
/** HttpSessionListener interface */
   @Override
   public void sessionCreated(HttpSessionEvent sessionEvent) {
if (sessionEvent == null) {
    return;
}
HttpSession session = sessionEvent.getSession();
session.setMaxInactiveInterval(SessionListener.timeout);

//set server default locale for STURTS and JSTL. This value should be overwrite
//LocaleFilter class. But this part code can cope with login.jsp Locale.
if (session != null) {
    String defaults[] = LanguageUtil.getDefaultLangCountry();
    Locale preferredLocale = new Locale(defaults[0] == null ? "" : defaults[0],
        defaults[1] == null ? "" : defaults[1]);
    session.setAttribute(LocaleFilter.PREFERRED_LOCALE_KEY, preferredLocale);
    Config.set(session, Config.FMT_LOCALE, preferredLocale);
}
   }
项目:sgroup    文件:NewSessionListener.java   
@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
    String sessionId = httpSessionEvent.getSession().getId();
    System.out.println("当前销毁的sessionId = " + sessionId);
    ServletContext servletContext = httpSessionEvent.getSession().getServletContext();
    Object userCount = servletContext.getAttribute("userCount");
    if (userCount == null) {
        servletContext.setAttribute("userCount", 0);
    } else {
        servletContext.setAttribute("userCount", Integer.parseInt(userCount.toString()) - 1);
    }
}
项目:lazycat    文件:StandardSession.java   
/**
 * Inform the listeners about the new session.
 *
 */
public void tellNew() {

    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_CREATED_EVENT, null);

    // Notify interested application event listeners
    Context context = (Context) manager.getContainer();
    Object listeners[] = context.getApplicationLifecycleListeners();
    if (listeners != null) {
        HttpSessionEvent event = new HttpSessionEvent(getSession());
        for (int i = 0; i < listeners.length; i++) {
            if (!(listeners[i] instanceof HttpSessionListener))
                continue;
            HttpSessionListener listener = (HttpSessionListener) listeners[i];
            try {
                context.fireContainerEvent("beforeSessionCreated", listener);
                listener.sessionCreated(event);
                context.fireContainerEvent("afterSessionCreated", listener);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                try {
                    context.fireContainerEvent("afterSessionCreated", listener);
                } catch (Exception e) {
                    // Ignore
                }
                manager.getContainer().getLogger().error(sm.getString("standardSession.sessionEvent"), t);
            }
        }
    }

}
项目:automat    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    if (getAllUserNumber() > 0) {
        logger.info("销毁了一个Session连接:[" + session.getId() + "]");
    }
    session.removeAttribute(Constants.CURRENT_USER);
    setAllUserNumber(-1);
}
项目:timesheet-upload    文件:SessionListener.java   
@Override
public void sessionCreated(HttpSessionEvent event) {
    try {
        event.getSession().setMaxInactiveInterval(60 * 60);
    } catch (Exception ex) {
        log.error("Exception while getting the Max Inactive Interval " + ex);
    }

}
项目:tomcat7    文件:StandardSession.java   
/**
 * Inform the listeners about the new session.
 *
 */
public void tellNew() {

    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_CREATED_EVENT, null);

    // Notify interested application event listeners
    Context context = (Context) manager.getContainer();
    Object listeners[] = context.getApplicationLifecycleListeners();
    if (listeners != null) {
        HttpSessionEvent event =
            new HttpSessionEvent(getSession());
        for (int i = 0; i < listeners.length; i++) {
            if (!(listeners[i] instanceof HttpSessionListener))
                continue;
            HttpSessionListener listener =
                (HttpSessionListener) listeners[i];
            try {
                context.fireContainerEvent("beforeSessionCreated",
                        listener);
                listener.sessionCreated(event);
                context.fireContainerEvent("afterSessionCreated", listener);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                try {
                    context.fireContainerEvent("afterSessionCreated",
                            listener);
                } catch (Exception e) {
                    // Ignore
                }
                manager.getContainer().getLogger().error
                    (sm.getString("standardSession.sessionEvent"), t);
            }
        }
    }

}
项目:dhus-core    文件:SessionDestroyedCleaner.java   
@Override
public void sessionDestroyed (final HttpSessionEvent event)
{
   SecurityContextProvider.removeSecurityContext ((String) event
      .getSession ().getAttribute ("integrity"));
   super.sessionDestroyed (event);
}
项目:zkAdmin    文件:WebSessionListener.java   
@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {

    Object obj = httpSessionEvent.getSession().getAttribute(Constants.ZOOKEEPER_MANAGER_SESSION_KEY);
    if(obj!=null){
        ((ZookeeperManager)obj).close();
    }
    logger.trace("session destroy!");
}
项目:oscm    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event) {

        HttpSession session = event.getSession();
        sessionMap.remove(session.getId());

        ServiceAccess serviceAccess = ServiceAccess
                .getServiceAcccessFor(session);
        serviceAccess.getService(SessionService.class)
                .deleteSessionsForSessionId(event.getSession().getId());
    }
项目:lemon    文件:SessionEventHttpSessionListenerAdapter.java   
private HttpSessionEvent createHttpSessionEvent(AbstractSessionEvent event) {
    ExpiringSession session = event.getSession();
    HttpSession httpSession = new ExpiringSessionHttpSession<ExpiringSession>(session,
            this.context);
    HttpSessionEvent httpSessionEvent = new HttpSessionEvent(httpSession);
    return httpSessionEvent;
}
项目:lemon    文件:LogoutHttpSessionListener.java   
public void sessionDestroyed(HttpSessionEvent se) {
    ApplicationContext ctx = WebApplicationContextUtils
            .getWebApplicationContext(se.getSession().getServletContext());

    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    HttpSession session = se.getSession();
    UserAuthDTO userAuthDto = this.internalUserAuthConnector
            .findFromSession(session);

    String tenantId = null;

    if (userAuthDto != null) {
        tenantId = userAuthDto.getTenantId();
    }

    LogoutEvent logoutEvent = new LogoutEvent(session, null,
            session.getId(), tenantId);
    ctx.publishEvent(logoutEvent);
}
项目:lemon    文件:ProxyServletListener.java   
public void sessionCreated(HttpSessionEvent se) {
    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    Collection<HttpSessionListener> httpSessionListeners = ctx
            .getBeansOfType(HttpSessionListener.class).values();

    for (HttpSessionListener httpSessionListener : httpSessionListeners) {
        httpSessionListener.sessionCreated(se);
    }
}
项目:lemon    文件:ProxyServletListener.java   
public void sessionDestroyed(HttpSessionEvent se) {
    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    Collection<HttpSessionListener> httpSessionListeners = ctx
            .getBeansOfType(HttpSessionListener.class).values();

    for (HttpSessionListener httpSessionListener : httpSessionListeners) {
        httpSessionListener.sessionDestroyed(se);
    }
}
项目:Equella    文件:UserSessionDestructionListener.java   
@Override
public void sessionCreated(HttpSessionEvent event)
{
    for( HttpSessionListener listener : getListeners() )
    {
        listener.sessionCreated(event);
    }
}
项目:Equella    文件:UserSessionDestructionListener.java   
@Override
public void sessionDestroyed(HttpSessionEvent event)
{
    for( HttpSessionListener listener : getListeners() )
    {
        listener.sessionDestroyed(event);
    }
}
项目:Equella    文件:UserSessionDestructionListener.java   
@Override
public void sessionCreated(HttpSessionEvent event)
{
    // We don't care about these
    if( LOGGER.isDebugEnabled() )
    {
        final String sessionId = event.getSession().getId();
        LOGGER.debug(sessionId + " session created");
    }
}
项目:lams    文件:StandardSession.java   
/**
 * Inform the listeners about the new session.
 *
 */
public void tellNew() {

    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_CREATED_EVENT, null);

    // Notify interested application event listeners
    Context context = (Context) manager.getContainer();
    Object listeners[] = context.getApplicationLifecycleListeners();
    if (listeners != null) {
        HttpSessionEvent event =
            new HttpSessionEvent(getSession());
        for (int i = 0; i < listeners.length; i++) {
            if (!(listeners[i] instanceof HttpSessionListener))
                continue;
            HttpSessionListener listener =
                (HttpSessionListener) listeners[i];
            try {
                fireContainerEvent(context,
                                   "beforeSessionCreated",
                                   listener);
                listener.sessionCreated(event);
                fireContainerEvent(context,
                                   "afterSessionCreated",
                                   listener);
            } catch (Throwable t) {
                try {
                    fireContainerEvent(context,
                                       "afterSessionCreated",
                                       listener);
                } catch (Exception e) {
                    ;
                }
                manager.getContainer().getLogger().error
                    (sm.getString("standardSession.sessionEvent"), t);
            }
        }
    }

}
项目:lams    文件:SessionRestoringHandler.java   
public void stop() {
    ClassLoader old = getTccl();
    try {
        setTccl(servletContext.getClassLoader());
        this.started = false;
        final Map<String, SessionPersistenceManager.PersistentSession> objectData = new HashMap<>();
        for (String sessionId : sessionManager.getTransientSessions()) {
            Session session = sessionManager.getSession(sessionId);
            if (session != null) {
                final HttpSessionEvent event = new HttpSessionEvent(SecurityActions.forSession(session, servletContext, false));
                final Map<String, Object> sessionData = new HashMap<>();
                for (String attr : session.getAttributeNames()) {
                    final Object attribute = session.getAttribute(attr);
                    sessionData.put(attr, attribute);
                    if (attribute instanceof HttpSessionActivationListener) {
                        ((HttpSessionActivationListener) attribute).sessionWillPassivate(event);
                    }
                }
                objectData.put(sessionId, new PersistentSession(new Date(session.getLastAccessedTime() + (session.getMaxInactiveInterval() * 1000)), sessionData));
            }
        }
        sessionPersistenceManager.persistSessions(deploymentName, objectData);
        this.data.clear();
    } finally {
        setTccl(old);
    }
}
项目:lams    文件:SessionRestoringHandler.java   
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    final String incomingSessionId = servletContext.getSessionConfig().findSessionId(exchange);
    if (incomingSessionId == null || !data.containsKey(incomingSessionId)) {
        next.handleRequest(exchange);
        return;
    }

    //we have some old data
    PersistentSession result = data.remove(incomingSessionId);
    if (result != null) {
        long time = System.currentTimeMillis();
        if (time < result.getExpiration().getTime()) {
            final HttpSessionImpl session = servletContext.getSession(exchange, true);
            final HttpSessionEvent event = new HttpSessionEvent(session);
            for (Map.Entry<String, Object> entry : result.getSessionData().entrySet()) {

                if (entry.getValue() instanceof HttpSessionActivationListener) {
                    ((HttpSessionActivationListener) entry.getValue()).sessionDidActivate(event);
                }
                if(entry.getKey().startsWith(HttpSessionImpl.IO_UNDERTOW)) {
                    session.getSession().setAttribute(entry.getKey(), entry.getValue());
                } else {
                    session.setAttribute(entry.getKey(), entry.getValue());
                }
            }
        }
    }
    next.handleRequest(exchange);
}
项目:lams    文件:ApplicationListeners.java   
public void sessionDestroyed(final HttpSession session) {
    final HttpSessionEvent sre = new HttpSessionEvent(session);
    for (int i = httpSessionListeners.length - 1; i >= 0; --i) {
        ManagedListener listener = httpSessionListeners[i];
        this.<HttpSessionListener>get(listener).sessionDestroyed(sre);
    }
}
项目:Spring-web-shop-project    文件:SessionActionsListener.java   
@Override
public void sessionCreated(HttpSessionEvent session) {
    if (ApplicationProperties.FALSE_WHILE_RUNNING_DB_TESTS) {
        HashSet<Book> shopBasket = new HashSet<Book>();
        LinkedList<Book> shopBasketUno = new LinkedList<Book>();

        session.getSession().setAttribute("basket", shopBasket);
        session.getSession().setAttribute("basketWithAllBooks", shopBasketUno);
        session.getSession().setAttribute("PROJECT_NAME", ApplicationProperties.PROJECT_NAME);
        session.getSession().setAttribute("URL", ApplicationProperties.URL);
    }
}
项目:iBase4J    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    if (getAllUserNumber() > 0) {
        logger.info("销毁了一个Session连接:[" + session.getId() + "]");
    }
    session.removeAttribute(Constants.CURRENT_USER);
    setAllUserNumber(-1);
}
项目:unitimes    文件:SessionListener.java   
/**
 * Listener Event when session is created
 */
public void sessionCreated(HttpSessionEvent se) {
    HttpSession session = se.getSession();
    sessions.put(session.getId(), session);
    activeSessions++;        

    Debug.info("TT Session started ... " + session.getId() + " " +  new Date());
}
项目:unitimes    文件:SessionListener.java   
/**
   * Listener Event when session is destroyed
   */
  public void sessionDestroyed(HttpSessionEvent se) {
      HttpSession session = se.getSession();
sessions.remove(session.getId());
      if(activeSessions > 0) {
    activeSessions--;
}

      Debug.info("TT Session ended ... " + session.getId() + " " +  new Date());
      Debug.info("    - TT Session time ... " +  
              ( (new Date().getTime() - session.getCreationTime())/(1000*60) ) + " minutes" );

      session.invalidate();
  }
项目:unitimes    文件:BusySessions.java   
protected Tracker getTracker(HttpSessionEvent event) {
    if (iTracker == null) {
        WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(event.getSession().getServletContext());
        iTracker = (Tracker)applicationContext.getBean("unitimeBusySessions");
    }
    return iTracker;
}
项目:ctsms    文件:LogoutListener.java   
@Override
public void sessionDestroyed(HttpSessionEvent event) {
    SessionScopeBean sessionScopeBean = WebUtil.getSessionScopeBean(event.getSession());
    if (sessionScopeBean != null) {
        ApplicationScopeBean.unregisterActiveUser(sessionScopeBean.getUser());
    }
}
项目:sgroup    文件:NewSessionListener.java   
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
    String sessionId = httpSessionEvent.getSession().getId();
    System.out.println("当前创建的sessionId = " + sessionId);
    ServletContext servletContext = httpSessionEvent.getSession().getServletContext();
    Object userCount = servletContext.getAttribute("userCount");
    if (userCount == null || "0".equals(userCount)) {
        servletContext.setAttribute("userCount", 1);
    } else {
        servletContext.setAttribute("userCount", Integer.parseInt(userCount.toString()) + 1);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:StandardSession.java   
/**
 * Inform the listeners about the new session.
 *
 */
public void tellNew() {

    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_CREATED_EVENT, null);

    // Notify interested application event listeners
    Context context = (Context) manager.getContainer();
    Object listeners[] = context.getApplicationLifecycleListeners();
    if (listeners != null) {
        HttpSessionEvent event =
            new HttpSessionEvent(getSession());
        for (int i = 0; i < listeners.length; i++) {
            if (!(listeners[i] instanceof HttpSessionListener))
                continue;
            HttpSessionListener listener =
                (HttpSessionListener) listeners[i];
            try {
                context.fireContainerEvent("beforeSessionCreated",
                        listener);
                listener.sessionCreated(event);
                context.fireContainerEvent("afterSessionCreated", listener);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                try {
                    context.fireContainerEvent("afterSessionCreated",
                            listener);
                } catch (Exception e) {
                    // Ignore
                }
                manager.getContainer().getLogger().error
                    (sm.getString("standardSession.sessionEvent"), t);
            }
        }
    }

}
项目:JAVA-    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    if (getAllUserNumber() > 0) {
        logger.info("销毁了一个Session连接:[" + session.getId() + "]");
    }
    session.removeAttribute(Constants.CURRENT_USER);
    redisTemplate.opsForSet().remove(Constants.ALLUSER_NUMBER, session.getId());
}
项目:alfresco-remote-api    文件:WebDAVSessionListener.java   
@Override
public void sessionCreated(HttpSessionEvent hse)
{
    if (logger.isDebugEnabled())
    {
        logger.debug("Session created " + hse.getSession().getId());
    }
}
项目:wangmarket    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event) {
        HttpSession session = event.getSession();

//      SImpleSiteVO vo = (SImpleSiteVO) session.getAttribute("SImpleSiteVO");  //当前用户访问的站点信息
        RequestLog requestLog = (RequestLog) session.getAttribute("requestLog");

        try {
            //如果为空,应该是没走domain应用的dns.do,那么为空的不予理会
            if(requestLog != null && G.aliyunLogUtil != null){
                G.aliyunLogUtil.saveByGroup(requestLog.getServerName(), requestLog.getIp(), requestLog.getLogGroup());
            }
        } catch (LogException e) {
            e.printStackTrace();
        }
    }
项目:wangmarket    文件:SessionListener.java   
public void sessionDestroyed(HttpSessionEvent event) {
        HttpSession session = event.getSession();

//      SImpleSiteVO vo = (SImpleSiteVO) session.getAttribute("SImpleSiteVO");  //当前用户访问的站点信息
        RequestLog requestLog = (RequestLog) session.getAttribute("requestLog");

        try {
            //如果为空,应该是没走domain应用的dns.do,那么为空的不予理会
            if(requestLog != null && G.aliyunLogUtil != null){
                G.aliyunLogUtil.saveByGroup(requestLog.getServerName(), requestLog.getIp(), requestLog.getLogGroup());
            }
        } catch (LogException e) {
            e.printStackTrace();
        }
    }
项目:jaffa-framework    文件:WebServiceSessionListener.java   
@Override
public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    // session has been invalidated and all session data (except Id)is no longer available
    if (log.isDebugEnabled()) {
        log.debug(getTime() + " (session) Destroyed:ID=" + session.getId());
    }
}
项目:Spring-5.0-Cookbook    文件:AppSessionListener.java   
@Override
public void sessionDestroyed(HttpSessionEvent event) {
    System.out.println("app session destroyed");
}