01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: URLMapper.java 7496 2005-10-13 07:02:43Z durieuxp $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas.ws.axis;
25:
26: import javax.servlet.http.HttpServletRequest;
27:
28: import org.apache.axis.AxisFault;
29: import org.apache.axis.MessageContext;
30: import org.apache.axis.handlers.BasicHandler;
31: import org.apache.axis.transport.http.HTTPConstants;
32:
33: /**
34: * The <code>URLMapper</code> is given an HTTPServletRequest and
35: * knows from the invoked URL which service should be used.
36: * Old style URL :
37: * http://<host>:<port>/<context>/<url-mapping>/<name>
38: * pathInfo = /<name>
39: * servletPath = /<url-mapping>
40: *
41: * New Style URL:
42: * http://<host>:<port>/<context>/<name>
43: * pathInfo = empty
44: * servletPath = /<name>
45: *
46: * @author Guillaume Sauthier
47: */
48: public class URLMapper extends BasicHandler {
49:
50: private static final long serialVersionUID = 5261537788705414094L;
51:
52: /**
53: * @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
54: */
55: public void invoke(MessageContext mc) throws AxisFault {
56: /**
57: * If there's already a targetService then just return.
58: */
59: if (mc.getService() == null) {
60: String pathInfo = (String) mc
61: .getProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO);
62: HttpServletRequest req = (HttpServletRequest) mc
63: .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
64: String servletPath = req.getServletPath();
65: String path = null;
66:
67: if ((pathInfo == null) || (pathInfo.length() == 0)) {
68: // use the servletPath as target service
69: // new mode
70: if (servletPath.startsWith("/")) {
71: path = servletPath.substring(1); //chop the extra "/"
72: }
73: } else {
74: // directly take the pathinfo value
75: // compatibility mode
76: if (pathInfo.startsWith("/")) {
77: path = pathInfo.substring(1); //chop the extra "/"
78: }
79: }
80: mc.setTargetService(path);
81: }
82: }
83: }
|