axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barre...@apache.org
Subject svn commit: r550909 - in /webservices/axis2/trunk/java/modules/metadata: src/org/apache/axis2/jaxws/description/ src/org/apache/axis2/jaxws/description/impl/ test/org/apache/axis2/jaxws/description/
Date Tue, 26 Jun 2007 18:45:59 GMT
Author: barrettj
Date: Tue Jun 26 11:45:58 2007
New Revision: 550909

URL: http://svn.apache.org/viewvc?view=rev&rev=550909
Log:
Fix getSyncOperation logic to return the sync operation corresponding to a JAX-WS client async
method or null if one does not exist or can not be found.
Add associated test and comments on the interface for the OperationDescription method.

Added:
    webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/GetSyncOperationTests.java
Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java?view=diff&rev=550909&r1=550908&r2=550909
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java
Tue Jun 26 11:45:58 2007
@@ -190,5 +190,18 @@
 
     public void setOperationRuntimeDesc(OperationRuntimeDescription ord);
 
+    /**
+     * For JAX-WS client-side async operations, this will return the corresponding sync 
+     * OperationDescription.
+     * 
+     * Note that if this method is used within the metadata layer, it is possible that it
will return
+     * null.  That will happen if the metadata layer is constructed from annotations on the
SEI 
+     * (not WSDL).  In that case, it is possible that the async methods on the SEI are processed

+     * before the sync method.  In that case, there will be no sync method yet.  If this
method
+     * is called outside the metadata layer, then if the async methods exist, the sync method
+     * should also exist.  
+     * 
+     * @return OperationDescription corresponding to the sync operation, or null (see note
above).
+     */
     public OperationDescription getSyncOperation();
 }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?view=diff&rev=550909&r1=550908&r2=550909
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Tue Jun 26 11:45:58 2007
@@ -336,8 +336,8 @@
 
         } else if (composite.getWsdlDefinition() == null) {
             //This is a SOAP12 binding that does not contain a WSDL definition, log a WARNING
-            log.warn("This implementation does not contain a WSDL definition and uses a SOAP
1.2 based binding. " +
-                    "Per JAXWS spec. - a WSDL definition cannot be generated for this implementation.
Name: "
+            log.warn("This implementation does not contain a WSDL definition and is not a
SOAP 1.1 based binding. "
+                    + "Per JAXWS spec. - a WSDL definition cannot be generated for this implementation.
Name: "
                     + composite.getClassName());
         }
 

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?view=diff&rev=550909&r1=550908&r2=550909
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
Tue Jun 26 11:45:58 2007
@@ -162,7 +162,9 @@
     private Boolean webResultHeader;
     private Method serviceImplMethod;
     private boolean serviceImplMethodFound = false;
-    private OperationDescription syncOperationDescription;
+    // For JAX-WS client async methods, this is the corresponding Sync method; for everything
else,
+    // this is "this".
+    private OperationDescription syncOperationDescription = null;
     // RUNTIME INFORMATION
     Map<String, OperationRuntimeDescription> runtimeDescMap =
             Collections.synchronizedMap(new HashMap<String, OperationRuntimeDescription>());
@@ -727,37 +729,46 @@
         return webMethodOperationName;
     }
 
