亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? servletrequestattributes.java

?? spring framework 2.5.4源代碼
?? JAVA
字號:
/*
 * Copyright 2002-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.web.context.request;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.util.WebUtils;

/**
 * Servlet-based implementation of the {@link RequestAttributes} interface.
 *
 * <p>Accesses objects from servlet request and HTTP session scope,
 * with no distinction between "session" and "global session".
 *
 * @author Juergen Hoeller
 * @since 2.0
 * @see javax.servlet.ServletRequest#getAttribute
 * @see javax.servlet.http.HttpSession#getAttribute
 */
public class ServletRequestAttributes extends AbstractRequestAttributes {

	/**
	 * Constant identifying the {@link String} prefixed to the name of a
	 * destruction callback when it is stored in a {@link HttpSession}.
	 */
	public static final String DESTRUCTION_CALLBACK_NAME_PREFIX =
			ServletRequestAttributes.class.getName() + ".DESTRUCTION_CALLBACK.";


	private final HttpServletRequest request;

	private HttpSession session;

	private final Map sessionAttributesToUpdate = new HashMap();


	/**
	 * Create a new ServletRequestAttributes instance for the given request.
	 * @param request current HTTP request
	 */
	public ServletRequestAttributes(HttpServletRequest request) {
		Assert.notNull(request, "Request must not be null");
		this.request = request;
		// Fetch existing session reference early, to have it available even
		// after request completion (for example, in a custom child thread).
		this.session = request.getSession(false);
	}


	/**
	 * Exposes the native {@link HttpServletRequest} that we're wrapping.
	 */
	public final HttpServletRequest getRequest() {
		return this.request;
	}

	/**
	 * Exposes the {@link HttpSession} that we're wrapping.
	 * @param allowCreate whether to allow creation of a new session if none exists yet
	 */
	protected final HttpSession getSession(boolean allowCreate) {
		try {
			HttpSession currentSession = this.request.getSession(allowCreate);
			// If the current session is null, we might be in a custom child thread,
			// hence we want to preserve the original session reference (if any).
			// However, if we have a fresh non-null session, then let's use it.
			if (currentSession != null) {
				this.session = currentSession;
			}
			return this.session;
		}
		catch (IllegalStateException ex) {
			// Couldn't access session... let's check why.
			if (this.session == null) {
				// No matter what happened - we cannot offer a session.
				throw ex;
			}
			// We have a fallback session reference...
			// Let's see whether it is appropriate to return it.
			if (allowCreate) {
				boolean canAskForExistingSession = false;
				try {
					this.request.getSession(false);
					canAskForExistingSession = true;
				}
				catch (IllegalStateException ex2) {
				}
				if (canAskForExistingSession) {
					// Could ask for existing session, hence the IllegalStateException
					// came from trying to create a new session too late -> rethrow.
					throw ex;
				}
			}
			// Else: Could not even ask for existing session, hence we assume that
			// the request has been completed and the session is accessed later on
			// (for example, in a custom child thread).
			return this.session;
		}
	}


	public Object getAttribute(String name, int scope) {
		if (scope == SCOPE_REQUEST) {
			return this.request.getAttribute(name);
		}
		else {
			HttpSession session = getSession(false);
			if (session != null) {
				try {
					Object value = session.getAttribute(name);
					if (value != null) {
						this.sessionAttributesToUpdate.put(name, value);
					}
					return value;
				}
				catch (IllegalStateException ex) {
					// Session invalidated - shouldn't usually happen.
				}
			}
			return null;
		}
	}

	public void setAttribute(String name, Object value, int scope) {
		if (scope == SCOPE_REQUEST) {
			this.request.setAttribute(name, value);
		}
		else {
			HttpSession session = getSession(true);
			this.sessionAttributesToUpdate.remove(name);
			session.setAttribute(name, value);
		}
	}

