java类javax.servlet.http.HttpSessionBindingEvent的实例源码

HttpSessionListener.java 文件源码 项目:convertigo-engine 阅读 28 收藏 0 点赞 0 评论 0
public void valueUnbound(HttpSessionBindingEvent event) {
    try {
        Engine.logContext.debug("HTTP session stopping...");
        HttpSession httpSession = event.getSession();
        String httpSessionID = httpSession.getId();

        if (Engine.theApp != null) Engine.theApp.contextManager.removeAll(httpSessionID);
        removeSession(httpSessionID);

        Engine.logContext.debug("HTTP session stopped [" + httpSessionID + "]");
    } catch(Exception e) {
        Engine.logContext.error("Exception during unbinding HTTP session listener", e);
    }
}
SessionListenerBridge.java 文件源码 项目:lams 阅读 42 收藏 0 点赞 0 评论 0
@Override
public void attributeUpdated(final Session session, final String name, final Object value, final Object old) {
    if(name.startsWith(IO_UNDERTOW)) {
        return;
    }
    final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
    if (old != value) {
        if (old instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
        }
        applicationListeners.httpSessionAttributeReplaced(httpSession, name, old);
    }
    if (value instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
    }
}
ChartDeleter.java 文件源码 项目:parabuild-ci 阅读 49 收藏 0 点赞 0 评论 0
/**
 * When this object is unbound from the session (including upon session
 * expiry) the files that have been added to the ArrayList are iterated
 * and deleted.
 *
 * @param event  the session unbind event.
 */
public void valueUnbound(HttpSessionBindingEvent event) {

    Iterator iter = this.chartNames.listIterator();
    while (iter.hasNext()) {
        String filename = (String) iter.next();
        File file = new File(
            System.getProperty("java.io.tmpdir"), filename
        );
        if (file.exists()) {
            file.delete();
        }
    }
    return;

}
HttpSessionImpl.java 文件源码 项目:opengse 阅读 38 收藏 0 点赞 0 评论 0
/**
 * Removes the object bound with the specified name from
 * this session.
 */
public void removeAttribute(String name) {
  maybeThrowIllegalStateException();
  checkValid();
  Object value = getAttribute(name);
  // notify binding listeners
  if (value != null) {
    sessionData_.remove(name);
    updateCache();
    if (value instanceof HttpSessionBindingListener) {
      ((HttpSessionBindingListener) value).valueUnbound(
        new HttpSessionBindingEvent(this, name));
    }
  }
  // notify attribute listeners
  ServletSessionCache.getCache(cacheId_).
    notifySessionAttributeRemoved(this, name);
}
MockHttpSession.java 文件源码 项目:spring4-understanding 阅读 41 收藏 0 点赞 0 评论 0
/**
 * Serialize the attributes of this session into an object that can be
 * turned into a byte array with standard Java serialization.
 *
 * @return a representation of this session's serialized state
 */
public Serializable serializeState() {
    HashMap<String, Serializable> state = new HashMap<String, Serializable>();
    for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) {
        Map.Entry<String, Object> entry = it.next();
        String name = entry.getKey();
        Object value = entry.getValue();
        it.remove();
        if (value instanceof Serializable) {
            state.put(name, (Serializable) value);
        }
        else {
            // Not serializable... Servlet containers usually automatically
            // unbind the attribute in this case.
            if (value instanceof HttpSessionBindingListener) {
                ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
            }
        }
    }
    return state;
}
VertxWrappedSessionUT.java 文件源码 项目:vaadin-vertx-samples 阅读 40 收藏 0 点赞 0 评论 0
@Test
public void shouldUnbindOnInvalidate() throws Exception {

    Map<String, Object> sampleData = new HashMap<>();
    HttpSessionBindingListener mockA = mock(HttpSessionBindingListener.class);
    HttpSessionBindingListener mockC = mock(HttpSessionBindingListener.class);
    sampleData.put("a", mockA);
    sampleData.put("b", "b");
    sampleData.put("c", mockC);
    sampleData.put("b", "b");
    when(session.data()).thenReturn(sampleData);
    vertxWrappedSession.invalidate();
    verify(session).destroy();
    ArgumentCaptor<HttpSessionBindingEvent> sessionBindingEventCaptor = ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
    verify(mockA).valueUnbound(sessionBindingEventCaptor.capture());
    verify(mockC).valueUnbound(sessionBindingEventCaptor.capture());
    assertThat(sessionBindingEventCaptor.getAllValues()).hasSize(2);
    assertHttpSessionBindingEvent("a", mockA, sessionBindingEventCaptor.getAllValues().get(0));
    assertHttpSessionBindingEvent("c", mockC, sessionBindingEventCaptor.getAllValues().get(1));
}
MockHttpSession.java 文件源码 项目:nbone 阅读 75 收藏 0 点赞 0 评论 0
/**
 * Serialize the attributes of this session into an object that can be
 * turned into a byte array with standard Java serialization.
 *
 * @return a representation of this session's serialized state
 */
