javax.faces.context.ExternalContextWrapper Maven / Gradle / Ivy
Show all versions of javax.faces Show documentation
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.faces.context;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.security.Principal;
import javax.faces.FacesWrapper;
/**
* Provides a simple implementation of
* {@link ExternalContext} that can
* be subclassed by developers wishing to provide specialized behavior
* to an existing {@link ExternalContext} instance. The default
* implementation of all methods is to call through to the wrapped
* {@link ExternalContext} instance.
*
* Usage: extend this class and override
* {@link #getWrapped} to
* return the instance being wrapping.
*
* @since 2.0
*/
public abstract class ExternalContextWrapper extends ExternalContext implements FacesWrapper {
// ----------------------------------------------- Methods from FacesWrapper
/**
* @return the wrapped {@link ExternalContext} instance
* @see javax.faces.FacesWrapper#getWrapped()
*/
public abstract ExternalContext getWrapped();
// -------------------------------------------- Methods from ExternalContext
/**
* The default behavior of this method is to
* call {@link ExternalContext#dispatch(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#dispatch(String)
*/
public void dispatch(String path) throws IOException {
getWrapped().dispatch(path);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#encodeActionURL(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#encodeActionURL(String)
*/
public String encodeActionURL(String url) {
return getWrapped().encodeActionURL(url);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#encodeNamespace(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#encodeNamespace(String)
*/
public String encodeNamespace(String name) {
return getWrapped().encodeNamespace(name);
}
@Override
public String encodePartialActionURL(String url) {
return getWrapped().encodePartialActionURL(url);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#encodeResourceURL(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#encodeResourceURL(String)
*/
public String encodeResourceURL(String url) {
return getWrapped().encodeResourceURL(url);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getApplicationMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getApplicationMap()
*/
public Map getApplicationMap() {
return getWrapped().getApplicationMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getAuthType}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getAuthType()
*/
public String getAuthType() {
return getWrapped().getAuthType();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getContext}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getContext()
*/
public Object getContext() {
return getWrapped().getContext();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getInitParameter(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getInitParameter(String)
*/
public String getInitParameter(String name) {
return getWrapped().getInitParameter(name);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getInitParameterMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getInitParameterMap()
*/
public Map getInitParameterMap() {
return getWrapped().getInitParameterMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRemoteUser}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRemoteUser()
*/
public String getRemoteUser() {
return getWrapped().getRemoteUser();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequest}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequest()
*/
public Object getRequest() {
return getWrapped().getRequest();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestContextPath}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestContextPath()
*/
public String getRequestContextPath() {
return getWrapped().getRequestContextPath();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestCookieMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestCookieMap()
*/
public Map getRequestCookieMap() {
return getWrapped().getRequestCookieMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestHeaderMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestHeaderMap()
*/
public Map getRequestHeaderMap() {
return getWrapped().getRequestHeaderMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestHeaderValuesMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestHeaderValuesMap()
*/
public Map getRequestHeaderValuesMap() {
return getWrapped().getRequestHeaderValuesMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestLocale}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestLocale()
*/
public Locale getRequestLocale() {
return getWrapped().getRequestLocale();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestLocales}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestLocales()
*/
public Iterator getRequestLocales() {
return getWrapped().getRequestLocales();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestMap()
*/
public Map getRequestMap() {
return getWrapped().getRequestMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestParameterMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestParameterMap()
*/
public Map getRequestParameterMap() {
return getWrapped().getRequestParameterMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestParameterNames}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestParameterNames()
*/
public Iterator getRequestParameterNames() {
return getWrapped().getRequestParameterNames();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestParameterValuesMap}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestParameterValuesMap()
*/
public Map getRequestParameterValuesMap() {
return getWrapped().getRequestParameterValuesMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestPathInfo}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestPathInfo()
*/
public String getRequestPathInfo() {
return getWrapped().getRequestPathInfo();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestServletPath}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestServletPath()
*/
public String getRequestServletPath() {
return getWrapped().getRequestServletPath();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResource(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResource(String)
*/
public URL getResource(String path) throws MalformedURLException {
return getWrapped().getResource(path);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResourceAsStream(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResourceAsStream(String)
*/
public InputStream getResourceAsStream(String path) {
return getWrapped().getResourceAsStream(path);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResourcePaths(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResourcePaths(String)
*/
public Set getResourcePaths(String path) {
return getWrapped().getResourcePaths(path);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponse}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponse()
*/
public Object getResponse() {
return getWrapped().getResponse();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getSession(boolean)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getSession(boolean)
*/
public Object getSession(boolean create) {
return getWrapped().getSession(create);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getAuthType}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getAuthType()
*/
public Map getSessionMap() {
return getWrapped().getSessionMap();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getUserPrincipal}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getUserPrincipal()
*/
public Principal getUserPrincipal() {
return getWrapped().getUserPrincipal();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#isUserInRole(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#isUserInRole(String)
*/
public boolean isUserInRole(String role) {
return getWrapped().isUserInRole(role);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#log(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#log(String)
*/
public void log(String message) {
getWrapped().log(message);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#log(String, Throwable)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#log(String, Throwable)
*/
public void log(String message, Throwable exception) {
getWrapped().log(message, exception);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#redirect(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#redirect(String)
*/
public void redirect(String url) throws IOException {
getWrapped().redirect(url);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#addResponseCookie(String, String, Map)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#addResponseCookie(String, String, Map)
*/
@Override
public void addResponseCookie(String name,
String value,
Map properties) {
getWrapped().addResponseCookie(name, value, properties);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getMimeType(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getMimeType(String)
*/
@Override
public String getMimeType(String file) {
return getWrapped().getMimeType(file);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getContextName}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getContextName()
*/
@Override
public String getContextName() {
return getWrapped().getContextName();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setRequest(Object)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setRequest(Object)
*/
@Override
public void setRequest(Object request) {
getWrapped().setRequest(request);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestScheme}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestScheme()
*/
@Override
public String getRequestScheme() {
return getWrapped().getRequestScheme();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestServerName}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestServerName()
*/
@Override
public String getRequestServerName() {
return getWrapped().getRequestServerName();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestServerPort}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestServerPort()
*/
@Override
public int getRequestServerPort() {
return getWrapped().getRequestServerPort();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setRequestCharacterEncoding(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setRequestCharacterEncoding(String)
*/
@Override
public void setRequestCharacterEncoding(String encoding)
throws UnsupportedEncodingException {
getWrapped().setRequestCharacterEncoding(encoding);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRealPath(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRealPath(String)
*/
@Override
public String getRealPath(String path) {
return getWrapped().getRealPath(path);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestCharacterEncoding}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestCharacterEncoding()
*/
@Override
public String getRequestCharacterEncoding() {
return getWrapped().getRequestCharacterEncoding();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestContentType}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestContentType()
*/
@Override
public String getRequestContentType() {
return getWrapped().getRequestContentType();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getRequestContentLength}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getRequestContentLength()
*/
@Override
public int getRequestContentLength() {
return getWrapped().getRequestContentLength();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponseCharacterEncoding}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponseCharacterEncoding()
*/
@Override
public String getResponseCharacterEncoding() {
return getWrapped().getResponseCharacterEncoding();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponseContentType}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponseContentType()
*/
@Override
public String getResponseContentType() {
return getWrapped().getResponseContentType();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setResponse(Object)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setResponse(Object)
*/
@Override
public void setResponse(Object response) {
getWrapped().setResponse(response);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponseOutputStream}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponseOutputStream()
*/
@Override
public OutputStream getResponseOutputStream() throws IOException {
return getWrapped().getResponseOutputStream();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponseOutputWriter}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponseOutputWriter()
*/
@Override
public Writer getResponseOutputWriter() throws IOException {
return getWrapped().getResponseOutputWriter();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponseCharacterEncoding}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponseCharacterEncoding()
*/
@Override
public void setResponseCharacterEncoding(String encoding) {
getWrapped().setResponseCharacterEncoding(encoding);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setResponseContentType(String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setResponseContentType(String)
*/
@Override
public void setResponseContentType(String contentType) {
getWrapped().setResponseContentType(contentType);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#invalidateSession}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#invalidateSession()
*/
@Override
public void invalidateSession() {
getWrapped().invalidateSession();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setResponseHeader(String,String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setResponseHeader(String,String)
*/
@Override
public void setResponseHeader(String name, String value) {
getWrapped().setResponseHeader(name, value);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#addResponseHeader(String,String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#addResponseHeader(String,String)
*/
@Override
public void addResponseHeader(String name, String value) {
getWrapped().addResponseHeader(name, value);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setResponseBufferSize(int)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setResponseBufferSize(int)
*/
@Override
public void setResponseBufferSize(int size) {
getWrapped().setResponseBufferSize(size);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getResponseBufferSize()}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#getResponseBufferSize()
*/
@Override
public int getResponseBufferSize() {
return getWrapped().getResponseBufferSize();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#isResponseCommitted()}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#isResponseCommitted()
*/
@Override
public boolean isResponseCommitted() {
return getWrapped().isResponseCommitted();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#responseReset()}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#responseReset()
*/
@Override
public void responseReset() {
getWrapped().responseReset();
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#responseSendError(int,String)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#responseSendError(int,String)
*/
@Override
public void responseSendError(int statusCode, String message) throws IOException {
getWrapped().responseSendError(statusCode, message);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#setResponseStatus(int)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setResponseStatus(int)
*/
@Override
public void setResponseStatus(int statusCode) {
getWrapped().setResponseStatus(statusCode);
}
/**
* The default behavior of this method is to
* call {@link javax.faces.context.ExternalContext#responseFlushBuffer()}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#responseFlushBuffer()
*/
@Override
public void responseFlushBuffer() throws IOException {
getWrapped().responseFlushBuffer();
}
/**
* The default behavior of this method is to
* call {@link javax.faces.context.ExternalContext#setResponseContentLength(int)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#setResponseContentLength(int)
*/
@Override
public void setResponseContentLength(int length) {
getWrapped().setResponseContentLength(length);
}
/**
* The default behavior of this method is to
* call {@link javax.faces.context.ExternalContext#encodeBookmarkableURL(String, java.util.Map)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#encodeBookmarkableURL(String, java.util.Map)
*/
@Override
public String encodeBookmarkableURL(String baseUrl, Map> parameters) {
return getWrapped().encodeBookmarkableURL(baseUrl, parameters);
}
/**
* The default behavior of this method is to
* call {@link javax.faces.context.ExternalContext#encodeRedirectURL(String, java.util.Map)}
* on the wrapped {@link ExternalContext} object.
*
* @see javax.faces.context.ExternalContext#encodeRedirectURL(String, java.util.Map)
*/
@Override
public String encodeRedirectURL(String baseUrl, Map> parameters) {
return getWrapped().encodeRedirectURL(baseUrl, parameters);
}
/**
* The default behavior of this method is to
* call {@link ExternalContext#getFlash()} on the wrapped {@link ExternalContext}
* object.