	public void removeAttribute(String name, int scope) {
		if (scope == SCOPE_REQUEST) {
			this.request.removeAttribute(name);
			removeRequestDestructionCallback(name);
		}
		else {
			HttpSession session = getSession(false);
			if (session != null) {
				this.sessionAttributesToUpdate.remove(name);
				try {
					session.removeAttribute(name);
					// Remove any registered destruction callback as well.
					session.removeAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name);
				}
				catch (IllegalStateException ex) {
					// Session invalidated - shouldn't usually happen.
				}
			}
		}
	}

	public String[] getAttributeNames(int scope) {
		if (scope == SCOPE_REQUEST) {
			return StringUtils.toStringArray(this.request.getAttributeNames());
		}
		else {
			HttpSession session = getSession(false);
			if (session != null) {
				try {
					return StringUtils.toStringArray(session.getAttributeNames());
				}
				catch (IllegalStateException ex) {
					// Session invalidated - shouldn't usually happen.
				}
			}
			return new String[0];
		}
	}

	public void registerDestructionCallback(String name, Runnable callback, int scope) {
		if (scope == SCOPE_REQUEST) {
			registerRequestDestructionCallback(name, callback);
		}
		else {
			registerSessionDestructionCallback(name, callback);
		}
	}

	public String getSessionId() {
		return getSession(true).getId();
	}

	public Object getSessionMutex() {
		return WebUtils.getSessionMutex(getSession(true));
	}


	/**
	 * Update all accessed session attributes through <code>session.setAttribute</code>
	 * calls, explicitly indicating to the container that they might have been modified.
	 */
	protected void updateAccessedSessionAttributes() {
		HttpSession session = getSession(false);
		if (session != null) {
			try {
				for (Iterator it = this.sessionAttributesToUpdate.entrySet().iterator(); it.hasNext();) {
					Map.Entry entry = (Map.Entry) it.next();
					String name = (String) entry.getKey();
					Object newValue = entry.getValue();
					Object oldValue = session.getAttribute(name);
					if (oldValue == newValue) {
						session.setAttribute(name, newValue);
					}
				}
			}
			catch (IllegalStateException ex) {
				// Session invalidated - shouldn't usually happen.
			}
		}
		this.sessionAttributesToUpdate.clear();
	}

	/**
	 * Register the given callback as to be executed after session termination.
	 * @param name the name of the attribute to register the callback for
	 * @param callback the callback to be executed for destruction
	 */
	private void registerSessionDestructionCallback(String name, Runnable callback) {
		HttpSession session = getSession(true);
		session.setAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name,
				new DestructionCallbackBindingListener(callback));
	}


	public String toString() {
		return this.request.toString();
	}


	/**
	 * Adapter that implements the Servlet 2.3 HttpSessionBindingListener
	 * interface, wrapping a request destruction callback.
	 */
	private static class DestructionCallbackBindingListener implements HttpSessionBindingListener, Serializable {

		private final Runnable destructionCallback;

		public DestructionCallbackBindingListener(Runnable destructionCallback) {
			this.destructionCallback = destructionCallback;
		}

		public void valueBound(HttpSessionBindingEvent event) {
		}

		public void valueUnbound(HttpSessionBindingEvent event) {
			this.destructionCallback.run();
		}
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性生交片4| 综合激情成人伊人| 国产精品久线观看视频| 肉丝袜脚交视频一区二区| 国内成人自拍视频| 欧美日韩在线观看一区二区| 国产日韩欧美精品综合| 毛片基地黄久久久久久天堂| 一本色道久久综合狠狠躁的推荐 | 色8久久人人97超碰香蕉987| 久久久精品影视| 免费的国产精品| 在线视频你懂得一区| 亚洲欧洲精品成人久久奇米网| 精品一区中文字幕| 日韩欧美国产一区二区在线播放 | 欧美日韩亚州综合| 亚洲美女免费视频| 91丝袜国产在线播放| 久久影院视频免费| 狠狠色狠狠色综合| 精品va天堂亚洲国产| 美腿丝袜在线亚洲一区| 欧美男男青年gay1069videost| 一区二区三区产品免费精品久久75| 成人三级在线视频| 亚洲国产精品尤物yw在线观看| 国产一区二区三区四区在线观看 | 中文字幕欧美激情| 久久99精品久久久久久久久久久久 | 欧美日韩国产精品成人| 一区二区视频在线看| 91麻豆自制传媒国产之光| 亚洲欧洲成人自拍| 不卡的av在线| 亚洲乱码精品一二三四区日韩在线| www..com久久爱| 国产精品二区一区二区aⅴ污介绍| 波多野结衣亚洲一区| 国产精品久久久久久一区二区三区| 日本不卡中文字幕| 欧美亚洲禁片免费| 香蕉加勒比综合久久| 欧美日韩综合色| 午夜av一区二区三区| 日韩午夜激情免费电影| 久久国产日韩欧美精品| 久久麻豆一区二区| 99国产精品视频免费观看| 亚洲精品国产精品乱码不99| 欧美日韩激情在线| 激情图片小说一区| 亚洲色图19p| 欧美一区二区三区免费视频 | 奇米精品一区二区三区四区| 精品国精品自拍自在线| 成人短视频下载| 一区二区三区丝袜| 日韩欧美在线网站| 成熟亚洲日本毛茸茸凸凹| 亚洲精品免费视频| 欧美一级理论片| 99在线精品一区二区三区| 天天色 色综合| 国产欧美日韩在线看| 色婷婷久久久亚洲一区二区三区| 免费在线观看视频一区| 国产精品久久三| 欧美高清www午色夜在线视频| 国产精品一区二区久久不卡| 一区二区成人在线视频| 久久影音资源网| 欧美在线看片a免费观看| 激情偷乱视频一区二区三区| 一级中文字幕一区二区| 国产日韩欧美a| 777午夜精品视频在线播放| 成人妖精视频yjsp地址| 日韩—二三区免费观看av| 中文字幕亚洲在| 精品久久99ma| 欧美丝袜丝交足nylons图片| 国产成人av电影免费在线观看| 一区二区三区免费观看| 久久一日本道色综合| 欧美猛男超大videosgay| av电影一区二区| 国产乱色国产精品免费视频| 亚洲成人激情综合网| **网站欧美大片在线观看| 精品国产乱码久久久久久浪潮| 欧美午夜影院一区| 972aa.com艺术欧美| 国产精品888| 极品少妇一区二区| 日韩精品国产欧美| 亚洲精品午夜久久久| 国产精品久久久久天堂| 国产调教视频一区| 26uuu精品一区二区在线观看| 欧美高清精品3d| 欧美三级中文字| 在线视频国内一区二区| 91丨九色丨黑人外教| 成人综合在线观看| 国产精品66部| 国产成a人亚洲| 国产91在线看| 中文字幕不卡在线播放| 丝袜a∨在线一区二区三区不卡| 国产精品国产三级国产三级人妇 | 国产成人在线色| 国产美女在线精品| 国内精品嫩模私拍在线| 另类小说一区二区三区| 日本不卡不码高清免费观看| 日日嗨av一区二区三区四区| 天堂成人国产精品一区| 日韩国产成人精品| 看片的网站亚洲| 国产成人在线看| 北岛玲一区二区三区四区| 99久久精品久久久久久清纯| 99久久精品费精品国产一区二区| 成人激情视频网站| 一本一道久久a久久精品综合蜜臀| 午夜欧美一区二区三区在线播放| 精品一二三四在线| 麻豆成人91精品二区三区| 青青草精品视频| 国产一区二区三区免费看| 成人丝袜18视频在线观看| 972aa.com艺术欧美| 91久久精品一区二区| 欧美午夜电影一区| 日韩欧美成人午夜| 中文字幕欧美日韩一区| 亚洲一区在线免费观看| 麻豆一区二区三| 高清在线观看日韩| 欧美亚洲一区二区在线| 欧美成人在线直播| 国产精品国产三级国产aⅴ入口| 亚洲乱码国产乱码精品精小说 | 337p粉嫩大胆噜噜噜噜噜91av| 欧美韩日一区二区三区| 亚洲美女淫视频| 日韩av一区二| 波多野结衣亚洲一区| 欧美一区二区三级| 中文字幕+乱码+中文字幕一区| 洋洋av久久久久久久一区| 免费成人小视频| 91丨九色丨黑人外教| 精品久久人人做人人爰| 一区二区视频在线| 国产精品一卡二| 欧美日韩在线一区二区| 中文字幕av一区二区三区高 | 亚洲国产欧美一区二区三区丁香婷| 日本不卡免费在线视频| 91美女蜜桃在线| 久久综合久久综合亚洲| 亚洲一区二区三区免费视频| 成人中文字幕合集| 日韩欧美视频一区| 亚洲综合一二三区| 成+人+亚洲+综合天堂| 日韩欧美资源站| 亚洲地区一二三色| 成人做爰69片免费看网站| 欧美变态tickling挠脚心| 亚洲图片自拍偷拍| proumb性欧美在线观看| 久久一日本道色综合| 日韩主播视频在线| 欧美色电影在线| 亚洲乱码精品一二三四区日韩在线| 国产成人精品aa毛片| 精品久久人人做人人爰| 日韩av中文在线观看| 欧美喷水一区二区| 一个色妞综合视频在线观看| av毛片久久久久**hd| 欧美情侣在线播放| 亚洲欧美日韩在线不卡| 国产福利91精品一区| 久久久久久久电影| 麻豆精品视频在线| 欧美一区二区三区在线观看视频| 一区二区三区不卡在线观看| 色老头久久综合| 国产精品久久久久婷婷| 成人国产精品视频| 亚洲国产精品成人久久综合一区| 国产在线精品国自产拍免费| 日韩精品一区在线观看| 久久精品国产一区二区三| 欧美一区二区在线看| 免费欧美日韩国产三级电影|