You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ve...@apache.org on 2009/08/20 22:01:19 UTC
svn commit: r806331 -
/webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
Author: veithen
Date: Thu Aug 20 20:01:19 2009
New Revision: 806331
URL: http://svn.apache.org/viewvc?rev=806331&view=rev
Log:
AXIS2-4465: Restored the initContextRoot method for compatibility with 1.5.
Modified:
webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
Modified: webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java?rev=806331&r1=806330&r2=806331&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java Thu Aug 20 20:01:19 2009
@@ -577,9 +577,36 @@
}
/**
+ * Set the context root if it is not set already.
+ *
+ * @param req
+ */
+ public void initContextRoot(HttpServletRequest req) {
+ if (contextRoot != null && contextRoot.trim().length() != 0) {
+ return;
+ }
+ String contextPath = null;
+ // Support older servlet API's
+ try {
+ contextPath = req.getContextPath();
+ } catch (Throwable t) {
+ log.info("Old Servlet API (Fallback to HttpServletRequest.getServletPath) :" + t);
+ contextPath = req.getServletPath();
+ }
+ //handling ROOT scenario, for servlets in the default (root) context, this method returns ""
+ if (contextPath != null && contextPath.length() == 0) {
+ contextPath = "/";
+ }
+ this.contextRoot = contextPath;
+
+ configContext.setContextRoot(contextRoot);
+ }
+
+ /**
* Preprocess the request. This will:
* <ul>
- * <li>Set the context root if it is not set already.
+ * <li>Set the context root if it is not set already (by calling
+ * {@link #initContextRoot(HttpServletRequest)}).
* <li>Remember the port number if port autodetection is enabled.
* <li>Reject the request if no {@link AxisServletListener} has been registered for the
* protocol.
@@ -587,24 +614,11 @@
*
* @param req the request to preprocess
*/
- protected void preprocessRequest(HttpServletRequest req) throws ServletException {
- if (contextRoot == null || contextRoot.trim().length() == 0) {
- String contextPath = null;
- // Support older servlet API's
- try {
- contextPath = req.getContextPath();
- } catch (Throwable t) {
- log.info("Old Servlet API (Fallback to HttpServletRequest.getServletPath) :" + t);
- contextPath = req.getServletPath();
- }
- //handling ROOT scenario, for servlets in the default (root) context, this method returns ""
- if (contextPath != null && contextPath.length() == 0) {
- contextPath = "/";
- }
- this.contextRoot = contextPath;
-
- configContext.setContextRoot(contextRoot);
- }
+ // This method should not be part of the public API. In particular we must not allow subclasses
+ // to override this method because we don't make any guarantees as to when exactly this method
+ // is called.
+ private void preprocessRequest(HttpServletRequest req) throws ServletException {
+ initContextRoot(req);
AxisServletListener listener = req.isSecure() ? httpsListener : httpListener;
if (listener == null) {