コード例 #1
0
  @Override
  public void sessionCreated(HttpSessionEvent e) {

    System.out.println(this.date() + ": Session " + e.getSession().getId() + " created.");

    SessionRegistry.addSession(e.getSession());
  }
コード例 #2
0
  @Override
  public void sessionDestroyed(HttpSessionEvent e) {

    System.out.println(this.date() + ": Session " + e.getSession().getId() + " destroyed.");

    SessionRegistry.removeSession(e.getSession());
  }
コード例 #3
0
  @Override
  public void sessionIdChanged(HttpSessionEvent e, String oldSessionId) {

    System.out.println(
        this.date() + ": Session ID" + oldSessionId + " changed to " + e.getSession().getId());

    SessionRegistry.udpateSessionId(e.getSession(), oldSessionId);
  }
コード例 #4
0
ファイル: User.java プロジェクト: CircuitCoder/GrafixPlane
 @Override
 public void sessionDestroyed(HttpSessionEvent se) {
   if (se.getSource() instanceof User) return;
   User u = (User) se.getSession().getAttribute("g_user");
   if (u != null) {
     u.sessions.remove(se.getSession());
     --sessionCount;
   }
 }
コード例 #5
0
  /* (non-Javadoc)
   * @see javax.servlet.http.HttpSessionActivationListener#sessionDidActivate(javax.servlet.http.HttpSessionEvent)
   */
  @Override
  public void sessionDidActivate(HttpSessionEvent event) {
    // pour getSessionCount
    SESSION_COUNT.incrementAndGet();

    // pour invalidateAllSession
    SESSION_MAP_BY_ID.put(event.getSession().getId(), event.getSession());
    notifySessionDidActivate(event);
  }
コード例 #6
0
 /**
  * Handles the HttpSessionEvent by publishing a {@link HttpSessionCreationEvent} to the
  * application appContext.
  *
  * @param event HttpSessionEvent passed in by the container
  */
 public void sessionCreated(HttpSessionEvent event) {
   if (null == eventMulticaster) {
     eventMulticaster =
         ContextLoader.getContext(event.getSession().getServletContext())
             .getBean(EventMulticaster.class);
     Assert.notNull(eventMulticaster);
   }
   eventMulticaster.multicast(new HttpSessionCreationEvent(event.getSession()));
 }
コード例 #7
0
  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());
  }
コード例 #8
0
  /* (non-Javadoc)
   * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
   */
  public void sessionDestroyed(HttpSessionEvent se) {
    if (activeSessions > 0) {
      activeSessions--;
    }

    String sess = find2((String) se.getSession().getAttribute("RNCODE"));
    if (sess != null) {
      sessions.remove(se.getSession().getAttribute("RNCODE"));
    }
    se.getSession().invalidate();
  }
