You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2008/02/11 22:54:19 UTC
svn commit: r620625 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http:
AbstractAgent.java AxisServlet.java ListingAgent.java
Author: dims
Date: Mon Feb 11 13:54:17 2008
New Revision: 620625
URL: http://svn.apache.org/viewvc?rev=620625&view=rev
Log:
Get Axis2 Servlet to work somewhat reasonably under older Servlet API environment
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractAgent.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractAgent.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractAgent.java?rev=620625&r1=620624&r2=620625&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractAgent.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractAgent.java Mon Feb 11 13:54:17 2008
@@ -116,10 +116,13 @@
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
throws IOException, ServletException {
- httpServletResponse.setContentType("text/html");
- httpServletRequest.getRequestDispatcher(Constants.AXIS_WEB_CONTENT_ROOT + jspName)
- .include(httpServletRequest, httpServletResponse);
-
+ httpServletResponse.setContentType("text/html");
+ try {
+ httpServletRequest.getRequestDispatcher(Constants.AXIS_WEB_CONTENT_ROOT + jspName)
+ .include(httpServletRequest, httpServletResponse);
+ } catch (Throwable t) {
+ log.info("Old Servlet API :" + t);
+ }
}
private void preloadMethods() {
@@ -155,7 +158,11 @@
protected void populateSessionInformation(HttpServletRequest req) {
HashMap services = configContext.getAxisConfiguration().getServices();
- req.getSession().setAttribute(Constants.SERVICE_MAP, services);
- req.getSession().setAttribute(Constants.SERVICE_PATH, configContext.getServicePath());
+ try {
+ req.getSession().setAttribute(Constants.SERVICE_MAP, services);
+ req.getSession().setAttribute(Constants.SERVICE_PATH, configContext.getServicePath());
+ } catch (Throwable t){
+ log.info("Old Servlet API :" + t);
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?rev=620625&r1=620624&r2=620625&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Mon Feb 11 13:54:17 2008
@@ -106,7 +106,11 @@
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//set the initial buffer for a larger value
+ try {
response.setBufferSize(BUFFER_SIZE);
+ } catch (Throwable t){
+ log.info("Old Servlet API :" + t);
+ }
initContextRoot(request);
@@ -118,13 +122,21 @@
msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
try {
// adding ServletContext into msgContext;
+ String url;
+ try {
+ url = request.getRequestURL().toString();
+ } catch (Throwable t){
+ log.info("Old Servlet API (fallback to HttpServletRequest.getRequestURI) :" + t);
+ url = request.getRequestURI();
+ }
+
InvocationResponse pi = HTTPTransportUtils.
processHTTPPostRequest(msgContext,
new BufferedInputStream(request.getInputStream()),
new BufferedOutputStream(out),
contentType,
request.getHeader(HTTPConstants.HEADER_SOAP_ACTION),
- request.getRequestURL().toString());
+ url);
Boolean holdResponse =
(Boolean) msgContext.getProperty(RequestResponseTransport.HOLD_RESPONSE);
@@ -517,7 +529,14 @@
if (contextRoot != null && contextRoot.trim().length() != 0) {
return;
}
- String contextPath = req.getContextPath();
+ 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 = "/";
@@ -603,8 +622,16 @@
MessageContext msgContext = configContext.createMessageContext();
String requestURI = request.getRequestURI();
- String trsPrefix = request.getRequestURL().toString();
- int sepindex = trsPrefix.indexOf(':');
+ String trsPrefix = null;
+ int sepindex = -1;
+ // Support older servlet API's
+ try {
+ trsPrefix = request.getRequestURL().toString();
+ } catch (Throwable t){
+ log.info("Old Servlet API (Fallback to HttpServletRequest.getRequestURI) :" + t);
+ trsPrefix = request.getRequestURI();
+ }
+ sepindex = trsPrefix.indexOf(':');
if (sepindex > -1) {
trsPrefix = trsPrefix.substring(0, sepindex);
msgContext.setIncomingTransportName(trsPrefix);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java?rev=620625&r1=620624&r2=620625&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java Mon Feb 11 13:54:17 2008
@@ -111,7 +111,13 @@
protected void initTransportListener(HttpServletRequest httpServletRequest) {
// httpServletRequest.getLocalPort() , giving me a build error so I had to use the followin
- String filePart = httpServletRequest.getRequestURL().toString();
+ String filePart;
+ try {
+ filePart = httpServletRequest.getRequestURL().toString();
+ } catch (Throwable t){
+ log.info("Old Servlet API (fallback to HttpServletRequest.getRequestURI) :" + t);
+ filePart = httpServletRequest.getRequestURI();
+ }
int ipindex = filePart.indexOf("//");
String ip;
if (ipindex >= 0) {
@@ -137,7 +143,11 @@
String serviceName = req.getParameter("serviceName");
if (serviceName != null) {
AxisService service = configContext.getAxisConfiguration().getService(serviceName);
- req.getSession().setAttribute(Constants.SINGLE_SERVICE, service);
+ try {
+ req.getSession().setAttribute(Constants.SINGLE_SERVICE, service);
+ } catch (Throwable t) {
+ log.info("Old Servlet API :" + t);
+ }
}
renderView(LIST_FAULTY_SERVICES_JSP_NAME, req, res);
}
@@ -229,7 +239,13 @@
HttpServletResponse res)
throws IOException, ServletException {
- String url = req.getRequestURL().toString();
+ String url;
+ try {
+ url = req.getRequestURL().toString();
+ } catch (Throwable t) {
+ log.info("Old Servlet API (Fallback to HttpServletRequest.getRequestURI) :" + t);
+ url = req.getRequestURI();
+ }
String serviceName = extractServiceName(url);
HashMap services = configContext.getAxisConfiguration().getServices();
String query = req.getQueryString();
@@ -379,11 +395,20 @@
return;
} else {
- req.getSession().setAttribute(Constants.SINGLE_SERVICE,
- serviceObj);
+ try {
+ req.getSession().setAttribute(Constants.SINGLE_SERVICE,
+ serviceObj);
+ } catch (Throwable t) {
+ log.info("Old Servlet API :" + t);
+ }
}
} else {
- req.getSession().setAttribute(Constants.SINGLE_SERVICE, null);
+ try {
+ req.getSession().setAttribute(Constants.SINGLE_SERVICE, null);
+ } catch (Throwable t){
+ log.info("Old Servlet API :" + t);
+ }
+
res.sendError(HttpServletResponse.SC_NOT_FOUND, url);
}
}
@@ -396,9 +421,12 @@
throws IOException, ServletException {
populateSessionInformation(req);
- req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
- configContext.getAxisConfiguration().getFaultyServices());
-
+ try {
+ req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
+ configContext.getAxisConfiguration().getFaultyServices());
+ } catch (Throwable t){
+ log.info("Old Servlet API :" + t);
+ }
renderView(LIST_MULTIPLE_SERVICE_JSP_NAME, req, res);
}
@@ -490,12 +518,18 @@
SessionContext sessionContext =
(SessionContext) req.getSession(true).getAttribute(
Constants.SESSION_CONTEXT_PROPERTY);
- String sessionId = req.getSession().getId();
- if (sessionContext == null) {
+ String sessionId = null;
+ try {
+ sessionId = req.getSession().getId();
+ if (sessionContext == null) {
sessionContext = new SessionContext(null);
sessionContext.setCookieID(sessionId);
req.getSession().setAttribute(Constants.SESSION_CONTEXT_PROPERTY,
sessionContext);
+ }
+ } catch (Throwable t){
+ log.info("Old Servlet API :" + t);
+ return null;
}
messageContext.setSessionContext(sessionContext);
messageContext.setProperty(AxisServlet.SESSION_ID, sessionId);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org