You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2011/03/23 22:59:31 UTC

svn commit: r1084772 - in /tuscany/sca-java-2.x/trunk/modules/binding-ws: META-INF/MANIFEST.MF src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java

Author: rfeng
Date: Wed Mar 23 21:59:31 2011
New Revision: 1084772

URL: http://svn.apache.org/viewvc?rev=1084772&view=rev
Log:
Fix the string comparison to have constant as the 1st parameter to avoid NPE

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-ws/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws/META-INF/MANIFEST.MF?rev=1084772&r1=1084771&r2=1084772&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws/META-INF/MANIFEST.MF Wed Mar 23 21:59:31 2011
@@ -17,7 +17,8 @@ Bundle-Version: 2.0.0
 Bundle-ManifestVersion: 2
 Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
 Bundle-Description: Apache Tuscany SCA WS Binding Model
-Import-Package: javax.wsdl,
+Import-Package: javax.jws.soap,
+ javax.wsdl,
  javax.wsdl.extensions;version="1.6.2",
  javax.wsdl.extensions.soap;version="1.6.2",
  javax.wsdl.extensions.soap12;version="1.6.2",

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java?rev=1084772&r1=1084771&r2=1084772&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java Wed Mar 23 21:59:31 2011
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
 import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
 import javax.wsdl.Message;
