cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r470723 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ rt/transports/http/ rt/transports/http/src/main/java/org/ap...
Date Fri, 03 Nov 2006 08:47:10 GMT
Author: mmao
Date: Fri Nov  3 00:47:09 2006
New Revision: 470723

URL: http://svn.apache.org/viewvc?view=rev&rev=470723
Log:
HTTP GET Update 

* added fixedparameterorder configuration, and set the default value to false, 
   this means that the given parameters in the request uri can be random, but the name of
value must be given correctly according to the style/use of the service.
   In the JAX-WS case, the name is the value of the name attribute in WebParam defined in
JSR181.
* change the default value of contextMatchStrategy to stem since this kind of uri more and
more popular.
* enable the -Xdv option to generate the default value for http destination.

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorDocLitTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java
    incubator/cxf/trunk/rt/transports/http/pom.xml
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/resources/schemas/configuration/http-destination.xsd

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java Fri Nov  3 00:47:09
2006
@@ -49,6 +49,7 @@
     String SCHEMA_VALIDATION_ENABLED = Message.class.getCanonicalName() + ".schemaValidationEnabled";
     String CONTENT_TYPE = Message.class.getName() + ".ContentType";
     String BASE_PATH = Message.class.getName() + ".BASE_PATH";
+    String FIXED_PARAMETER_ORDER = Message.class.getName() + "FIXED_PARAMETER_ORDER";
 
     String getId();
     void setId(String id);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
