KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > handlers > http > URLMapper


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.handlers.http;
18
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.MessageContext;
21 import org.apache.axis.components.logger.LogFactory;
22 import org.apache.axis.handlers.BasicHandler;
23 import org.apache.axis.transport.http.HTTPConstants;
24 import org.apache.commons.logging.Log;
25
26
27 /** An <code>URLMapper</code> attempts to use the extra path info
28  * of this request as the service name.
29  *
30  * @author Glen Daniels (gdaniels@apache.org)
31  */

32 public class URLMapper extends BasicHandler
33 {
34     protected static Log log =
35         LogFactory.getLog(URLMapper.class.getName());
36
37     public void invoke(MessageContext msgContext) throws AxisFault
38     {
39         log.debug("Enter: URLMapper::invoke");
40
41         /** If there's already a targetService then just return.
42          */

43         if ( msgContext.getService() == null ) {
44             // path may or may not start with a "/". see http://issues.apache.org/jira/browse/AXIS-1372
45
String JavaDoc path = (String JavaDoc)msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO);
46             if ((path != null) && (path.length() >= 1)) { //rules out the cases of path="", path=null
47
if(path.startsWith("/"))
48                     path = path.substring(1); //chop the extra "/"
49

50                 msgContext.setTargetService( path );
51             }
52         }
53
54         log.debug("Exit: URLMapper::invoke");
55     }
56
57     public void generateWSDL(MessageContext msgContext) throws AxisFault {
58         invoke(msgContext);
59     }
60 }
61
Popular Tags