cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1150822 - in /cxf/trunk/tools/wsdlto/frontend/jaxws/src: main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/annotator/ test/java/org/apache/cxf/t...
Date Mon, 25 Jul 2011 18:20:42 GMT
Author: dkulp
Date: Mon Jul 25 18:20:40 2011
New Revision: 1150822

URL: http://svn.apache.org/viewvc?rev=1150822&view=rev
Log:
[CXF-3684] Move @WebParam(header=true) processing for out-of-band
headers into the ParameterProcessor which actually knows that it's
out-of-band and can force the header=true flag there.

Modified:
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/annotator/WebParamAnnotator.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessorTest.java

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java?rev=1150822&r1=1150821&r2=1150822&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
Mon Jul 25 18:20:40 2011
@@ -103,14 +103,16 @@ public class ParameterProcessor extends 
                                                  MessagePartInfo part,
                                                  JavaType.Style style)
         throws ToolException {
-        return addParameter(method, getParameterFromPart(method, part, style));
+        return addParameter(part, method, getParameterFromPart(method, part, style));
     }
 
     private JavaParameter getParameterFromPart(JavaMethod jm, MessagePartInfo part, JavaType.Style
style) {
         return ParameterMapper.map(jm, part, style, context);
     }
 
-    protected JavaParameter addParameter(JavaMethod method, JavaParameter parameter) throws
ToolException {
+    protected JavaParameter addParameter(MessagePartInfo mpart,
+                                         JavaMethod method,
+                                         JavaParameter parameter) throws ToolException {
         if (parameter == null) {
             return null;
         }
@@ -123,7 +125,7 @@ public class ParameterProcessor extends 
         }
         
         parameter.setMethod(method);
-        parameter.annotate(new WebParamAnnotator());
+        parameter.annotate(new WebParamAnnotator(isOutOfBandHeader(mpart)));
         method.addParameter(parameter);
 
         return parameter;
@@ -171,6 +173,9 @@ public class ParameterProcessor extends 
     }
 
     private boolean isOutOfBandHeader(final MessagePartInfo part) {
+        if (part == null) {
+            return false;
+        }
         return Boolean.TRUE.equals(part.getProperty(OUT_OF_BAND_HEADER));
     }
 
@@ -219,7 +224,7 @@ public class ParameterProcessor extends 
                     }
                 }
             }
-            addParameter(method, param);
+            addParameter(part, method, param);
         }
     }
 
@@ -249,7 +254,7 @@ public class ParameterProcessor extends 
                 jp.setTargetNamespace("");
             }
 
-            addParameter(method, jp);
+            addParameter(part, method, jp);
         }
 
         // Adding out of band headers
@@ -258,7 +263,7 @@ public class ParameterProcessor extends 
                 if (!isOutOfBandHeader(hpart)) {
                     continue;
                 }
-                addParameter(method, getParameterFromPart(method, hpart, JavaType.Style.IN));
+                addParameter(hpart, method, getParameterFromPart(method, hpart, JavaType.Style.IN));
             }
         }
     }
@@ -303,12 +308,13 @@ public class ParameterProcessor extends 
                             p.setClassName(holderClass);
                             p.getAnnotations().clear();
                             p.setStyle(JavaType.Style.INOUT);
-                            p.annotate(new WebParamAnnotator());
+                            p.annotate(new WebParamAnnotator(isOutOfBandHeader(outpart)));
                             found = true;
                         }
                     }
                     if (!found) {
-                        addParameter(method, getParameterFromPart(method, outpart, JavaType.Style.INOUT));
+                        addParameter(outpart, method,
+                                     getParameterFromPart(method, outpart, JavaType.Style.INOUT));
                     }
                     continue;
                 } else if (!isSamePart(inpart, outpart)) {
@@ -341,7 +347,7 @@ public class ParameterProcessor extends 
                     }
                 }
 
-                addParameter(method, param);
+                addParameter(part, method, param);
             }
         } else {
             processReturn(method, null);
@@ -360,7 +366,7 @@ public class ParameterProcessor extends 
                 if (!isOutOfBandHeader(hpart) || !requireOutOfBandHeader()) {
                     continue;
                 }
-                addParameter(method, getParameterFromPart(method, hpart, JavaType.Style.OUT));
+                addParameter(hpart, method, getParameterFromPart(method, hpart, JavaType.Style.OUT));
             }
         }
     }
@@ -422,7 +428,7 @@ public class ParameterProcessor extends 
                     if (!jpIn.getClassName().equals(jp.getClassName())) {
                         jp.setStyle(JavaType.Style.OUT);
                     } 
-                    addParameter(method, jp);
+                    addParameter(outputPart, method, jp);
                     sameWrapperChild = true;
 
                     if (method.getReturn() == null) {
@@ -476,7 +482,7 @@ public class ParameterProcessor extends 
                             checkPartName(outputMessage, outElement, jp);
                         }
 