public Serializable serializeState() {
    HashMap<String, Serializable> state = new HashMap<String, Serializable>();
    for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) {
        Map.Entry<String, Object> entry = it.next();
        String name = entry.getKey();
        Object value = entry.getValue();
        it.remove();
        if (value instanceof Serializable) {
            state.put(name, (Serializable) value);
        }
        else {
            // Not serializable... Servlet containers usually automatically
            // unbind the attribute in this case.
            if (value instanceof HttpSessionBindingListener) {
                ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
            }
        }
    }
    return state;
}
CrawlerSessionManagerValve.java 文件源码 项目:tomcat7 阅读 35 收藏 0 点赞 0 评论 0
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
    String clientIp = sessionIdClientIp.remove(event.getSession().getId());
    if (clientIp != null) {
        clientIpSessionId.remove(clientIp);
    }
}
HttpSessionImpl.java 文件源码 项目:tasfe-framework 阅读 38 收藏 0 点赞 0 评论 0
@Override
public void removeAttribute(String name) {
    if (attributes != null) {
        Object value = attributes.get(name);
        if (value != null && value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
        }
        attributes.remove(name);
    }
}
HttpSessionImpl.java 文件源码 项目:tasfe-framework 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void setAttribute(String name, Object value) {
    attributes.put(name, value);

    if (value != null && value instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(this, name, value));
    }

}
SessionListenerBridge.java 文件源码 项目:lams 阅读 41 收藏 0 点赞 0 评论 0
@Override
public void attributeAdded(final Session session, final String name, final Object value) {
    if(name.startsWith(IO_UNDERTOW)) {
        return;
    }
    final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
    applicationListeners.httpSessionAttributeAdded(httpSession, name, value);
    if (value instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
    }
}
SessionListenerBridge.java 文件源码 项目:lams 阅读 40 收藏 0 点赞 0 评论 0
@Override
public void attributeRemoved(final Session session, final String name, final Object old) {
    if(name.startsWith(IO_UNDERTOW)) {
        return;
    }
    final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
    if (old != null) {
        applicationListeners.httpSessionAttributeRemoved(httpSession, name, old);
        if (old instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
        }
    }
}
PageStoreManager.java 文件源码 项目:gitplex-mit 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void valueUnbound(HttpSessionBindingEvent event)
{
    // WICKET-5164 use the original sessionId
    IPageStore store = getPageStore();
    // store might be null if destroyed already
    if (store != null)
    {
        store.unbind(sessionId);
    }
}
OnlineSession.java 文件源码 项目:ChronoBike 阅读 41 收藏 0 点赞 0 评论 0
public void valueUnbound(HttpSessionBindingEvent event)
{
    if(event.getName().equals("AppSession"))
    {
        Log.logNormal("Removing session");
        OnlineSession session = (OnlineSession)event.getValue();
        m_ResourceManager.removeSession(session);
    }
    else
    {
        Log.logImportant("Removing unknown object from session: "+event.getName());
    }
}
ChartDeleter.java 文件源码 项目:parabuild-ci 阅读 36 收藏 0 点赞 0 评论 0
/**
 * When this object is unbound from the session (including upon session
 * expiry) the files that have been added to the ArrayList are iterated
 * and deleted.
 *
 * @param event  the session unbind event.
 */
public void valueUnbound(HttpSessionBindingEvent event) {

    Iterator iter = this.chartNames.listIterator();
    while (iter.hasNext()) {
        String filename = (String) iter.next();
        File file = new File(System.getProperty("java.io.tmpdir"), filename);
        if (file.exists()) {
            file.delete();
        }
    }
    return;

}
CrawlerSessionManagerValve.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 43 收藏 0 点赞 0 评论 0
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
    String clientIp = sessionIdClientIp.remove(event.getSession().getId());
    if (clientIp != null) {
        clientIpSessionId.remove(clientIp);
    }
}
SessionListener.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Record the fact that a servlet context attribute was added.
 *
 * @param event
 *            The session attribute event
 */
@Override
public void attributeAdded(HttpSessionBindingEvent event) {

    log("attributeAdded('" + event.getSession().getId() + "', '"
            + event.getName() + "', '" + event.getValue() + "')");

}
SessionListener.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 35 收藏 0 点赞 0 评论 0
/**
 * Record the fact that a servlet context attribute was removed.
 *
 * @param event
 *            The session attribute event
 */
@Override
public void attributeRemoved(HttpSessionBindingEvent event) {

    log("attributeRemoved('" + event.getSession().getId() + "', '"
            + event.getName() + "', '" + event.getValue() + "')");

}
SessionListener.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Record the fact that a servlet context attribute was replaced.
 *
 * @param event
 *            The session attribute event
 */
@Override
public void attributeReplaced(HttpSessionBindingEvent event) {

    log("attributeReplaced('" + event.getSession().getId() + "', '"
            + event.getName() + "', '" + event.getValue() + "')");

}
SessionListener.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Record the fact that a servlet context attribute was added.
 *
 * @param event
 *            The session attribute event
 */
