FakeSession.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:youtube-cache 作者:
/**
 * Binds an object to this session, using the name specified. If an object of 
 * the same name is already bound to the session, the object is replaced.
 * @param name The name to which the object is bound; cannot be null.
 * @param value The object to be bound.
 */
public void setAttribute(String name, Object value) {
    if (!isValid())
        throw new IllegalStateException(
            "Method is called on an invalidated session");
    if (value == null) removeAttribute(name);
    else {
        attributes.put(name, value);
        try {
            HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
            listener.valueBound(new HttpSessionBindingEvent(this, name, value));
            listener.notifyAll();
        }
        catch (ClassCastException e) { }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号