Fri Nov  3 00:47:09 2006
@@ -56,18 +56,15 @@
 
     public void handleMessage(Message message) throws Fault {
         String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
-        LOG.info("Invoking HTTP method " + method);
-        BindingOperationInfo op = message.getExchange().get(BindingOperationInfo.class);
+        LOG.info("Invoking HTTP method " + method);        
         if (!isGET(message)) {
             LOG.info("URIMappingInterceptor can only handle HTTP GET, not HTTP " + method);
             return;
         }
-        if (op != null) {
-            return;
-        }
+
         String opName = getOperationName(message);
         LOG.info("URIMappingInterceptor get operation: " + opName);
-        op = ServiceModelUtil.getOperation(message.getExchange(), opName);
+        BindingOperationInfo op = ServiceModelUtil.getOperation(message.getExchange(), opName);
         
         if (op == null || opName == null || op.getName() == null
             || StringUtils.isEmpty(op.getName().getLocalPart())
@@ -84,9 +81,9 @@
         return md.getMethod(operation);
     }
        
-    private boolean requireCheckParameterName(Message message) {
-        // TODO add a configuration, if return false, then the parameter should be given
by order.
-        Boolean order = (Boolean) message.get("HTTP_GET_CHECK_PARAM_NAME");
+    private boolean isFixedParameterOrder(Message message) {
+        // Default value is false
+        Boolean order = (Boolean)message.get(Message.FIXED_PARAMETER_ORDER);        
         return order != null && order;
     }
     
@@ -129,13 +126,14 @@
 
         Map<String, String> queries = getQueries(message);
         
-        if (requireCheckParameterName(message)) {
-            boolean emptyQueries = CollectionUtils.isEmpty(queries.keySet());
+        if (!isFixedParameterOrder(message)) {
+            boolean emptyQueries = CollectionUtils.isEmpty(queries.values());           

+            
             List<String> names = ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo());
             queries = keepInOrder(queries, 
                                   operation.getOperationInfo(),
                                   names);
-            if (!emptyQueries && CollectionUtils.isEmpty(queries.keySet())) {
+            if (!emptyQueries && CollectionUtils.isEmpty(queries.values())) {   
        
                 throw new Fault(new org.apache.cxf.common.i18n.Message("ORDERED_PARAM_REQUIRED",

                                                                        BUNDLE, 
                                                                        names.toString()));

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorDocLitTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorDocLitTest.java?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorDocLitTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorDocLitTest.java
Fri Nov  3 00:47:09 2006
@@ -29,6 +29,7 @@
 import org.apache.cxf.calculator.CalculatorImpl;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.URIMappingInterceptor;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.message.Exchange;
@@ -79,49 +80,30 @@
     }
     
     public void testGetAddFromPath() throws Exception {
-        message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add/arg0/1/arg1/2");
+        message.put(Message.FIXED_PARAMETER_ORDER, Boolean.TRUE);
+        message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add/arg0/1/arg1/0");
         
         URIMappingInterceptor interceptor = new URIMappingInterceptor();
         interceptor.handleMessage(message);
         
         assertNull(message.getContent(Exception.class));
         
-        Object parameters = message.getContent(List.class);
-        assertNotNull(parameters);
-        assertEquals(2, ((List)parameters).size());
-         
-        Integer value = (Integer) ((List)parameters).get(0);
-        assertEquals(1, value.intValue());
-        
-        value = (Integer) ((List)parameters).get(1);        
-        assertEquals(2, value.intValue());
-        
-        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
-        assertNotNull(boi);
-        assertEquals(new QName(ns, "add"), boi.getName());
+        assertion();        
     }
     
     public void testGetAddFromQuery() throws Exception {
+        message.put(Message.FIXED_PARAMETER_ORDER, Boolean.TRUE);
         message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add");
-        message.put(Message.QUERY_STRING, "arg0=1&arg1=2");
+        message.put(Message.QUERY_STRING, "arg0=1&arg1=0");
         
         URIMappingInterceptor interceptor = new URIMappingInterceptor();
         interceptor.handleMessage(message);
         
         assertNull(message.getContent(Exception.class));
-        
-        Object parameters = message.getContent(List.class);
-        assertNotNull(parameters);
-        assertEquals(2, ((List)parameters).size());
-                 
-        Integer value = (Integer) ((List)parameters).get(0);
-        assertEquals(1, value.intValue());
-        value = (Integer) ((List)parameters).get(1);
-        assertEquals(2, value.intValue());
+        assertion();
     }
     
     public void testGetAddFromQueryOrdered() throws Exception {
-        message.put("HTTP_GET_CHECK_PARAM_NAME", Boolean.TRUE);
         message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add");
         message.put(Message.QUERY_STRING, "arg1=0&arg0=1");
         
@@ -129,8 +111,38 @@
         interceptor.handleMessage(message);
         
         assertNull(message.getContent(Exception.class));
+        assertion();
+    }
+    
+    public void testGetAddFromPathOrdered() throws Exception {
+        message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add/arg1/0/arg0/1");
+        
+        URIMappingInterceptor interceptor = new URIMappingInterceptor();
+        interceptor.handleMessage(message);
+        
+        assertNull(message.getContent(Exception.class));
+        assertion();
+    }    
+    
+    public void testGetAddFromQueryOrderedFault() throws Exception {        
+        message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add");
+        message.put(Message.QUERY_STRING, "one=1&two=2");
+        
+        URIMappingInterceptor interceptor = new URIMappingInterceptor();
+        try {
+            interceptor.handleMessage(message);
+        } catch (Exception e) {
+            assertTrue(e instanceof Fault);
+            assertEquals("Parameter should be ordered in the following sequence: [arg0, arg1]",

+                         e.getMessage());
+        }
         
         Object parameters = message.getContent(List.class);
+        assertNull(parameters);
+    }    
+    
+    private void assertion() throws Exception {
+        Object parameters = message.getContent(List.class);
         assertNotNull(parameters);
         assertEquals(2, ((List)parameters).size());
                  
@@ -138,21 +150,8 @@
         assertEquals(1, value.intValue());
         value = (Integer) ((List)parameters).get(1);
         assertEquals(0, value.intValue());
-    }
-    
-    public void testGetAddFromQueryOrderedNull() throws Exception {
-        message.put("HTTP_GET_CHECK_PARAM_NAME", Boolean.TRUE);
-        message.put(Message.PATH_INFO, "/CalculatorService/SoapPort/add");
-        message.put(Message.QUERY_STRING, "one=1&two=2");
-        
-        URIMappingInterceptor interceptor = new URIMappingInterceptor();
-        interceptor.handleMessage(message);
-        assertNull(message.getContent(Exception.class));
-        Object parameters = message.getContent(List.class);
-        assertNotNull(parameters);
-        assertEquals(2, ((List)parameters).size());        
-        
-        assertNull(((List)parameters).get(0));
-        assertNull(((List)parameters).get(1));        
+        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
+        assertNotNull(boi);
+        assertEquals(new QName(ns, "add"), boi.getName());
     }    
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java
Fri Nov  3 00:47:09 2006
@@ -28,6 +28,7 @@
 import org.apache.cxf.binding.soap.SoapBindingFactory;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.URIMappingInterceptor;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.message.Exchange;
@@ -94,7 +95,7 @@
     }
     
     public void testGetGreetMeFromPath() throws Exception {
-        message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe/me/king+author");
+        message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe/in/king+author");
         
         URIMappingInterceptor interceptor = new URIMappingInterceptor();        
         interceptor.handleMessage(message);
@@ -108,25 +109,56 @@
         assertEquals("king author", value);
     }
     
-    public void testGetSayHiFromQuery() throws Exception {
+    public void testGetSayHiFromQueryFixedOrder() throws Exception {
+        message.put(Message.FIXED_PARAMETER_ORDER, Boolean.TRUE);
         message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe");
-        message.put(Message.QUERY_STRING, "?me=king");
+        message.put(Message.QUERY_STRING, "me=king");
         
         URIMappingInterceptor interceptor = new URIMappingInterceptor();
         interceptor.handleMessage(message);
         
         assertNull(message.getContent(Exception.class));
         
+        assertion();
+    }
+    
+    public void testGetSayHiFromQueryRandomOrder() throws Exception {
+        message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe");
+        message.put(Message.QUERY_STRING, "in=king");
+        
+        URIMappingInterceptor interceptor = new URIMappingInterceptor();
+        interceptor.handleMessage(message);
+        
+        assertNull(message.getContent(Exception.class));        
+        assertion();
+    }
+    
+    public void testGetSayHiFromQueryRandomOrderFault() throws Exception {
+        message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe");
+        message.put(Message.QUERY_STRING, "me=king");
+        
+        URIMappingInterceptor interceptor = new URIMappingInterceptor();
+        try {
+            interceptor.handleMessage(message);
+        } catch (Exception e) {
+            assertTrue(e instanceof Fault);
+            assertEquals("Parameter should be ordered in the following sequence: [in]", e.getMessage());
+        }
+        Object parameters = message.getContent(List.class);
+        assertNull(parameters);
+    }
+    
+    private void assertion() throws Exception {
         Object parameters = message.getContent(List.class);
         assertNotNull(parameters);
         assertEquals(1, ((List)parameters).size());
         String value = (String) ((List)parameters).get(0);
-        assertEquals("king", value);
+        assertEquals("king", value);        
     }
     
     public void testGetSayHiFromQueryEncoded() throws Exception {
         message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe");
-        message.put(Message.QUERY_STRING, "?me=king+author");
+        message.put(Message.QUERY_STRING, "in=king+author");
         
         URIMappingInterceptor interceptor = new URIMappingInterceptor();
         interceptor.handleMessage(message);

Modified: incubator/cxf/trunk/rt/transports/http/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/pom.xml?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/pom.xml (original)
+++ incubator/cxf/trunk/rt/transports/http/pom.xml Fri Nov  3 00:47:09 2006
@@ -116,7 +116,8 @@
                                     <bindingFile>${basedir}/src/main/resources/schemas/wsdl/http-conf.xjb</bindingFile>
                                     <extension>true</extension>
                                     <extensionArgs>
-                                        <extensionArg>-Xcfg</extensionArg>
+                                        <extensionArg>-Xdv</extensionArg>
+                                        <extensionArg>-Xcfg</extensionArg>  
                                 
                                     </extensionArgs>
                                     <deleteDirs>
                                         <deleteDir>${basedir}/target/generated/src/main/java/org/apache/cxf/wsdl</deleteDir>

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Fri Nov  3 00:47:09 2006
@@ -214,8 +214,7 @@
     */
     }
 
-    boolean contextMatchOnStem() {
-        return "stem".equals(getContextMatchStrategy());
-    }
-    
+    boolean contextMatchOnExact() {
+        return "exact".equals(getContextMatchStrategy());
+    }    
 }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java
Fri Nov  3 00:47:09 2006
@@ -102,12 +102,11 @@
             LOG.info("registering incoming observer: " + observer);
             try {
                 URL url = new URL(getAddressValue());
-                if (contextMatchOnStem()) {
+                if (contextMatchOnExact()) {
                     engine.addServant(url, new AbstractHttpHandler() {
                         public void handle(String pathInContext, String pathParams, HttpRequest
req,
                                            HttpResponse resp) throws IOException {
-                            String name = getName();
-                            if (pathInContext.startsWith(name)) {
+                            if (pathInContext.equals(getName())) {
                                 doService(req, resp);
                             }
                         }
@@ -278,7 +277,8 @@
             if (!StringUtils.isEmpty(getAddressValue())) {
                 inMessage.put(Message.BASE_PATH, new URL(getAddressValue()).getPath());
             }
-
+            inMessage.put(Message.FIXED_PARAMETER_ORDER, isFixedParameterOrder());
+            
             setHeaders(inMessage);
 
             inMessage.setDestination(this);

Modified: incubator/cxf/trunk/rt/transports/http/src/main/resources/schemas/configuration/http-destination.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/resources/schemas/configuration/http-destination.xsd?view=diff&rev=470723&r1=470722&r2=470723
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/resources/schemas/configuration/http-destination.xsd
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/resources/schemas/configuration/http-destination.xsd
Fri Nov  3 00:47:09 2006
@@ -36,7 +36,8 @@
     <xs:element name="server" type="http-conf:HTTPServerPolicy"/>
     <xs:element name="authorization" type="sec:AuthorizationPolicy"/>
     <xs:element name="sslServer" type="sec:SSLServerPolicy"/>
-    <xs:element name="contextMatchStrategy" type="xs:string" default="exact"/>
+    <xs:element name="contextMatchStrategy" type="xs:string" default="stem"/>
+    <xs:element name="fixedParameterOrder" type="xs:boolean" default="false"/>
 
     <xs:complexType name="HTTPDestinationConfigBean">        
         <xs:annotation>
@@ -49,6 +50,7 @@
             <xs:element ref="tns:authorization" minOccurs="0"/>
             <xs:element ref="tns:sslServer" minOccurs="0"/>
             <xs:element ref="tns:contextMatchStrategy" minOccurs="0"/>
+            <xs:element ref="tns:fixedParameterOrder" minOccurs="0"/>
         </xs:sequence>
     </xs:complexType>
 



Mime
View raw message