@Override
public void attributeAdded(HttpSessionBindingEvent event) {

    log("attributeAdded('" + event.getSession().getId() + "', '"
            + event.getName() + "', '" + event.getValue() + "')");

}
SessionListener.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 47 收藏 0 点赞 0 评论 0
/**
 * Record the fact that a servlet context attribute was removed.
 *
 * @param event
 *            The session attribute event
 */
@Override
public void attributeRemoved(HttpSessionBindingEvent event) {

    log("attributeRemoved('" + event.getSession().getId() + "', '"
            + event.getName() + "', '" + event.getValue() + "')");

}
SessionListener.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Record the fact that a servlet context attribute was replaced.
 *
 * @param event
 *            The session attribute event
 */
@Override
public void attributeReplaced(HttpSessionBindingEvent event) {

    log("attributeReplaced('" + event.getSession().getId() + "', '"
            + event.getName() + "', '" + event.getValue() + "')");

}
UserSession.java 文件源码 项目:jaffa-framework 阅读 38 收藏 0 点赞 0 评论 0
/** This is invoked, whenever an instance of this class is added to the HttpSession object.
 * Currently, this method will set the session timeout value
 * @param httpSessionBindingEvent the event that identifies the session.
 */
public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
   if (log.isDebugEnabled())
      log.debug("valueBound event");

   if(ContextManagerFactory.instance().getProperty(UserSession.RULE_TIMEOUT) != null ) {
      if (log.isDebugEnabled())
         log.debug("Setting Timeout to "+(String) ContextManagerFactory.instance().getProperty(UserSession.RULE_TIMEOUT));
      httpSessionBindingEvent.getSession().setMaxInactiveInterval(Integer.parseInt((String) ContextManagerFactory.instance().getProperty(UserSession.RULE_TIMEOUT)));
   }
}
UserSession.java 文件源码 项目:jaffa-framework 阅读 38 收藏 0 点赞 0 评论 0
/** This is invoked, whenever an instance of this class is removed from the HttpSession object.
 * This can happen by an explicit session.removeAttribute(), or if the HttpSession is invalidated or if the HttpSession times out.
 * It will kill all related components.
 * It will de-register from the Session Manager.
 * It will null out all internal references.
 * @param httpSessionBindingEvent the event that identifies the session.
 */
public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
    if (log.isDebugEnabled())
        log.debug("The valueUnbound method has been invoked. This will kill the UserSession.");

    // kill this usersession
    killUserSession();
}
MockHttpServletRequest.java 文件源码 项目:jaffa-framework 阅读 52 收藏 0 点赞 0 评论 0
public void setAttribute(String string, Object object) {
    Object originalValue = attr.put(string, object);
    if (originalValue != null && originalValue instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) originalValue).valueUnbound(new HttpSessionBindingEvent(this, string));
    }
    if (object != null && object instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) object).valueBound(new HttpSessionBindingEvent(this, string));
    }
}
NewSessionListener.java 文件源码 项目:sgroup 阅读 39 收藏 0 点赞 0 评论 0
@Override
public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) {
    ServletContext servletContext = httpSessionBindingEvent.getSession().getServletContext();
    Object loginCount = httpSessionBindingEvent.getSession().getAttribute("loginCount");
    if (loginCount == null || "0".equals(loginCount)) {
        servletContext.setAttribute("loginCount", 1);
    } else {
        servletContext.setAttribute("loginCount", Integer.parseInt(loginCount.toString()) + 1);
    }
}
NewSessionListener.java 文件源码 项目:sgroup 阅读 33 收藏 0 点赞 0 评论 0
@Override
public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) {
    ServletContext servletContext = httpSessionBindingEvent.getSession().getServletContext();
    Object loginCount = httpSessionBindingEvent.getSession().getAttribute("loginCount");
    if (loginCount == null || "0".equals(loginCount)) {
        servletContext.setAttribute("loginCount", 0);
    } else {
        servletContext.setAttribute("loginCount", Integer.parseInt(loginCount.toString()) - 1);
    }
}
CrawlerSessionManagerValve.java 文件源码 项目:lazycat 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
    String clientIp = sessionIdClientIp.remove(event.getSession().getId());
    if (clientIp != null) {
        clientIpSessionId.remove(clientIp);
    }
}
DefaultScriptSessionManager.java 文件源码 项目:dwr 阅读 61 收藏 0 点赞 0 评论 0
public void valueUnbound(HttpSessionBindingEvent arg0)
{
    if (scriptSessionManager != null && httpSessionId != null)
    {
        scriptSessionManager.disassociateAllScriptSessionsFromHttpSession(httpSessionId);
    }
}
ChartDeleter.java 文件源码 项目:jfreechart 阅读 45 收藏 0 点赞 0 评论 0
/**
 * When this object is unbound from the session (including upon session
 * expiry) the files that have been added to the ArrayList are iterated
 * and deleted.
 *
 * @param event  the session unbind event.
 */
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
    Iterator iter = this.chartNames.listIterator();
    while (iter.hasNext()) {
        String filename = (String) iter.next();
        File file = new File(
            System.getProperty("java.io.tmpdir"), filename
        );
        if (file.exists()) {
            file.delete();
        }
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号