日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Request_继承体系

發(fā)布時間:2024/4/13 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Request_继承体系 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2. request對象繼承體系結構:?? ?
?? ?ServletRequest?? ??? ?--?? ?接口
?? ??? ?|?? ?繼承
?? ?HttpServletRequest?? ?-- 接口
?? ??? ?|?? ?實現
?? ?org.apache.catalina.connector.RequestFacade 類(tomcat)

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements. See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You 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.apache.catalina.connector;import java.io.BufferedReader; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Collection; import java.util.Enumeration; import java.util.Locale; import java.util.Map;import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpUpgradeHandler; import javax.servlet.http.Part;import org.apache.catalina.Globals; import org.apache.catalina.security.SecurityUtil; import org.apache.catalina.servlet4preview.http.HttpServletRequest; import org.apache.catalina.servlet4preview.http.PushBuilder; import org.apache.catalina.servlet4preview.http.ServletMapping; import org.apache.tomcat.util.res.StringManager;/*** Facade class that wraps a Coyote request object.* All methods are delegated to the wrapped request.** @author Craig R. McClanahan* @author Remy Maucherat*/ @SuppressWarnings("deprecation") public class RequestFacade implements HttpServletRequest {// ----------------------------------------------------------- DoPrivilegedprivate final class GetAttributePrivilegedActionimplements PrivilegedAction<Enumeration<String>> {@Overridepublic Enumeration<String> run() {return request.getAttributeNames();}}private final class GetParameterMapPrivilegedActionimplements PrivilegedAction<Map<String,String[]>> {@Overridepublic Map<String,String[]> run() {return request.getParameterMap();}}private final class GetRequestDispatcherPrivilegedActionimplements PrivilegedAction<RequestDispatcher> {private final String path;public GetRequestDispatcherPrivilegedAction(String path){this.path = path;}@Overridepublic RequestDispatcher run() {return request.getRequestDispatcher(path);}}private final class GetParameterPrivilegedActionimplements PrivilegedAction<String> {public String name;public GetParameterPrivilegedAction(String name){this.name = name;}@Overridepublic String run() {return request.getParameter(name);}}private final class GetParameterNamesPrivilegedActionimplements PrivilegedAction<Enumeration<String>> {@Overridepublic Enumeration<String> run() {return request.getParameterNames();}}private final class GetParameterValuePrivilegedActionimplements PrivilegedAction<String[]> {public String name;public GetParameterValuePrivilegedAction(String name){this.name = name;}@Overridepublic String[] run() {return request.getParameterValues(name);}}private final class GetCookiesPrivilegedActionimplements PrivilegedAction<Cookie[]> {@Overridepublic Cookie[] run() {return request.getCookies();}}private final class GetCharacterEncodingPrivilegedActionimplements PrivilegedAction<String> {@Overridepublic String run() {return request.getCharacterEncoding();}}private final class GetHeadersPrivilegedActionimplements PrivilegedAction<Enumeration<String>> {private final String name;public GetHeadersPrivilegedAction(String name){this.name = name;}@Overridepublic Enumeration<String> run() {return request.getHeaders(name);}}private final class GetHeaderNamesPrivilegedActionimplements PrivilegedAction<Enumeration<String>> {@Overridepublic Enumeration<String> run() {return request.getHeaderNames();}}private final class GetLocalePrivilegedActionimplements PrivilegedAction<Locale> {@Overridepublic Locale run() {return request.getLocale();}}private final class GetLocalesPrivilegedActionimplements PrivilegedAction<Enumeration<Locale>> {@Overridepublic Enumeration<Locale> run() {return request.getLocales();}}private final class GetSessionPrivilegedActionimplements PrivilegedAction<HttpSession> {private final boolean create;public GetSessionPrivilegedAction(boolean create){this.create = create;}@Overridepublic HttpSession run() {return request.getSession(create);}}// ----------------------------------------------------------- Constructors/*** Construct a wrapper for the specified request.** @param request The request to be wrapped*/public RequestFacade(Request request) {this.request = request;}// ----------------------------------------------------- Instance Variables/*** The wrapped request.*/protected Request request = null;/*** The string manager for this package.*/protected static final StringManager sm = StringManager.getManager(RequestFacade.class);// --------------------------------------------------------- Public Methods/*** Clear facade.*/public void clear() {request = null;}/*** Prevent cloning the facade.*/@Overrideprotected Object clone()throws CloneNotSupportedException {throw new CloneNotSupportedException();}// ------------------------------------------------- ServletRequest Methods@Overridepublic Object getAttribute(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getAttribute(name);}@Overridepublic Enumeration<String> getAttributeNames() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetAttributePrivilegedAction());} else {return request.getAttributeNames();}}@Overridepublic String getCharacterEncoding() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetCharacterEncodingPrivilegedAction());} else {return request.getCharacterEncoding();}}@Overridepublic void setCharacterEncoding(String env)throws java.io.UnsupportedEncodingException {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}request.setCharacterEncoding(env);}@Overridepublic int getContentLength() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getContentLength();}@Overridepublic String getContentType() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getContentType();}@Overridepublic ServletInputStream getInputStream() throws IOException {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getInputStream();}@Overridepublic String getParameter(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetParameterPrivilegedAction(name));} else {return request.getParameter(name);}}@Overridepublic Enumeration<String> getParameterNames() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetParameterNamesPrivilegedAction());} else {return request.getParameterNames();}}@Overridepublic String[] getParameterValues(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}String[] ret = null;/** Clone the returned array only if there is a security manager* in place, so that performance won't suffer in the non-secure case*/if (SecurityUtil.isPackageProtectionEnabled()){ret = AccessController.doPrivileged(new GetParameterValuePrivilegedAction(name));if (ret != null) {ret = ret.clone();}} else {ret = request.getParameterValues(name);}return ret;}@Overridepublic Map<String,String[]> getParameterMap() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetParameterMapPrivilegedAction());} else {return request.getParameterMap();}}@Overridepublic String getProtocol() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getProtocol();}@Overridepublic String getScheme() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getScheme();}@Overridepublic String getServerName() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getServerName();}@Overridepublic int getServerPort() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getServerPort();}@Overridepublic BufferedReader getReader() throws IOException {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getReader();}@Overridepublic String getRemoteAddr() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRemoteAddr();}@Overridepublic String getRemoteHost() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRemoteHost();}@Overridepublic void setAttribute(String name, Object o) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}request.setAttribute(name, o);}@Overridepublic void removeAttribute(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}request.removeAttribute(name);}@Overridepublic Locale getLocale() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetLocalePrivilegedAction());} else {return request.getLocale();}}@Overridepublic Enumeration<Locale> getLocales() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetLocalesPrivilegedAction());} else {return request.getLocales();}}@Overridepublic boolean isSecure() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.isSecure();}@Overridepublic RequestDispatcher getRequestDispatcher(String path) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetRequestDispatcherPrivilegedAction(path));} else {return request.getRequestDispatcher(path);}}@Overridepublic String getRealPath(String path) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRealPath(path);}@Overridepublic String getAuthType() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getAuthType();}@Overridepublic Cookie[] getCookies() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}Cookie[] ret = null;/** Clone the returned array only if there is a security manager* in place, so that performance won't suffer in the non-secure case*/if (SecurityUtil.isPackageProtectionEnabled()){ret = AccessController.doPrivileged(new GetCookiesPrivilegedAction());if (ret != null) {ret = ret.clone();}} else {ret = request.getCookies();}return ret;}@Overridepublic long getDateHeader(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getDateHeader(name);}@Overridepublic String getHeader(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getHeader(name);}@Overridepublic Enumeration<String> getHeaders(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetHeadersPrivilegedAction(name));} else {return request.getHeaders(name);}}@Overridepublic Enumeration<String> getHeaderNames() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (Globals.IS_SECURITY_ENABLED){return AccessController.doPrivileged(new GetHeaderNamesPrivilegedAction());} else {return request.getHeaderNames();}}@Overridepublic int getIntHeader(String name) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getIntHeader(name);}@Overridepublic String getMethod() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getMethod();}@Overridepublic String getPathInfo() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getPathInfo();}@Overridepublic String getPathTranslated() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getPathTranslated();}@Overridepublic String getContextPath() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getContextPath();}@Overridepublic String getQueryString() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getQueryString();}@Overridepublic String getRemoteUser() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRemoteUser();}@Overridepublic boolean isUserInRole(String role) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.isUserInRole(role);}@Overridepublic java.security.Principal getUserPrincipal() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getUserPrincipal();}@Overridepublic String getRequestedSessionId() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRequestedSessionId();}@Overridepublic String getRequestURI() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRequestURI();}@Overridepublic StringBuffer getRequestURL() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRequestURL();}@Overridepublic String getServletPath() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getServletPath();}@Overridepublic HttpSession getSession(boolean create) {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}if (SecurityUtil.isPackageProtectionEnabled()){return AccessController.doPrivileged(new GetSessionPrivilegedAction(create));} else {return request.getSession(create);}}@Overridepublic HttpSession getSession() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return getSession(true);}@Overridepublic String changeSessionId() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.changeSessionId();}@Overridepublic boolean isRequestedSessionIdValid() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.isRequestedSessionIdValid();}@Overridepublic boolean isRequestedSessionIdFromCookie() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.isRequestedSessionIdFromCookie();}@Overridepublic boolean isRequestedSessionIdFromURL() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.isRequestedSessionIdFromURL();}@Overridepublic boolean isRequestedSessionIdFromUrl() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.isRequestedSessionIdFromURL();}@Overridepublic String getLocalAddr() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getLocalAddr();}@Overridepublic String getLocalName() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getLocalName();}@Overridepublic int getLocalPort() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getLocalPort();}@Overridepublic int getRemotePort() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getRemotePort();}@Overridepublic ServletContext getServletContext() {if (request == null) {throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));}return request.getServletContext();}@Overridepublic AsyncContext startAsync() throws IllegalStateException {return request.startAsync();}@Overridepublic AsyncContext startAsync(ServletRequest request, ServletResponse response)throws IllegalStateException {return this.request.startAsync(request, response);}@Overridepublic boolean isAsyncStarted() {return request.isAsyncStarted();}@Overridepublic boolean isAsyncSupported() {return request.isAsyncSupported();}@Overridepublic AsyncContext getAsyncContext() {return request.getAsyncContext();}@Overridepublic DispatcherType getDispatcherType() {return request.getDispatcherType();}@Overridepublic boolean authenticate(HttpServletResponse response)throws IOException, ServletException {return request.authenticate(response);}@Overridepublic void login(String username, String password)throws ServletException {request.login(username, password);}@Overridepublic void logout() throws ServletException {request.logout();}@Overridepublic Collection<Part> getParts() throws IllegalStateException,IOException, ServletException {return request.getParts();}@Overridepublic Part getPart(String name) throws IllegalStateException, IOException,ServletException {return request.getPart(name);}public boolean getAllowTrace() {return request.getConnector().getAllowTrace();}/*** {@inheritDoc}** @since Servlet 3.1*/@Overridepublic long getContentLengthLong() {return request.getContentLengthLong();}/*** {@inheritDoc}** @since Servlet 3.1*/@Overridepublic <T extends HttpUpgradeHandler> T upgrade(Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException {return request.upgrade(httpUpgradeHandlerClass);}/*** {@inheritDoc}* <p>* Pulled forward from Servlet 4.0. The method signature may be modified,* removed or replaced at any time until Servlet 4.0 becomes final.*/@Overridepublic ServletMapping getServletMapping() {return request.getServletMapping();}public PushBuilder newPushBuilder(javax.servlet.http.HttpServletRequest request) {return this.request.newPushBuilder(request);}/*** {@inheritDoc}* <p>* Pulled forward from Servlet 4.0. The method signature may be modified,* removed or replaced at any time until Servlet 4.0 becomes final.*/@Overridepublic PushBuilder newPushBuilder() {return request.newPushBuilder();} }

?

總結

以上是生活随笔為你收集整理的Request_继承体系的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。