コード例 #9
0
 @Override
 public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
   for (Enumeration<String> enumeration = httpSessionEvent.getSession().getAttributeNames();
       enumeration.hasMoreElements(); ) {
     String key = enumeration.nextElement();
     if (key.startsWith("cursor.")) {
       EntityCursor cursor = (EntityCursor) httpSessionEvent.getSession().getAttribute(key);
       try {
         cursor.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
コード例 #10
0
  /**
   * Called when a session destroyed.
   *
   * @param hse the HTTP session event.
   */
  public void sessionDestroyed(HttpSessionEvent hse) {
    if (LOGGER.isLoggable(Level.FINEST)) {
      LOGGER.log(Level.FINEST, "Cleaning up session for CDI @ViewScoped beans");
    }

    HttpSession session = hse.getSession();

    Map<Object, Map<String, ViewScopeContextObject>> activeViewScopeContexts =
        (Map<Object, Map<String, ViewScopeContextObject>>)
            session.getAttribute(ACTIVE_VIEW_CONTEXTS);

    if (activeViewScopeContexts != null) {
      Map<String, Object> activeViewMaps =
          (Map<String, Object>) session.getAttribute(ACTIVE_VIEW_MAPS);
      if (activeViewMaps != null) {
        Iterator<Object> activeViewMapsIterator = activeViewMaps.values().iterator();
        while (activeViewMapsIterator.hasNext()) {
          Map<String, Object> instanceMap = (Map<String, Object>) activeViewMapsIterator.next();
          Map<String, ViewScopeContextObject> contextMap =
              activeViewScopeContexts.get(System.identityHashCode(instanceMap));
          destroyBeans(instanceMap, contextMap);
        }
      }

      activeViewScopeContexts.clear();
      session.removeAttribute(ACTIVE_VIEW_CONTEXTS);
    }
  }
コード例 #11
0
 @Override
 public void sessionCreated(HttpSessionEvent httpSessionEvent) {
   HttpSession session = httpSessionEvent.getSession();
   String sessionId = session.getId();
   LoggerFactory.getLogger(getClass())
       .info("HttpSession '" + session + "' with ID '" + sessionId + "' created");
 }
コード例 #12
0
 public void sessionDestroyed(HttpSessionEvent evt) {
   // Note: Session Fixation Protection (such as Spring Security)
   // might invalidate HTTP session and restore with a new one.
   // Thus, we use an attribute to denote this case and avoid the callback
   final HttpSession hsess = evt.getSession();
   if (hsess.getAttribute(Attributes.RENEW_NATIVE_SESSION) == null)
     WebManager.sessionDestroyed(hsess);
 }
コード例 #13
0
 public void sessionDestroyed(HttpSessionEvent se) {
   /* Session is destroyed. */
   System.out.println("用户走了,而且彻底走了");
   HttpSession session = se.getSession();
   String str = (String) session.getAttribute("userName");
   UserAcount uac = UserAcount.getInstance();
   uac.remove(str);
 }
コード例 #14
0
 @Override
 public void sessionDestroyed(HttpSessionEvent _se) {
   try {
     HttpSession tempSession = sessions.remove(_se.getSession().getId());
   } catch (NullPointerException | UnsupportedOperationException | ClassCastException e) {
   }
   setUsersOnline(getUsersOnline() - 1);
 }
コード例 #15
0
  /* (non-Javadoc)
   * @see javax.servlet.http.HttpSessionActivationListener#sessionWillPassivate(javax.servlet.http.HttpSessionEvent)
   */
  @Override
  public void sessionWillPassivate(HttpSessionEvent event) {
    // pour getSessionCount
    SESSION_COUNT.decrementAndGet();

    // pour invalidateAllSession
    SESSION_MAP_BY_ID.remove(event.getSession().getId());
    notifySessionWillPassivate(event);
  }
コード例 #16
0
 public void sessionDestroyed(HttpSessionEvent event) {
   // TODO Auto-generated method stub
   logger.warn("SessionListener destroy - " + event.getSource());
   try {
     throw new Exception();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #17
0
 /*
  * (non-Javadoc)
  *
  * @see
  * javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet
  * .http.HttpSessionEvent)
  */
 public void sessionDestroyed(HttpSessionEvent event) {
   HttpSession session = event.getSession();
   if (getAllUserNumber() > 0) {
     logger.info("销毁了一个Session连接:[" + session.getId() + "]");
   }
   session.removeAttribute(Constants.CURRENT_USER);
   sessionService.deleteBySessionId(session.getId());
   setAllUserNumber(-1);
 }
コード例 #18
0
  @Override
  public void sessionDestroyed(HttpSessionEvent event) {
    // TODO Auto-generated method stub
    HttpSession session = event.getSession();
    Membre user = (Membre) session.getAttribute("user");

    // mettre a jour status du user dans la BD
    int offline = MembreManager.setUserOffline(user.getMembreId());
  }
コード例 #19
0
 public void sessionCreated(HttpSessionEvent event) {
   // TODO Auto-generated method stub
   // Enumeration foo = event.getSession();
   logger.warn("SessionListener create - " + event.getSource());
   try {
     throw new Exception();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #20
0
ファイル: WebdavListener.java プロジェクト: nesi/ARCS-systems
 public void sessionDestroyed(HttpSessionEvent event) {
   HttpSession session = event.getSession();
   System.out.println("session destroyed: " + session.getId());
   Map credentials = (Map) session.getAttribute(WebdavServlet.CREDENTIALS);
   List creds = new ArrayList(credentials.values());
   SRBStorage srb = null;
   for (int i = 0; i < creds.size(); i++) {
     srb = (SRBStorage) creds.get(i);
     srb.disconnect();
   }
 }
コード例 #21
0
ファイル: SessionListener.java プロジェクト: adamsmj/yawl
  // can be used to cleanup after session invalidates
  public void sessionDestroyed(HttpSessionEvent event) {

    // get the session being destroyed
    HttpSession session = event.getSession();
    try {
      handleSessionTimeout(session);
    } catch (Exception e) {
      LogManager.getLogger(SessionListener.class)
          .error("Error while logging out at session destroyed : ", e);
    }
  }
コード例 #22
0
ファイル: SessionManager.java プロジェクト: kingoin/kgyun
 @Override
 public void sessionDestroyed(HttpSessionEvent se) {
   try {
     String sessionId = se.getSession().getId();
     logger.debug("session destroyed! sessionId = " + sessionId);
     sessionMap.remove(sessionId);
     ServiceLocator.getOnlineUserService().deleteOnlineUserBySessionId(sessionId);
   } catch (Exception ex) {
     logger.error(ex.getMessage(), ex);
   }
 }
コード例 #23
0
 /** {@inheritDoc} */
 @Override
 public void sessionCreated(final HttpSessionEvent event) {
   try {
     if (logger.isDebugEnabled()) {
       logger.debug("Starting a session with session id : [{0}]", event.getSession().getId());
     }
     if (webBeansContext instanceof WebappWebBeansContext) { // start before child
       ((WebappWebBeansContext) webBeansContext)
           .getParent()
           .getContextsService()
           .startContext(SessionScoped.class, event.getSession());
     }
     this.webBeansContext
         .getContextsService()
         .startContext(SessionScoped.class, event.getSession());
   } catch (final Exception e) {
     logger.error(OWBLogConst.ERROR_0020, event.getSession());
     WebBeansUtil.throwRuntimeExceptions(e);
   }
 }
コード例 #24
0
  @Override
  public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
    ServletContext ctx = httpSessionEvent.getSession().getServletContext();

    List<Object> jsListeners =
        (List<Object>) ctx.getAttribute(JaggeryCoreConstants.JS_DESTROYED_LISTENERS);
    JaggeryContext clonedContext = WebAppManager.clonedJaggeryContext(ctx);

    RhinoEngine engine = clonedContext.getEngine();
    Context cx = engine.enterContext();

    ScriptableObject clonedScope = clonedContext.getScope();

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

    if (jsListeners != null) {
      for (Object jsListener : jsListeners) {
        CommonManager.getCallstack(clonedContext).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);
        }
      }
    }
  }
コード例 #25
0
 @Override
 public void sessionDestroyed(HttpSessionEvent sessionEvent) {
   System.out.println("session destroyed");
   HttpSession session = sessionEvent.getSession();
   Object ip = session.getAttribute("IPInSession");
   if (ip != null) {
     clearAllUser(ip.toString(), session.getAttributeNames());
   }
   if (session != null) {
     new APControl().clearSession(session);
   }
 }
コード例 #26
0
 /**
  * Method checks session on not fully created objects and clean up it.
  *
  * @param httpSessionEvent destroy event
  */
 @Override
 public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
   Bet bet = (Bet) httpSessionEvent.getSession().getAttribute("bet");
   if (bet != null) {
     BetService betService = new BetService();
     try {
       betService.cancelBetCreation(bet);
     } catch (ServiceException e) {
       LOG.error("Cannot cancel bet creation after sessions invalidating", e);
     }
   }
   Match match = (Match) httpSessionEvent.getSession().getAttribute("match");
   if (match != null) {
     MatchService matchService = new MatchService();
     try {
       matchService.cancelMatchCreation(match);
     } catch (ServiceException e) {
       LOG.error("Cannot cancel match creation after session invalidating ", e);
     }
   }
 }
コード例 #27
0
  public static synchronized void sessionDestroyed(HttpSessionEvent ev) {
    HttpSession httpSession = ev.getSession();
    String id = httpSession.getId();

    synchronized (lookupSessionById) {
      lookupSessionById.remove(id);
    }

    // Forget HTTP-session:
    {
      lookupHttpSessionById.remove(id);
    }
  }
コード例 #28
0
  /** Remove {@link ConversationState}. {@inheritDoc} */
  public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession httpSession = event.getSession();
    StateKey stateKey = new HttpSessionStateKey(httpSession);

    ConversationRegistry conversationRegistry =
        (ConversationRegistry)
            getContainer(httpSession.getServletContext())
                .getComponentInstanceOfType(ConversationRegistry.class);

    ConversationState conversationState = conversationRegistry.unregister(stateKey);

    if (conversationState != null)
      if (log.isDebugEnabled()) log.debug("Remove conversation state " + httpSession.getId());
  }
コード例 #29
0
  @Override
  public void sessionCreated(HttpSessionEvent se) {
    HttpSession session = se.getSession();
    try {
      sessions.put(session.getId(), session);
      setUsersOnline(getUsersOnline() + 1);

    } catch (UnsupportedOperationException
        | ClassCastException
        | NullPointerException
        | IllegalArgumentException e) {
      System.out.println(
          "edu.temple.cis3238.wiki.WikiEventMonitor.sessionCreated() -- " + e.toString());
    }
  }
コード例 #30
0
  /* (non-Javadoc)
   * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
   */
  @Override
  public void sessionDestroyed(HttpSessionEvent event) {
    final HttpSession session = event.getSession();

    // plus de removeAttribute
    // (pas nécessaire et Tomcat peut faire une exception "session already invalidated")
    //		session.removeAttribute(SESSION_ACTIVATION_KEY);

    // pour getSessionCount
    SESSION_COUNT.decrementAndGet();

    // pour invalidateAllSession
    SESSION_MAP_BY_ID.remove(session.getId());
    notifySessionDestroyed(event);
  }