|
|||||||||||||||||||
| 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 | |||||||||||||||
| ServletTestRedirector.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2001-2004 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 javax.servlet.ServletException;
|
|
| 23 |
import javax.servlet.http.HttpServlet;
|
|
| 24 |
import javax.servlet.http.HttpServletRequest;
|
|
| 25 |
import javax.servlet.http.HttpServletResponse;
|
|
| 26 |
|
|
| 27 |
import org.apache.cactus.internal.configuration.ConfigurationInitializer;
|
|
| 28 |
import org.apache.cactus.internal.server.ServletImplicitObjects;
|
|
| 29 |
import org.apache.cactus.internal.server.ServletTestController;
|
|
| 30 |
import org.apache.commons.logging.Log;
|
|
| 31 |
import org.apache.commons.logging.LogFactory;
|
|
| 32 |
|
|
| 33 |
/**
|
|
| 34 |
* Generic Servlet redirector that calls a test method on the server side.
|
|
| 35 |
*
|
|
| 36 |
* @version $Id: ServletTestRedirector.java 238991 2004-05-22 11:34:50Z vmassol $
|
|
| 37 |
* @see org.apache.cactus.internal.server.ServletTestCaller
|
|
| 38 |
*/
|
|
| 39 |
public class ServletTestRedirector extends HttpServlet |
|
| 40 |
{
|
|
| 41 |
/**
|
|
| 42 |
* As this class is the first one loaded on the server side, we ensure
|
|
| 43 |
* that the Cactus configuration has been initialized. A better
|
|
| 44 |
* implementation might be to perform this initialization in the
|
|
| 45 |
* init() method. However, that requires removing the static LOGGER
|
|
| 46 |
* object.
|
|
| 47 |
*/
|
|
| 48 |
static
|
|
| 49 |
{
|
|
| 50 | 1 |
ConfigurationInitializer.initialize(); |
| 51 |
} |
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* The logger
|
|
| 55 |
*/
|
|
| 56 |
private static final Log LOGGER = |
|
| 57 |
LogFactory.getLog(ServletTestRedirector.class);
|
|
| 58 |
|
|
| 59 |
/**
|
|
| 60 |
* Handle GET requests.
|
|
| 61 |
*
|
|
| 62 |
* @param theRequest the incoming HTTP client request
|
|
| 63 |
* @param theResponse the outgoing HTTP client request to send back.
|
|
| 64 |
*
|
|
| 65 |
* @exception ServletException if an error occurs when servicing the
|
|
| 66 |
* request
|
|
| 67 |
*/
|
|
| 68 | 27 |
public void doGet(HttpServletRequest theRequest, |
| 69 |
HttpServletResponse theResponse) throws ServletException
|
|
| 70 |
{
|
|
| 71 |
// Same handling than for a POST
|
|
| 72 | 27 |
doPost(theRequest, theResponse); |
| 73 |
} |
|
| 74 |
|
|
| 75 |
/**
|
|
| 76 |
* Handle POST request. Extract from the HTTP request parameter, the
|
|
| 77 |
* Service to perform : call test method or return tests results.
|
|
| 78 |
*
|
|
| 79 |
* @param theRequest the incoming HTTP request.
|
|
| 80 |
* @param theResponse the outgoing HTTP response.
|
|
| 81 |
*
|
|
| 82 |
* @exception ServletException if an error occurs when servicing the
|
|
| 83 |
* request
|
|
| 84 |
*/
|
|
| 85 | 28 |
public void doPost(HttpServletRequest theRequest, |
| 86 |
HttpServletResponse theResponse) throws ServletException
|
|
| 87 |
{
|
|
| 88 |
// Mark beginning of test on server side
|
|
| 89 | 28 |
LOGGER.debug("------------- Start Servlet service");
|
| 90 |
|
|
| 91 |
// Create implicit object holder
|
|
| 92 | 28 |
ServletImplicitObjects objects = new ServletImplicitObjects();
|
| 93 |
|
|
| 94 | 28 |
objects.setHttpServletRequest(theRequest); |
| 95 | 28 |
objects.setHttpServletResponse(theResponse); |
| 96 | 28 |
objects.setServletContext(getServletContext()); |
| 97 | 28 |
objects.setServletConfig(getServletConfig()); |
| 98 |
|
|
| 99 | 28 |
ServletTestController controller = new ServletTestController();
|
| 100 |
|
|
| 101 | 28 |
controller.handleRequest(objects); |
| 102 |
} |
|
| 103 |
} |
|
| 104 |
|
|
||||||||||