-                        addParameter(method, jp);
+                        addParameter(outputPart, method, jp);
                         sameWrapperChild = true;
                         break;
                     }
@@ -490,7 +496,7 @@ public class ParameterProcessor extends 
                 }
                 checkPartName(outputMessage, outElement, jp);
     
-                addParameter(method, jp);
+                addParameter(outputPart, method, jp);
             }
         }
         if (method.getReturn() == null) {
@@ -727,17 +733,17 @@ public class ParameterProcessor extends 
                 style = JavaType.Style.INOUT;
             }
             if (part != null) {
-                addParameter(method, getParameterFromPart(method, part, style));
+                addParameter(part, method, getParameterFromPart(method, part, style));
             }
             index++;
         }
         // now from unlisted input parts
         for (MessagePartInfo part : inputUnlistedParts) {
-            addParameter(method, getParameterFromPart(method, part, JavaType.Style.IN));
+            addParameter(part, method, getParameterFromPart(method, part, JavaType.Style.IN));
         }
         // now from unlisted output parts
         for (MessagePartInfo part : outputUnlistedParts) {
-            addParameter(method, getParameterFromPart(method, part, JavaType.Style.INOUT));
+            addParameter(part, method, getParameterFromPart(method, part, JavaType.Style.INOUT));
         }
     }
 

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java?rev=1150822&r1=1150821&r2=1150822&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
Mon Jul 25 18:20:40 2011
@@ -39,6 +39,7 @@ import org.w3c.dom.Element;
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.MessageInfo;
@@ -473,6 +474,9 @@ public class ServiceProcessor extends Ab
             for (ExtensibilityElement ext : outbindings) {
                 if (SOAPBindingUtil.isSOAPHeader(ext)) {
                     SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
+                    if (isOutOfBandHeader(operation.getOutput(), ext)) {
+                        continue;
+                    }
                     boolean found = false;
                     for (JavaParameter parameter : jm.getParameters()) {
                         if (soapHeader.getPart().equals(parameter.getPartName())) {
@@ -518,7 +522,19 @@ public class ServiceProcessor extends Ab
         }
     }
 
+    private boolean isOutOfBandHeader(BindingMessageInfo bmi, ExtensibilityElement ext) {
+        SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
+        if (soapHeader.getMessage() != null
+            && !bmi.getMessageInfo().getName().equals(soapHeader.getMessage())) {
+            return true;
+        }
+        return false;
+    }
+
     private void processSoapHeader(JavaMethod jm, BindingOperationInfo operation, ExtensibilityElement
ext) {
+        if (isOutOfBandHeader(operation.getInput(), ext)) {
+            return;
+        }
         SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
         for (JavaParameter parameter : jm.getParameters()) {
             if (soapHeader.getPart().equals(parameter.getPartName())) {

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/annotator/WebParamAnnotator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/annotator/WebParamAnnotator.java?rev=1150822&r1=1150821&r2=1150822&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/annotator/WebParamAnnotator.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/annotator/WebParamAnnotator.java
Mon Jul 25 18:20:40 2011
@@ -31,6 +31,14 @@ import org.apache.cxf.tools.common.model
 import org.apache.cxf.tools.common.model.JavaType;
 
 public class WebParamAnnotator implements Annotator {
+    boolean forceHeader;
+    
+    public WebParamAnnotator() {
+    }
+    public WebParamAnnotator(boolean head) {
+        forceHeader = head;
+    }
+    
     public void annotate(JavaAnnotatable ja) {
         JavaParameter parameter = null;
         if (ja instanceof JavaParameter) {
@@ -86,6 +94,10 @@ public class WebParamAnnotator implement
         for (String importClz : webParamAnnotation.getImports()) {
             parameter.getMethod().getInterface().addImport(importClz);
         }
+        
+        if (forceHeader) {
+            webParamAnnotation.addElement(new JAnnotationElement("header", true, true));
+        }
         parameter.addAnnotation("WebParam", webParamAnnotation);
     }
 }

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessorTest.java?rev=1150822&r1=1150821&r2=1150822&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessorTest.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessorTest.java
Mon Jul 25 18:20:40 2011
@@ -34,11 +34,11 @@ public class ParameterProcessorTest exte
         JavaMethod method = new JavaMethod();
         JavaParameter p1 = new JavaParameter("request", String.class.getName(), null);
         p1.setStyle(JavaType.Style.IN);
-        processor.addParameter(method, p1);
+        processor.addParameter(null, method, p1);
 
         JavaParameter p2 = new JavaParameter("request", String.class.getName(), null);
         p2.setStyle(JavaType.Style.OUT);
-        processor.addParameter(method, p2);
+        processor.addParameter(null, method, p2);
 
         assertEquals(1, method.getParameters().size());
         assertEquals(JavaType.Style.INOUT, method.getParameters().get(0).getStyle());



Mime
View raw message