@@ -90,7 +91,7 @@ class WebServiceBindingImpl implements W
      * Provide a meaningful representation of this Binding
      */
     public String toString() {
-    	return "Web Service Binding: " + name;
+        return "Web Service Binding: " + name;
     } // end method toString
 
     public String getName() {
@@ -250,7 +251,7 @@ class WebServiceBindingImpl implements W
         if (userSpecifiedWSDLDefinition == null) {
             Interface iface = bindingInterfaceContract.getInterface();
             if (iface instanceof WSDLInterface) {
-                userSpecifiedWSDLDefinition = ((WSDLInterface) iface).getWsdlDefinition();
+                userSpecifiedWSDLDefinition = ((WSDLInterface)iface).getWsdlDefinition();
             }
         }
         return userSpecifiedWSDLDefinition;
@@ -312,28 +313,28 @@ class WebServiceBindingImpl implements W
     public QName getType() {
         return TYPE;
     }
-    
+
     public WireFormat getRequestWireFormat() {
         return null;
     }
-    
-    public void setRequestWireFormat(WireFormat wireFormat) {  
+
+    public void setRequestWireFormat(WireFormat wireFormat) {
     }
-    
+
     public WireFormat getResponseWireFormat() {
         return null;
     }
-    
+
     public void setResponseWireFormat(WireFormat wireFormat) {
     }
-    
+
     public OperationSelector getOperationSelector() {
         return null;
     }
-    
+
     public void setOperationSelector(OperationSelector operationSelector) {
-    }   
-    
+    }
+
     /**
      * Some items get calculated and cached as they are used at runtime
      * to decide what message processing is required
@@ -343,55 +344,51 @@ class WebServiceBindingImpl implements W
         setIsLiteralEncoding();
         setIsMessageWrapped();
     }
-    
+
     protected void setIsDocumentStyle() {
-        
-        if (binding == null){
-            if (userSpecifiedWSDLDefinition != null && userSpecifiedWSDLDefinition.getDefinition() != null){
-                Message firstMessage = (Message)userSpecifiedWSDLDefinition.getDefinition().getMessages().values().iterator().next();
+
+        if (binding == null) {
+            if (userSpecifiedWSDLDefinition != null && userSpecifiedWSDLDefinition.getDefinition() != null) {
+                Message firstMessage =
+                    (Message)userSpecifiedWSDLDefinition.getDefinition().getMessages().values().iterator().next();
                 Part firstPart = (Part)firstMessage.getParts().values().iterator().next();
-                if (firstPart.getTypeName() != null){
+                if (firstPart.getTypeName() != null) {
                     isDocumentStyle = false;
                     return;
                 }
-            } 
-            
+            }
+
             // default to document style
             isDocumentStyle = true;
             return;
         } else {
-           for (Object ext : binding.getExtensibilityElements()){
-               if (ext instanceof SOAPBinding){
-                  if (((SOAPBinding)ext).getStyle().equals("rpc")){
-                      isDocumentStyle = false;
-                      return;
-                  } else {
-                      isDocumentStyle = true;
-                      return;
-                  }
-               }
-           }
-           isDocumentStyle = true;
-           return;
+            for (Object ext : binding.getExtensibilityElements()) {
+                if (ext instanceof SOAPBinding) {
+                    isDocumentStyle = !"rpc".equals(((SOAPBinding)ext).getStyle());
+                    return;
+                }
+            }
+            isDocumentStyle = true;
+            return;
         }
-        
+
     }
-    
+
     protected void setIsLiteralEncoding() {
-        
-        if (binding == null){
+
+        if (binding == null) {
             // default to literal encoding
             isLiteralEncoding = true;
             return;
         } else {
-            for(Object ext : ((BindingOperation)binding.getBindingOperations().get(0)).getBindingInput().getExtensibilityElements()){
-                if (ext instanceof SOAPBody){
-                    if (((SOAPBody)ext).getUse().equals("literal")){
-                        isLiteralEncoding = true;
-                        return;
-                    } else {
-                        isLiteralEncoding = false;
-                        return;
+            for (Object bop : binding.getBindingOperations()) {
+                BindingInput bindingInput = ((BindingOperation)bop).getBindingInput();
+                if (bindingInput != null) {
+                    for (Object ext : bindingInput.getExtensibilityElements()) {
+                        if (ext instanceof SOAPBody) {
+                            isLiteralEncoding = "literal".equals(((SOAPBody)ext).getUse());
+                            return;
+                        }
                     }
                 }
             }
@@ -399,62 +396,62 @@ class WebServiceBindingImpl implements W
             return;
         }
     }
-    
+
     protected void setIsMessageWrapped() {
-        if (getBindingInterfaceContract() != null){
+        if (getBindingInterfaceContract() != null) {
             isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isWrapperStyle();
         }
     }
-   
+
     public boolean isRpcEncoded() {
         return (!isDocumentStyle) && (!isLiteralEncoding);
     }
-    
+
     public boolean isRpcLiteral() {
         return (!isDocumentStyle) && (isLiteralEncoding);
     }
-    
+
     public boolean isDocEncoded() {
         return (isDocumentStyle) && (!isLiteralEncoding);
     }
-    
+
     public boolean isDocLiteralUnwrapped() {
         setIsMessageWrapped();
         return (isDocumentStyle) && (isLiteralEncoding) && (!isMessageWrapped);
     }
-    
+
     public boolean isDocLiteralWrapped() {
         setIsMessageWrapped();
-        return (isDocumentStyle) && (isLiteralEncoding) &&(isMessageWrapped);
+        return (isDocumentStyle) && (isLiteralEncoding) && (isMessageWrapped);
     }
-    
+
     public boolean isDocLiteralBare() {
         setIsMessageWrapped();
         return (isDocumentStyle) && (isLiteralEncoding);
-    }   
-    
+    }
+
     public boolean isHTTPTransport() {
         return getBindingTransport().equals("http://schemas.xmlsoap.org/soap/http");
     }
-    
+
     public boolean isJMSTransport() {
         return getBindingTransport().equals("http://schemas.xmlsoap.org/soap/jms");
     }
-    
+
     public String getBindingTransport() {
-        if (binding != null){
-            for (Object ext : binding.getExtensibilityElements()){
-                if (ext instanceof SOAPBinding){
+        if (binding != null) {
+            for (Object ext : binding.getExtensibilityElements()) {
+                if (ext instanceof SOAPBinding) {
                     return ((SOAPBinding)ext).getTransportURI();
                 }
             }
         }
-        
+
         // if no binding is explicitly specified by the user then default to http
         return "http://schemas.xmlsoap.org/soap/http";
     }
 
     public Map<String, String> getWsdliLocations() {
-        return wsdliLocations ;
+        return wsdliLocations;
     }
 }