11/* 
2-  * Copyright 2005-2010  the original author or authors. 
2+  * Copyright 2005-2012  the original author or authors. 
33 * 
44 * Licensed under the Apache License, Version 2.0 (the "License"); 
55 * you may not use this file except in compliance with the License. 
66 * You may obtain a copy of the License at 
77 * 
8-  *       http://www.apache.org/licenses/LICENSE-2.0 
8+  *     http://www.apache.org/licenses/LICENSE-2.0 
99 * 
1010 * Unless required by applicable law or agreed to in writing, software 
1111 * distributed under the License is distributed on an "AS IS" BASIS, 
2626import  org .springframework .ws .transport .context .TransportContextHolder ;
2727
2828/** 
29-  * Implementation of the <code>EndpointMapping</code> interface to map from the full request URI to endpoint beans. 
30-  * Supports both mapping to bean instances and mapping to bean names: the latter is required for prototype handlers. 
29+  * Implementation of the {@code EndpointMapping} interface to map from the full request URI or request URI path to 
30+  * endpoint beans. Supports both mapping to bean instances and mapping to bean names: the latter is required for 
31+  * prototype handlers. 
3132 * <p/> 
32-  * The <code>endpointMap</code> property is suitable for populating  the endpoint map with bean references, e.g. via the  
33-  * map element in XML bean definitions . 
33+  * When the {@link #setUsePath(boolean) usePath} property is enabled,  the mapping will be based on the URI path rather  
34+  * than the full URI . 
3435 * <p/> 
35-  * Mappings to bean names can be set via the <code>mappings</code> property, in a form accepted by the 
36-  * <code>java.util.Properties</code> class, like as follows: 
36+  * The {@code endpointMap} property is suitable for populating the endpoint map with bean references, e.g. via the map 
37+  * element in XML bean definitions. 
38+  * <p/> 
39+  * Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the {@code 
40+  * java.util.Properties} class, like as follows: 
3741 * <pre> 
3842 * http://example.com:8080/services/bookFlight=bookFlightEndpoint 
3943 * jms://exampleQueue=getFlightsEndpoint 
4044 * </pre> 
41-  * The syntax is URI=ENDPOINT_BEAN_NAME. 
45+  * or, when the {@code usePath} property is enabled: 
46+  * <pre> 
47+  * /services/bookFlight=bookFlightEndpoint 
48+  * </pre> 
49+  * The syntax is [URI|PATH]=ENDPOINT_BEAN_NAME. 
4250 * <p/> 
4351 * This endpoint mapping does not read from the request message, and therefore is more suitable for message factories 
44-  * which directly read from the transport request (such as the {@link AxiomSoapMessageFactory} with the 
45-  * <code> payloadCaching</code>  disabled). However, this endpoint mapping obviously is transport specific. 
52+  * which directly read from the transport request (such as the {@link AxiomSoapMessageFactory} with the {@code  
53+  * payloadCaching}  disabled). However, this endpoint mapping obviously is transport specific. 
4654 * 
4755 * @author Arjen Poutsma 
4856 * @since 1.5.0 
4957 */ 
5058public  class  UriEndpointMapping  extends  AbstractMapBasedEndpointMapping  {
5159
60+     private  boolean  usePath  = false ;
61+ 
62+     /** 
63+      * Indicates whether the path should be used instead of the full URI. Default is {@code false}. 
64+      * 
65+      * @since 2.1.1 
66+      */ 
67+     public  void  setUsePath (boolean  usePath ) {
68+         this .usePath  = usePath ;
69+     }
70+ 
5271    @ Override 
5372    protected  boolean  validateLookupKey (String  key ) {
5473        try  {
@@ -66,7 +85,13 @@ protected String getLookupKeyForMessage(MessageContext messageContext) throws Ex
6685        if  (transportContext  != null ) {
6786            WebServiceConnection  connection  = transportContext .getConnection ();
6887            if  (connection  != null ) {
69-                 return  connection .getUri ().toString ();
88+                 URI  connectionUri  = connection .getUri ();
89+                 if  (usePath ) {
90+                     return  connectionUri .getPath ();
91+                 }
92+                 else  {
93+                     return  connectionUri .toString ();
94+                 }
7095            }
7196        }
7297        return  null ;
0 commit comments