-    //Review:
-    //Adding method to get Sync operation's Operation Description
+    /* (non-Javadoc)
+     * @see org.apache.axis2.jaxws.description.OperationDescription#getSyncOperation()
+     */
     public OperationDescription getSyncOperation() {
-        OperationDescription opDesc = this;
-        if (!isJAXWSAsyncClientMethod()) {
-            return this;
-        }
-        if (this.syncOperationDescription != null) {
-            return syncOperationDescription;
-        }
-        String webMethodAnnoName = getOperationName();
-        String javaMethodName = getJavaMethodName();
-        if (webMethodAnnoName != null && webMethodAnnoName.length() > 0 &&
-                webMethodAnnoName != javaMethodName) {
-            EndpointInterfaceDescription eid = getEndpointInterfaceDescription();
-            if (eid != null) {
-                //searching for opDesc of sync operation.
-                OperationDescription[] ods = null;
-                ods = eid.getOperationForJavaMethod(webMethodAnnoName);
-                if (ods != null) {
-                    for (OperationDescription od : ods) {
-                        if (od.getJavaMethodName().equals(webMethodAnnoName)) {
-                            opDesc = od;
-                            break;
+
+        if (syncOperationDescription != null) {
+            // No need to do anything; the sync operation has already been set and will be
+            // returned below
+        } else if (!isJAXWSAsyncClientMethod()) {
+            // The current OpDesc is not an async operation.  Cache it, then return it below.
+            syncOperationDescription = this;
+        } else {
+            // We haven't found a sync opdesc for this operation yet, so try again.  See
the 
+            // comments in the interface declaration for this method on why this might occur.
+            OperationDescription opDesc = null;
+            
+            String webMethodAnnoName = getOperationName();
+            String javaMethodName = getJavaMethodName();
+            if (webMethodAnnoName != null && webMethodAnnoName.length() > 0 &&
+                    webMethodAnnoName != javaMethodName) {
+                EndpointInterfaceDescription eid = getEndpointInterfaceDescription();
+                if (eid != null) {
+                    //searching for opDesc of sync operation.
+                    OperationDescription[] ods = null;
+                    ods = eid.getOperationForJavaMethod(webMethodAnnoName);
+                    if (ods != null) {
+                        for (OperationDescription od : ods) {
+                            if (od.getJavaMethodName().equals(webMethodAnnoName)
+                                    && !od.isJAXWSAsyncClientMethod()) {
+                                opDesc = od;
+                                break;
+                            }
                         }
                     }
                 }
             }
+            // Note that opDesc might still be null
+            syncOperationDescription = opDesc;
         }
-        syncOperationDescription = opDesc;
-        return opDesc;
+        return syncOperationDescription;
     }
 
     public String getAction() {

Added: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/GetSyncOperationTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/GetSyncOperationTests.java?view=auto&rev=550909
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/GetSyncOperationTests.java
(added)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/GetSyncOperationTests.java
Tue Jun 26 11:45:58 2007
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.description;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import java.util.concurrent.Future;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ */
+public class GetSyncOperationTests extends TestCase {
+    
+    public void testNoSyncOperation() {
+        ServiceDescription sDesc = 
+            DescriptionFactory.createServiceDescription(null, 
+                                                        new QName("org.apache.axis2.jaxws.description",
"syncOperationTestService2"), 
+                                                        javax.xml.ws.Service.class);
+        EndpointDescription eDesc = 
+            DescriptionFactory.updateEndpoint(sDesc, 
+                                              AsyncOnlySEI.class, 
+                                              new QName("org.apache.axis2.jaxws.description",
"syncOperationTestPort2"), 
+                                              DescriptionFactory.UpdateType.GET_PORT);
+        EndpointInterfaceDescription eiDesc = eDesc.getEndpointInterfaceDescription();
+        OperationDescription opDescs[] = eiDesc.getOperations();
+        assertNotNull(opDescs);
+        assertEquals(2, opDescs.length);
+        // Make sure each of the async operations reference the sync opDesc
+        int asyncOperations = 0;
+        OperationDescription syncOpDescs[] = eiDesc.getOperationForJavaMethod("echo");
+        assertNull(syncOpDescs);
+        for (OperationDescription opDesc : opDescs) {
+            if (opDesc.isJAXWSAsyncClientMethod()) {
+                asyncOperations++;
+            }
+            // Since there isn't a sync method in the (invalid) SEI, then this should return
null
+            assertNull(opDesc.getSyncOperation());
+        }
+        assertEquals(2, asyncOperations);
+    }
+
+    public void testSyncOperation() {
+        ServiceDescription sDesc = 
+            DescriptionFactory.createServiceDescription(null, 
+                                                        new QName("org.apache.axis2.jaxws.description",
"syncOperationTestService1"), 
+                                                        javax.xml.ws.Service.class);
+        EndpointDescription eDesc = 
+            DescriptionFactory.updateEndpoint(sDesc, 
+                                              SyncAndAsyncSEI.class, 
+                                              new QName("org.apache.axis2.jaxws.description",
"syncOperationTestPort1"), 
+                                              DescriptionFactory.UpdateType.GET_PORT);
+        EndpointInterfaceDescription eiDesc = eDesc.getEndpointInterfaceDescription();
+        OperationDescription opDescs[] = eiDesc.getOperations();
+        assertNotNull(opDescs);
+        assertEquals(3, opDescs.length);
+        // Make sure each of the async operations reference the sync opDesc
+        int asyncOperations = 0;
+        OperationDescription syncOpDescs[] = eiDesc.getOperationForJavaMethod("echo");
+        assertNotNull(syncOpDescs);
+        assertEquals(1, syncOpDescs.length);
+        OperationDescription syncOpDesc = syncOpDescs[0];
+
+        for (OperationDescription opDesc : opDescs) {
+            if (opDesc.isJAXWSAsyncClientMethod()) {
+                asyncOperations++;
+            }
+            // Make sure all the operations point to the sync operation
+            assertEquals(syncOpDesc, opDesc.getSyncOperation());
+        }
+        
+        assertEquals(2, asyncOperations);
+    }
+
+
+}
+
+@WebService
+interface AsyncOnlySEI {
+    // Note this is an INVALID SEI since it only contains the
+    // JAXWS client async methods, and not the corresponding sync 
+    // method.
+    @WebMethod(operationName = "echo")
+    public Response<String> echoAsync(String toEcho);
+    @WebMethod(operationName = "echo")
+    public Future<?> echoAsync(String toEcho, AsyncHandler<String> asyncHandler);
+}
+
+@WebService
+interface SyncAndAsyncSEI {
+    @WebMethod(operationName = "echo")
+    public Response<String> echoAsync(String toEcho);
+    @WebMethod(operationName = "echo")
+    public Future<?> echoAsync(String toEcho, AsyncHandler<String> asyncHandler);
+    @WebMethod(operationName = "echo")
+    public String echo(String toEcho);
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message