|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AbstractPageContextWrapper.java | - | 29.6% | 26.9% | 28.3% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2001-2003 The Apache Software Foundation.
|
|
| 5 |
*
|
|
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 7 |
* you may not use this file except in compliance with the License.
|
|
| 8 |
* You may obtain a copy of the License at
|
|
| 9 |
*
|
|
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 11 |
*
|
|
| 12 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 15 |
* See the License for the specific language governing permissions and
|
|
| 16 |
* limitations under the License.
|
|
| 17 |
*
|
|
| 18 |
* ========================================================================
|
|
| 19 |
*/
|
|
| 20 |
package org.apache.cactus.server;
|
|
| 21 |
|
|
| 22 |
import java.io.IOException;
|
|
| 23 |
|
|
| 24 |
import java.util.Enumeration;
|
|
| 25 |
|
|
| 26 |
import javax.servlet.Servlet;
|
|
| 27 |
import javax.servlet.ServletConfig;
|
|
| 28 |
import javax.servlet.ServletContext;
|
|
| 29 |
import javax.servlet.ServletException;
|
|
| 30 |
import javax.servlet.ServletRequest;
|
|
| 31 |
import javax.servlet.ServletResponse;
|
|
| 32 |
import javax.servlet.http.HttpServletRequest;
|
|
| 33 |
import javax.servlet.http.HttpSession;
|
|
| 34 |
import javax.servlet.jsp.JspWriter;
|
|
| 35 |
import javax.servlet.jsp.PageContext;
|
|
| 36 |
import javax.servlet.jsp.tagext.BodyContent;
|
|
| 37 |
|
|
| 38 |
import org.apache.cactus.ServletURL;
|
|
| 39 |
|
|
| 40 |
/**
|
|
| 41 |
* Abstract wrapper around <code>PageContext</code>. This class provides
|
|
| 42 |
* a common implementation of the wrapper for the different servlet API.
|
|
| 43 |
*
|
|
| 44 |
* @version $Id: AbstractPageContextWrapper.java 239136 2005-02-01 08:54:44Z vmassol $
|
|
| 45 |
*/
|
|
| 46 |
public abstract class AbstractPageContextWrapper extends PageContext |
|
| 47 |
{
|
|
| 48 |
/**
|
|
| 49 |
* The real page context
|
|
| 50 |
*/
|
|
| 51 |
protected PageContext originalPageContext;
|
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* The URL to simulate
|
|
| 55 |
*/
|
|
| 56 |
protected ServletURL url;
|
|
| 57 |
|
|
| 58 |
/**
|
|
| 59 |
* Construct an <code>PageContext</code> instance that delegates
|
|
| 60 |
* it's method calls to the page context object passed as parameter and
|
|
| 61 |
* that uses the URL passed as parameter to simulate a URL from which
|
|
| 62 |
* the request would come from.
|
|
| 63 |
*
|
|
| 64 |
* @param theOriginalPageContext the real page context
|
|
| 65 |
* @param theURL the URL to simulate or <code>null</code> if none
|
|
| 66 |
*/
|
|
| 67 | 5 |
public AbstractPageContextWrapper(PageContext theOriginalPageContext,
|
| 68 |
ServletURL theURL) |
|
| 69 |
{
|
|
| 70 | 5 |
this.originalPageContext = theOriginalPageContext;
|
| 71 | 5 |
this.url = theURL;
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
// New methods ---------------------------------------------------------
|
|
| 75 |
|
|
| 76 |
/**
|
|
| 77 |
* @return the original page context
|
|
| 78 |
* @since 1.7
|
|
| 79 |
*/
|
|
| 80 | 0 |
public PageContext getOriginalPageContext()
|
| 81 |
{
|
|
| 82 | 0 |
return this.originalPageContext; |
| 83 |
} |
|
| 84 |
|
|
| 85 |
// Modified overridden methods -------------------------------------------
|
|
| 86 |
|
|
| 87 |
/**
|
|
| 88 |
* @return the Cactus wrapped servlet request that knows about the
|
|
| 89 |
* simulated URL
|
|
| 90 |
*/
|
|
| 91 | 0 |
public ServletRequest getRequest()
|
| 92 |
{
|
|
| 93 |
// Note: we only manage HttpServletRequest here
|
|
| 94 | 0 |
return new HttpServletRequestWrapper( |
| 95 |
(HttpServletRequest) this.originalPageContext.getRequest(),
|
|
| 96 |
this.url);
|
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
/**
|
|
| 100 |
* @return the Cactus wrapped servlet config
|
|
| 101 |
*/
|
|
| 102 | 0 |
public ServletConfig getServletConfig()
|
| 103 |
{
|
|
| 104 | 0 |
return new ServletConfigWrapper( |
| 105 |
this.originalPageContext.getServletConfig());
|
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
/**
|
|
| 109 |
* @return the Cactus wrapped servlet context
|
|
| 110 |
*/
|
|
| 111 | 0 |
public ServletContext getServletContext()
|
| 112 |
{
|
|
| 113 | 0 |
return new ServletContextWrapper( |
| 114 |
this.originalPageContext.getServletContext());
|
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
// Unmodified overridden methods -----------------------------------------
|
|
| 118 |
|
|
| 119 |
/**
|
|
| 120 |
* @see PageContext#findAttribute(String)
|
|
| 121 |
*/
|
|
| 122 | 0 |
public Object findAttribute(String theName)
|
| 123 |
{
|
|
| 124 | 0 |
return this.originalPageContext.findAttribute(theName); |
| 125 |
} |
|
| 126 |
|
|
| 127 |
/**
|
|
| 128 |
* @see PageContext#forward(String)
|
|
| 129 |
*/
|
|
| 130 | 0 |
public void forward(String theRelativeURLPath) throws ServletException, |
| 131 |
IOException |
|
| 132 |
{
|
|
| 133 | 0 |
this.originalPageContext.forward(theRelativeURLPath);
|
| 134 |
} |
|
| 135 |
|
|
| 136 |
/**
|
|
| 137 |
* @see PageContext#getAttribute(String)
|
|
| 138 |
*/
|
|
| 139 | 17 |
public Object getAttribute(String theName)
|
| 140 |
{
|
|
| 141 | 17 |
return this.originalPageContext.getAttribute(theName); |
| 142 |
} |
|
| 143 |
|
|
| 144 |
/**
|
|
| 145 |
* @see PageContext#getAttribute(String, int)
|
|
| 146 |
*/
|
|
| 147 | 0 |
public Object getAttribute(String theName, int theScope) |
| 148 |
{
|
|
| 149 | 0 |
return this.originalPageContext.getAttribute(theName, theScope); |
| 150 |
} |
|
| 151 |
|
|
| 152 |
/**
|
|
| 153 |
* @see PageContext#getAttributeNamesInScope(int)
|
|
| 154 |
*/
|
|
| 155 | 2 |
public Enumeration getAttributeNamesInScope(int theScope) |
| 156 |
{
|
|
| 157 | 2 |
return this.originalPageContext.getAttributeNamesInScope(theScope); |
| 158 |
} |
|
| 159 |
|
|
| 160 |
/**
|
|
| 161 |
* @see PageContext#getAttributesScope(String)
|
|
| 162 |
*/
|
|
| 163 | 0 |
public int getAttributesScope(String theName) |
| 164 |
{
|
|
| 165 | 0 |
return this.originalPageContext.getAttributesScope(theName); |
| 166 |
} |
|
| 167 |
|
|
| 168 |
/**
|
|
| 169 |
* @see PageContext#getException()
|
|
| 170 |
*/
|
|
| 171 | 0 |
public Exception getException()
|
| 172 |
{
|
|
| 173 | 0 |
return this.originalPageContext.getException(); |
| 174 |
} |
|
| 175 |
|
|
| 176 |
/**
|
|
| 177 |
* @see PageContext#getOut()
|
|
| 178 |
*/
|
|
| 179 | 3 |
public JspWriter getOut()
|
| 180 |
{
|
|
| 181 | 3 |
return this.originalPageContext.getOut(); |
| 182 |
} |
|
| 183 |
|
|
| 184 |
/**
|
|
| 185 |
* @see PageContext#getPage()
|
|
| 186 |
*/
|
|
| 187 | 0 |
public Object getPage()
|
| 188 |
{
|
|
| 189 | 0 |
return this.originalPageContext.getPage(); |
| 190 |
} |
|
| 191 |
|
|
| 192 |
/**
|
|
| 193 |
* @see PageContext#getResponse()
|
|
| 194 |
*/
|
|
| 195 | 0 |
public ServletResponse getResponse()
|
| 196 |
{
|
|
| 197 | 0 |
return this.originalPageContext.getResponse(); |
| 198 |
} |
|
| 199 |
|
|
| 200 |
/**
|
|
| 201 |
* @see PageContext#getSession()
|
|
| 202 |
*/
|
|
| 203 | 0 |
public HttpSession getSession()
|
| 204 |
{
|
|
| 205 | 0 |
return this.originalPageContext.getSession(); |
| 206 |
} |
|
| 207 |
|
|
| 208 |
/**
|
|
| 209 |
* @see PageContext#handlePageException(Exception)
|
|
| 210 |
*/
|
|
| 211 | 0 |
public void handlePageException(Exception theException) |
| 212 |
throws ServletException, IOException
|
|
| 213 |
{
|
|
| 214 | 0 |
this.originalPageContext.handlePageException(theException);
|
| 215 |
} |
|
| 216 |
|
|
| 217 |
/**
|
|
| 218 |
* @see PageContext#include(String)
|
|
| 219 |
*/
|
|
| 220 | 0 |
public void include(String theRelativeURLPath) throws ServletException, |
| 221 |
IOException |
|
| 222 |
{
|
|
| 223 | 0 |
this.originalPageContext.include(theRelativeURLPath);
|
| 224 |
} |
|
| 225 |
|
|
| 226 |
/**
|
|
| 227 |
* @see PageContext#initialize
|
|
| 228 |
*/
|
|
| 229 | 0 |
public void initialize(Servlet theServlet, ServletRequest theRequest, |
| 230 |
ServletResponse theResponse, String theErrorPageURL, |
|
| 231 |
boolean isSessionNeeded, int theBufferSize, boolean isAutoFlush) |
|
| 232 |
throws IOException, IllegalStateException, IllegalArgumentException
|
|
| 233 |
{
|
|
| 234 | 0 |
this.originalPageContext.initialize(theServlet, theRequest,
|
| 235 |
theResponse, theErrorPageURL, isSessionNeeded, theBufferSize, |
|
| 236 |
isAutoFlush); |
|
| 237 |
} |
|
| 238 |
|
|
| 239 |
/**
|
|
| 240 |
* @see PageContext#popBody()
|
|
| 241 |
*/
|
|
| 242 | 1 |
public JspWriter popBody()
|
| 243 |
{
|
|
| 244 | 1 |
return this.originalPageContext.popBody(); |
| 245 |
} |
|
| 246 |
|
|
| 247 |
/**
|
|
| 248 |
* @see PageContext#pushBody()
|
|
| 249 |
*/
|
|
| 250 | 1 |
public BodyContent pushBody()
|
| 251 |
{
|
|
| 252 | 1 |
return this.originalPageContext.pushBody(); |
| 253 |
} |
|
| 254 |
|
|
| 255 |
/**
|
|
| 256 |
* @see PageContext#release()
|
|
| 257 |
*/
|
|
| 258 | 0 |
public void release() |
| 259 |
{
|
|
| 260 | 0 |
this.originalPageContext.release();
|
| 261 |
} |
|
| 262 |
|
|
| 263 |
/**
|
|
| 264 |
* @see PageContext#removeAttribute(String)
|
|
| 265 |
*/
|
|
| 266 | 0 |
public void removeAttribute(String theName) |
| 267 |
{
|
|
| 268 | 0 |
this.originalPageContext.removeAttribute(theName);
|
| 269 |
} |
|
| 270 |
|
|
| 271 |
/**
|
|
| 272 |
* @see PageContext#removeAttribute(String, int)
|
|
| 273 |
*/
|
|
| 274 | 0 |
public void removeAttribute(String theName, int theScope) |
| 275 |
{
|
|
| 276 | 0 |
this.originalPageContext.removeAttribute(theName, theScope);
|
| 277 |
} |
|
| 278 |
|
|
| 279 |
/**
|
|
| 280 |
* @see PageContext#setAttribute(String, Object)
|
|
| 281 |
*/
|
|
| 282 | 1 |
public void setAttribute(String theName, Object theAttribute) |
| 283 |
{
|
|
| 284 | 1 |
this.originalPageContext.setAttribute(theName, theAttribute);
|
| 285 |
} |
|
| 286 |
|
|
| 287 |
/**
|
|
| 288 |
* @see PageContext#setAttribute(String, Object)
|
|
| 289 |
*/
|
|
| 290 | 0 |
public void setAttribute(String theName, Object theAttribute, int theScope) |
| 291 |
{
|
|
| 292 | 0 |
this.originalPageContext.setAttribute(theName, theAttribute, theScope);
|
| 293 |
} |
|
| 294 |
} |
|
| 295 |
|
|
||||||||||