|
|||||||||||||||||||
| 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 | |||||||||||||||
| ServletContextWrapper.java | 0% | 5% | 25% | 7.1% |
|
||||||||||||||
| 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.lang.reflect.Method;
|
|
| 23 |
|
|
| 24 |
import java.util.Set;
|
|
| 25 |
|
|
| 26 |
import javax.servlet.ServletContext;
|
|
| 27 |
|
|
| 28 |
/**
|
|
| 29 |
* Wrapper around Servlet 2.3 <code>ServletContext</code>. This wrapper
|
|
| 30 |
* provides additional behaviour (see
|
|
| 31 |
* <code>AbstractServletContextWrapper</code>).
|
|
| 32 |
*
|
|
| 33 |
* @version $Id: ServletContextWrapper.java 238991 2004-05-22 11:34:50Z vmassol $
|
|
| 34 |
* @see RequestDispatcherWrapper
|
|
| 35 |
*/
|
|
| 36 |
public class ServletContextWrapper extends AbstractServletContextWrapper |
|
| 37 |
{
|
|
| 38 |
/**
|
|
| 39 |
* @param theOriginalContext the original servlet context object
|
|
| 40 |
*/
|
|
| 41 | 3 |
public ServletContextWrapper(ServletContext theOriginalContext)
|
| 42 |
{
|
|
| 43 | 3 |
super(theOriginalContext);
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
/**
|
|
| 47 |
* @see ServletContext#getServletContextName()
|
|
| 48 |
*/
|
|
| 49 | 0 |
public String getServletContextName()
|
| 50 |
{
|
|
| 51 | 0 |
return this.originalContext.getServletContextName(); |
| 52 |
} |
|
| 53 |
|
|
| 54 |
/**
|
|
| 55 |
* @see #getResourcePaths(String)
|
|
| 56 |
*/
|
|
| 57 | 0 |
public Set getResourcePaths()
|
| 58 |
{
|
|
| 59 | 0 |
Set returnSet; |
| 60 |
|
|
| 61 |
// Use reflection because newest Servlet API 2.3 changes removed this
|
|
| 62 |
// method
|
|
| 63 | 0 |
try
|
| 64 |
{
|
|
| 65 | 0 |
Method method = this.originalContext.getClass().getMethod(
|
| 66 |
"getResourcePaths", null); |
|
| 67 |
|
|
| 68 | 0 |
if (method != null) |
| 69 |
{
|
|
| 70 | 0 |
returnSet = (Set) method.invoke(this.originalContext, null); |
| 71 |
} |
|
| 72 |
else
|
|
| 73 |
{
|
|
| 74 | 0 |
throw new RuntimeException("Method ServletContext." |
| 75 |
+ "getResourcePaths() no longer supported by your servlet "
|
|
| 76 |
+ "engine !");
|
|
| 77 |
} |
|
| 78 |
} |
|
| 79 |
catch (Exception e)
|
|
| 80 |
{
|
|
| 81 | 0 |
e.printStackTrace(); |
| 82 | 0 |
throw new RuntimeException("Error getting/calling method " |
| 83 |
+ "getResourcePaths()");
|
|
| 84 |
} |
|
| 85 |
|
|
| 86 | 0 |
return returnSet;
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
/**
|
|
| 90 |
* Added to support the changes of the Jakarta Servlet API 2.3 of the
|
|
| 91 |
* 17/03/2001 (in anticipation of the upcoming draft of Servlet 2.3). Kept
|
|
| 92 |
* the method without parameters for servlet engines that do not have
|
|
| 93 |
* upgraded yet to the new signature.
|
|
| 94 |
*
|
|
| 95 |
* @see ServletContext#getResourcePaths(String)
|
|
| 96 |
*/
|
|
| 97 | 0 |
public Set getResourcePaths(String thePath)
|
| 98 |
{
|
|
| 99 | 0 |
Set returnSet; |
| 100 |
|
|
| 101 |
// Check if the method exist (for servlet engines that do not have
|
|
| 102 |
// upgraded yet)
|
|
| 103 | 0 |
try
|
| 104 |
{
|
|
| 105 | 0 |
Method method = this.originalContext.getClass().getMethod(
|
| 106 |
"getResourcePaths", new Class[] {String.class}); |
|
| 107 |
|
|
| 108 | 0 |
if (method != null) |
| 109 |
{
|
|
| 110 | 0 |
returnSet = (Set) method.invoke(this.originalContext,
|
| 111 |
new Object[] {thePath});
|
|
| 112 |
} |
|
| 113 |
else
|
|
| 114 |
{
|
|
| 115 | 0 |
throw new RuntimeException("Method ServletContext." |
| 116 |
+ "getResourcePaths(String path) not supported yet by your "
|
|
| 117 |
+ "servlet engine !");
|
|
| 118 |
} |
|
| 119 |
} |
|
| 120 |
catch (Exception e)
|
|
| 121 |
{
|
|
| 122 | 0 |
e.printStackTrace(); |
| 123 | 0 |
throw new RuntimeException("Error getting/calling method " |
| 124 |
+ "getResourcePaths(String path)");
|
|
| 125 |
} |
|
| 126 |
|
|
| 127 | 0 |
return returnSet;
|
| 128 |
} |
|
| 129 |
} |
|
| 130 |
|
|
||||||||||