You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ba...@apache.org on 2006/10/07 23:25:57 UTC

svn commit: r454026 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/description/ test/org/apache/axis2/jaxws/description/ test/org/apache/axis2/jaxws/framework/

Author: barrettj
Date: Sat Oct  7 14:25:56 2006
New Revision: 454026

URL: http://svn.apache.org/viewvc?view=rev&rev=454026
Log:
Additional JAXWS default processing for annotations

Added:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java?view=diff&rev=454026&r1=454025&r2=454026
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java Sat Oct  7 14:25:56 2006
@@ -22,6 +22,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 import javax.jws.WebService;
 import javax.wsdl.Definition;
@@ -123,7 +124,7 @@
     private String              annotation_ServiceName;
     private String              annotation_PortName;
     private String              annotation_TargetNamespace;
-    // Information only set on WebService annotation
+    // ANNOTATION: @WebService
     private String              webService_EndpointInterface;
     private String              webService_Name;
 
@@ -277,7 +278,7 @@
         if (webServiceAnnotation != null) {
             // If this impl class references an SEI, then use that SEI to create the EndpointInterfaceDesc.
             // TODO: Add support for service impl endpoints that don't reference an SEI; remember that this is also called with just an SEI interface from svcDesc.updateWithSEI()
-            String seiClassName = getEndpointInterface();
+            String seiClassName = getWebServiceEndpointInterface();
             Class seiClass = null;
             if (DescriptionUtils.isEmpty(seiClassName)) {
                 // For now, just build the EndpointInterfaceDesc based on the class itself.
@@ -302,8 +303,8 @@
         if (portQName == null) {
             // The name was not set by the constructors, so get it from the
             // appropriate annotaion.
-            String name = getPortName();
-            String tns = getTargetNamespace();
+            String name = getWebServicePortName();
+            String tns = getWebServiceTargetNamespace();
             // TODO: Check for name &/| tns null or empty string and add tests for same
             portQName = new QName(tns, name);
         }
@@ -351,166 +352,6 @@
         }
         return;
     }
-
-
-    // ==========================================
-    // Annotation-related methods
-    // ==========================================
-    
-    public boolean isProviderBased() {
-        return webServiceProviderAnnotation != null;
-    }
-    
-    public boolean isEndpointBased() {
-        return webServiceAnnotation != null;
-    }
-    
-    // ------------------------------------------
-    // Common WebService and WebServiceProvider annotation-related getters
-    // ------------------------------------------
-    
-    public String getWSDLLocation() {
-        if (annotation_WsdlLocation == null) {
-            if (webServiceAnnotation != null) {
-                annotation_WsdlLocation = webServiceAnnotation.wsdlLocation();
-            }
-            else if (webServiceProviderAnnotation != null) {
-                annotation_WsdlLocation = webServiceProviderAnnotation.wsdlLocation();
-            }
-        }
-        return annotation_WsdlLocation;
-    }
-
-    public String getServiceName() {
-        if (annotation_ServiceName == null) {
-            if (webServiceAnnotation != null) {
-                annotation_ServiceName = webServiceAnnotation.serviceName();
-            }
-            else if (webServiceProviderAnnotation != null) {
-                annotation_ServiceName = webServiceProviderAnnotation.serviceName();
-            }
-        }
-        return annotation_ServiceName;
-    }
-    
-    public String getPortName() {
-        if (annotation_PortName == null) {
-            if (webServiceAnnotation != null) {
-                // REVIEW: Should this be portName() or just name()?
-                annotation_PortName = webServiceAnnotation.portName();
-            }
-            else if (webServiceProviderAnnotation != null) {
-                annotation_PortName = webServiceProviderAnnotation.portName();
-            }
-        }
-        return annotation_PortName;
-    }
-
-    public String getTargetNamespace() {
-        if (annotation_TargetNamespace == null) {
-            if (webServiceAnnotation != null) {
-                annotation_TargetNamespace = webServiceAnnotation.targetNamespace();
-            }
-            else if (webServiceProviderAnnotation != null) {
-                annotation_TargetNamespace = webServiceProviderAnnotation.targetNamespace();
-            }
-        }
-        return annotation_TargetNamespace;
-    }
-    // ------------------------------------------
-    // WebServiceProvider annotation related getters
-    // ------------------------------------------
-
-    WebServiceProvider getWebServiceProviderAnnotation() {
-        return webServiceProviderAnnotation;
-    }
-
-    // ------------------------------------------
-    // WebService annotation related getters
-    // ------------------------------------------
-
-    WebService getWebServiceAnnotation() {
-        return webServiceAnnotation;
-    }
-    
-    public String getEndpointInterface() {
-        if (webService_EndpointInterface == null && webServiceAnnotation != null) {
-            webService_EndpointInterface = webServiceAnnotation.endpointInterface();
-        }
-        return webService_EndpointInterface;
-    }
-    
-    public String getName() {
-        if (webService_Name == null && webServiceAnnotation != null) {
-            webService_Name = webServiceAnnotation.name();
-        }
-        return webService_Name;
-    }
-    
-    // ------------------------------------------
-    // ServiceMode annotation related getters
-    // ------------------------------------------
-    // REVIEW: Should this be returning an enum other than the one defined within the annotation?
-    ServiceMode getServiceMode() {
-        if (serviceModeAnnotation == null && implOrSEIClass != null) {
-            serviceModeAnnotation = (ServiceMode) implOrSEIClass.getAnnotation(ServiceMode.class);
-        }
-        return serviceModeAnnotation;
-    }
-    
-    public Service.Mode getServiceModeValue() {
-        // This annotation is only valid on Provider-based endpoints. 
-        if (isProviderBased() && serviceModeValue == null) {
-            if (getServiceMode() != null) {
-                serviceModeValue = getServiceMode().value();
-            }
-            else {
-                serviceModeValue = ServiceMode_DEFAULT; 
-            }
-        }
-        return serviceModeValue;
-    }
-    
-    // ------------------------------------------
-    // BindingType annotation related getters
-    // ------------------------------------------
-
-    BindingType getBindingType() {
-        if (bindingTypeAnnotation == null && implOrSEIClass != null) {
-            bindingTypeAnnotation = (BindingType) implOrSEIClass.getAnnotation(BindingType.class);
-        }
-        return bindingTypeAnnotation;
-    }
-    
-    public String getBindingTypeValue() {
-        if (bindingTypeValue == null) {
-            if (getBindingType() != null) {
-                bindingTypeValue = getBindingType().value();
-            }
-            else {
-                // No BindingType annotation present; use default value
-                bindingTypeValue = BindingType_DEFAULT;
-            }
-        }
-        return bindingTypeValue;
-    }
-
-    // ------------------------------------------
-    // HandlerChaing annotation related getters
-    // ------------------------------------------
-
-    /**
-     * Returns a live list describing the handlers on this port.
-     * TODO: This is currently returning List<String>, but it should return a HandlerDescritpion
-     * object that can represent a handler description from various Metadata (annotation, deployment descriptors, etc);
-     * use JAX-WS Appendix B Handler Chain Configuration File Schema as a starting point for HandlerDescription.
-     *  
-     * @return A List of handlers for this port.  The actual list is returned, and therefore can be modified.
-     */
-    public List<String> getHandlerList() {
-        return handlerList;
-    }
-    
     private void setupAxisService() {
         // TODO: Need to use MetaDataQuery validator to merge WSDL (if any) and annotations (if any)
         // Build up the AxisService.  Note that if this is a dynamic port, then we don't use the
@@ -674,4 +515,300 @@
         return getServiceDescription().getServiceQName().getLocalPart() + "." + portName;
     }
 
+    public boolean isProviderBased() {
+        return webServiceProviderAnnotation != null;
+    }
+    
+    public boolean isEndpointBased() {
+        return webServiceAnnotation != null;
+    }
+
+    // ===========================================
+    // ANNOTATION: WebService and WebServiceProvider
+    // ===========================================
+    
+    public String getWebServiceWSDLLocation() {
+        if (annotation_WsdlLocation == null) {
+            if (getWebServiceAnnotation() != null 
+                    && !DescriptionUtils.isEmpty(getWebServiceAnnotation().wsdlLocation())) {
+                annotation_WsdlLocation = getWebServiceAnnotation().wsdlLocation();
+            }
+            else if (getWebServiceProviderAnnotation() != null 
+                    && !DescriptionUtils.isEmpty(getWebServiceProviderAnnotation().wsdlLocation())) {
+                annotation_WsdlLocation = getWebServiceProviderAnnotation().wsdlLocation();
+            }
+            else {
+                // There is no default value per JSR-181 MR Sec 4.1 pg 16
+                annotation_WsdlLocation = "";
+            }
+        }
+        return annotation_WsdlLocation;
+    }
+
+    public String getWebServiceServiceName() {
+        if (annotation_ServiceName == null) {
+            if (getWebServiceAnnotation() != null 
+                    && !DescriptionUtils.isEmpty(getWebServiceAnnotation().serviceName())) {
+                annotation_ServiceName = getWebServiceAnnotation().serviceName();
+            }
+            else if (getWebServiceProviderAnnotation() != null 
+                    && !DescriptionUtils.isEmpty(getWebServiceProviderAnnotation().serviceName())) {
+                annotation_ServiceName = getWebServiceProviderAnnotation().serviceName();
+            }
+            else {
+                // Default value is the "simple name" of the class or interface + "Service"
+                // Per JSR-181 MR Sec 4.1, pg 15
+                annotation_ServiceName = getSimpleJavaClassName(implOrSEIClass) + "Service";
+            }
+        }
+        return annotation_ServiceName;
+    }
+    
+    public String getWebServicePortName() {
+        if (annotation_PortName == null) {
+            if (getWebServiceAnnotation() != null
+                    && !DescriptionUtils.isEmpty(getWebServiceAnnotation().portName())) {
+                annotation_PortName = getWebServiceAnnotation().portName();
+            }
+            else if (getWebServiceProviderAnnotation() != null
+                    && !DescriptionUtils.isEmpty(getWebServiceProviderAnnotation().portName())) {
+                annotation_PortName = getWebServiceProviderAnnotation().portName();
+            }
+            else {
+                // Default the value
+                if (isProviderBased()) {
+                    // This is the @WebServiceProvider annotation path
+                    // Default value is not specified in JSR-224, but we can assume it is 
+                    // similar to the default in the WebService case, however there is no
+                    // name attribute for a WebServiceProvider.  So in this case we use 
+                    // the default value for WebService.name per JSR-181 MR sec 4.1 pg 15.
+                    // Note that this is really the same thing as the call to getWebServiceName() 
+                    // in the WebService case; it is done sepertely just to be clear there is no 
+                    // name element on the WebServiceProvider annotation
+                    annotation_PortName = getSimpleJavaClassName(implOrSEIClass) + "Port";
+                }
+                else {
+                    // This is the @WebService annotation path
+                    // Default value is the @WebService.name of the class or interface + "Port"
+                    // Per JSR-181 MR Sec 4.1, pg 15
+                    annotation_PortName = getWebServiceName() + "Port";
+                }
+            }
+        }
+        return annotation_PortName;
+    }
+
+    public String getWebServiceTargetNamespace() {
+        if (annotation_TargetNamespace == null) {
+            if (getWebServiceAnnotation() != null 
+                    && !DescriptionUtils.isEmpty(getWebServiceAnnotation().targetNamespace())) {
+                annotation_TargetNamespace = getWebServiceAnnotation().targetNamespace();
+            }
+            else if (getWebServiceProviderAnnotation() != null
+                    && !DescriptionUtils.isEmpty(getWebServiceProviderAnnotation().targetNamespace())) {
+                annotation_TargetNamespace = getWebServiceProviderAnnotation().targetNamespace();
+            }
+            else {
+                // Default value per JSR-181 MR Sec 4.1 pg 15 defers to "Implementation defined, 
+                // as described in JAX-WS 2.0, section 3.2" which is JAX-WS 2.0 Sec 3.2, pg 29.
+                // FIXME: Hardcoded protocol for namespace
+                annotation_TargetNamespace = makeNamespaceFromPackageName(getJavaPackageName(implOrSEIClass), "http");
+            }
+        }
+        return annotation_TargetNamespace;
+    }
+    
+    
+    /**
+     * Return the name of the class without any package qualifier.
+     * @param theClass
+     * @return the name of the class sans package qualification.
+     */
+    private static String getSimpleJavaClassName(Class theClass) {
+        String returnName = null;
+        if (theClass != null) {
+            String fqName = theClass.getName();
+            // We need the "simple name", so strip off any package information from the name
+            int endOfPackageIndex = fqName.lastIndexOf('.');
+            int startOfClassIndex = endOfPackageIndex + 1;
+            returnName = fqName.substring(startOfClassIndex);
+        }
+        else {
+            // TODO: RAS and NLS
+            throw new UnsupportedOperationException("Java class is null");
+        }
+        return returnName;
+    }
+    /**
+     * Returns the package name from the class.  If no package, then returns null
+     * @param theClass
+     * @return
+     */
+    private static String getJavaPackageName(Class theClass) {
+        String returnPackage = null;
+        if (theClass != null) {
+            String fqName = theClass.getName();
+            // Get the package name, if there is one
+            int endOfPackageIndex = fqName.lastIndexOf('.');
+            if (endOfPackageIndex >= 0) {
+                returnPackage = fqName.substring(0, endOfPackageIndex);
+            }
+        }
+        else {
+            // TODO: RAS and NLS
+            throw new UnsupportedOperationException("Java class is null");
+        }
+        return returnPackage;
+    }
+    
+    /**
+     * Create a JAX-WS namespace based on the package name
+     * @param packageName
+     * @param protocol
+     * @return
+     */
+    private static final String NO_PACKAGE_HOST_NAME = "DefaultNamespace";
+
+    private static String makeNamespaceFromPackageName(String packageName, String protocol) {
+        if (DescriptionUtils.isEmpty(protocol)) {
+            protocol = "http";
+        }
+        if (DescriptionUtils.isEmpty(packageName)) {
+            return protocol + "://" + NO_PACKAGE_HOST_NAME;
+        }
+        StringTokenizer st = new StringTokenizer( packageName, "." );
+        String[] words = new String[ st.countTokens() ];
+        for(int i = 0; i < words.length; ++i)
+            words[i] = st.nextToken();
+
+        StringBuffer sb = new StringBuffer(80);
+        for(int i = words.length-1; i >= 0; --i) {
+            String word = words[i];
+            // seperate with dot
+            if( i != words.length-1 )
+                sb.append('.');
+            sb.append( word );
+        }
+        return protocol + "://" + sb.toString() + "/";
+    }
+
+    // ===========================================
+    // ANNOTATION: WebServiceProvider
+    // ===========================================
+
+    WebServiceProvider getWebServiceProviderAnnotation() {
+        return webServiceProviderAnnotation;
+    }
+
+    // ===========================================
+    // ANNOTATION: WebService
+    // ===========================================
+
+    WebService getWebServiceAnnotation() {
+        return webServiceAnnotation;
+    }
+    
+    public String getWebServiceEndpointInterface() {
+        // TODO: Validation: Not allowed on WebServiceProvider
+        if (webService_EndpointInterface == null) {
+            if (!isProviderBased() && getWebServiceAnnotation() != null
+                    && !DescriptionUtils.isEmpty(getWebServiceAnnotation().endpointInterface())) {
+                webService_EndpointInterface = getWebServiceAnnotation().endpointInterface();
+            }
+            else {
+                // This element is not valid on a WebServiceProvider annotation
+                // REVIEW: Is this a correct thing to return if this is called against a WebServiceProvier
+                //         which does not support this element?
+                webService_EndpointInterface = "";
+            }
+        }
+        return webService_EndpointInterface;
+    }
+    
+    public String getWebServiceName() {
+        // TODO: Validation: Not allowed on WebServiceProvider
+        if (webService_Name == null) {
+            if (!isProviderBased()) {
+                if (getWebServiceAnnotation() != null 
+                        && !DescriptionUtils.isEmpty(getWebServiceAnnotation().name())) {
+                    webService_Name = getWebServiceAnnotation().name();
+                }
+                else {
+                    // Default per JSR-181 Sec 4.1, pg 15
+                    webService_Name = getSimpleJavaClassName(implOrSEIClass);
+                }
+            }
+            else {
+                // This element is not valid on a WebServiceProvider annotation
+                // REVIEW: Is this a correct thing to return if this is called against a WebServiceProvier
+                //         which does not support this element?
+                webService_Name = "";
+            }
+        }
+        return webService_Name;
+    }
+    
+    // ===========================================
+    // ANNOTATION: ServiceMode
+    // ===========================================
+    // REVIEW: Should this be returning an enum other than the one defined within the annotation?
+    ServiceMode getServiceMode() {
+        if (serviceModeAnnotation == null && implOrSEIClass != null) {
+            serviceModeAnnotation = (ServiceMode) implOrSEIClass.getAnnotation(ServiceMode.class);
+        }
+        return serviceModeAnnotation;
+    }
+    
+    public Service.Mode getServiceModeValue() {
+        // This annotation is only valid on Provider-based endpoints. 
+        if (isProviderBased() && serviceModeValue == null) {
+            if (getServiceMode() != null) {
+                serviceModeValue = getServiceMode().value();
+            }
+            else {
+                serviceModeValue = ServiceMode_DEFAULT; 
+            }
+        }
+        return serviceModeValue;
+    }
+    
+    // ===========================================
+    // ANNOTATION: BindingType
+    // ===========================================
+
+    BindingType getBindingType() {
+        if (bindingTypeAnnotation == null && implOrSEIClass != null) {
+            bindingTypeAnnotation = (BindingType) implOrSEIClass.getAnnotation(BindingType.class);
+        }
+        return bindingTypeAnnotation;
+    }
+    
+    public String getBindingTypeValue() {
+        if (bindingTypeValue == null) {
+            if (getBindingType() != null) {
+                bindingTypeValue = getBindingType().value();
+            }
+            else {
+                // No BindingType annotation present; use default value
+                bindingTypeValue = BindingType_DEFAULT;
+            }
+        }
+        return bindingTypeValue;
+    }
+
+    // ===========================================
+    // ANNOTATION: HandlerChain
+    // ===========================================
+
+    /**
+     * Returns a live list describing the handlers on this port.
+     * TODO: This is currently returning List<String>, but it should return a HandlerDescritpion
+     * object that can represent a handler description from various Metadata (annotation, deployment descriptors, etc);
+     * use JAX-WS Appendix B Handler Chain Configuration File Schema as a starting point for HandlerDescription.
+     *  
+     * @return A List of handlers for this port.  The actual list is returned, and therefore can be modified.
+     */
+    public List<String> getHandlerList() {
+        return handlerList;
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java?view=diff&rev=454026&r1=454025&r2=454026
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java Sat Oct  7 14:25:56 2006
@@ -134,6 +134,12 @@
     // ANNOTATION: @WebMethod
     private WebMethod           webMethodAnnotation;
     private String              webMethodOperationName;
+    // Default value per JSR-181 MR Sec 4.2, pg 17
+    public static final String  WebMethod_Action_DEFAULT = "";
+    private String              webMethodAction;
+    // Default value per JSR-181 MR sec 4.2, pg 17
+    public static final Boolean WebMethod_Exclude_DEFAULT = new Boolean(false);
+    private Boolean             webMethodExclude;
     
     // ANNOTATION: @WebParam
     // TODO: Should WebParam annotation be moved to the ParameterDescription?
@@ -248,6 +254,35 @@
         return webMethodOperationName;
     }
     
+    public String getWebMethodAction() {
+        if (webMethodAction == null) {
+            if (getWebMethod() != null && !DescriptionUtils.isEmpty(getWebMethod().action())) {
+                webMethodAction = getWebMethod().action();
+            }
+            else {
+                webMethodAction = WebMethod_Action_DEFAULT;
+            }
+        }
+        return webMethodAction;
+    }
+    
+    public boolean getWebMethodExclude() {
+        if (webMethodExclude == null) {
+            // TODO: Validation: if this attribute specified, no other elements allowed per JSR-181 MR Sec 4.2, pg 17
+            // TODO: Validation: This element is not allowed on endpoint interfaces
+            // Unlike the elements with a String value, if the annotation is present, exclude will always 
+            // return a usable value since it will default to FALSE if the element is not present.
+            if (getWebMethod() != null) {
+                webMethodExclude = new Boolean(getWebMethod().exclude());
+            }
+            else {
+                webMethodExclude = WebMethod_Exclude_DEFAULT;
+            }
+        }
+        
+        return webMethodExclude.booleanValue();
+    }
+    
     // ==========================================
     // ANNOTATION: RequestWrapper
     // ==========================================
@@ -297,9 +332,9 @@
             }
             else {
                 // The default value for targetNamespace is the target namespace of the SEI. [JAX-WS Sec 7.3, p. 80]
-                // TODO: Get the TNS from the SEI via the endpoint interface desc.
-                throw new UnsupportedOperationException("RequestWrapper.targetNamespace default not implented yet");
-            }
+                // TODO: Implement getting the TNS from the SEI 
+//                requestWrapperTargetNamespace = getEndpointInterfaceDescription().getWebServiceTargetNamespace();
+                throw new UnsupportedOperationException("RequestWrapper.targetNamespace default not implented yet");            }
         }
         return requestWrapperTargetNamespace;
     }
@@ -380,9 +415,10 @@
                 responseWrapperTargetNamespace = getResponseWrapper().targetNamespace();
             }
             else {
-                // The default value for targetNamespace is the target namespace of the SEI. [JAX-WS Sec 7.4, p. 81]
-                // TODO: Get the TNS from the SEI via the endpoint interface desc.
-                throw new UnsupportedOperationException("ResponseWrapper.targetNamespace default not implented yet");
+                // The default value for targetNamespace is the target namespace of the SEI. [JAX-WS Sec 7.3, p. 80]
+                // TODO: Implement getting the TNS from the SEI 
+//                responseWrapperTargetNamespace = getEndpointInterfaceDescription().getWebServiceTargetNamespace();
+                throw new UnsupportedOperationException("RequestWrapper.targetNamespace default not implented yet");
             }
         }
         return responseWrapperTargetNamespace;

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java?view=diff&rev=454026&r1=454025&r2=454026
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java Sat Oct  7 14:25:56 2006
@@ -47,10 +47,10 @@
         assertEquals("http://www.w3.org/2003/05/soap/bindings/HTTP/", testEndpointDesc.getBindingTypeValue());
         // The WebServiceProvider annotation specified no values on it.
         // TODO: When the Description package changes to provide default values when no annotation present, this may need to change.
-        assertEquals("", testEndpointDesc.getWSDLLocation());
-        assertEquals("", testEndpointDesc.getServiceName());
-        assertEquals("", testEndpointDesc.getPortName());
-        assertEquals("", testEndpointDesc.getTargetNamespace());
+        assertEquals("", testEndpointDesc.getWebServiceWSDLLocation());
+        assertEquals("BasicProviderTestImplService", testEndpointDesc.getWebServiceServiceName());
+        assertEquals("BasicProviderTestImplPort", testEndpointDesc.getWebServicePortName());
+        assertEquals("http://description.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
     }
 
     public void testWebServiceProvider() {
@@ -69,10 +69,10 @@
         assertEquals(Service.Mode.PAYLOAD, testEndpointDesc.getServiceModeValue());
         assertEquals("http://www.w3.org/2003/05/soap/bindings/HTTP/", testEndpointDesc.getBindingTypeValue());
 
-        assertEquals("http://wsdl.test", testEndpointDesc.getWSDLLocation());
-        assertEquals("ProviderService", testEndpointDesc.getServiceName());
-        assertEquals("ProviderServicePort", testEndpointDesc.getPortName());
-        assertEquals("http://namespace.test", testEndpointDesc.getTargetNamespace());
+        assertEquals("http://wsdl.test", testEndpointDesc.getWebServiceWSDLLocation());
+        assertEquals("ProviderService", testEndpointDesc.getWebServiceServiceName());
+        assertEquals("ProviderServicePort", testEndpointDesc.getWebServicePortName());
+        assertEquals("http://namespace.test", testEndpointDesc.getWebServiceTargetNamespace());
     }
     
     public void testDefaultServiceModeProvider() {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java?view=diff&rev=454026&r1=454025&r2=454026
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java Sat Oct  7 14:25:56 2006
@@ -18,6 +18,7 @@
 
 package org.apache.axis2.jaxws.description;
 
+import javax.jws.WebMethod;
 import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
 import javax.xml.ws.RequestWrapper;
@@ -379,6 +380,49 @@
         assertEquals("org.apache.axis2.jaxws.description.method2ReqWrapper", operationDesc.getRequestWrapperClassName());
         assertEquals("org.apache.axis2.jaxws.description.Method2", operationDesc.getResponseWrapperClassName());
     }
+    
+    public void testWebMethod() {
+        EndpointInterfaceDescription testEndpointInterfaceDesc = getEndpointInterfaceDesc(WebMethodTestImpl.class);
+        
+        // Test results from method with no annotation
+        OperationDescription operationDesc = testEndpointInterfaceDesc.getOperation("method1")[0];
+        assertNotNull(operationDesc);
+        assertEquals("method1", operationDesc.getWebMethodOperationName());
+        assertEquals("", operationDesc.getWebMethodAction());
+        assertFalse(operationDesc.getWebMethodExclude());
+        
+        operationDesc = testEndpointInterfaceDesc.getOperation("method2")[0];
+        assertNotNull(operationDesc);
+        assertEquals("renamedMethod2", operationDesc.getWebMethodOperationName());
+        assertEquals("", operationDesc.getWebMethodAction());
+        assertFalse(operationDesc.getWebMethodExclude());
+
+        operationDesc = testEndpointInterfaceDesc.getOperation("method3")[0];
+        assertNotNull(operationDesc);
+        assertEquals("method3", operationDesc.getWebMethodOperationName());
+        assertEquals("ActionMethod3", operationDesc.getWebMethodAction());
+        assertFalse(operationDesc.getWebMethodExclude());
+        
+        operationDesc = testEndpointInterfaceDesc.getOperation("method4")[0];
+        assertNotNull(operationDesc);
+        assertEquals("renamedMethod4", operationDesc.getWebMethodOperationName());
+        assertEquals("ActionMethod4", operationDesc.getWebMethodAction());
+        assertFalse(operationDesc.getWebMethodExclude());
+        
+        operationDesc = testEndpointInterfaceDesc.getOperation("method4")[0];
+        assertNotNull(operationDesc);
+        assertEquals("renamedMethod4", operationDesc.getWebMethodOperationName());
+        assertEquals("ActionMethod4", operationDesc.getWebMethodAction());
+        assertFalse(operationDesc.getWebMethodExclude());
+
+        // REVIEW: Should these getters be throwing an exception or returning a default value since exclude=true? 
+        operationDesc = testEndpointInterfaceDesc.getOperation("method5")[0];
+        assertNotNull(operationDesc);
+        assertEquals("method5", operationDesc.getWebMethodOperationName());
+        assertEquals("", operationDesc.getWebMethodAction());
+        assertTrue(operationDesc.getWebMethodExclude());
+
+    }
 
     /*
      * Method to return the endpoint interface description for a given implementation class.
@@ -480,4 +524,35 @@
     public String method2 (String s) {
         return s;
     }
-}   
\ No newline at end of file
+}
+
+// =============================================================================
+// testWebMethod service implementaiton class
+// =============================================================================
+@WebService
+class WebMethodTestImpl {
+    // No web method annotation
+    public String method1 (String s) {
+        return s;
+    }
+    
+    @WebMethod(operationName="renamedMethod2")
+    public String method2 (String s) {
+        return s;
+    }
+    
+    @WebMethod(action="ActionMethod3")
+    public String method3 (String s) {
+        return s;
+    }
+    
+    @WebMethod(operationName="renamedMethod4", action="ActionMethod4")
+    public String method4 (String s) {
+        return s;
+    }
+    
+    @WebMethod(exclude=true)
+    public String method5(String s) {
+        return s;
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java?view=auto&rev=454026
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java Sat Oct  7 14:25:56 2006
@@ -0,0 +1,165 @@
+package org.apache.axis2.jaxws.description;
+
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceProvider;
+
+import junit.framework.TestCase;
+
+public class ServiceAnnotationTests extends TestCase {
+
+    public void testWebServiceDefaults() {
+        String className = "WebServiceDefaultTest";
+        EndpointDescription testEndpointDesc = getEndpointDesc(WebServiceDefaultTest.class);
+        assertNotNull(testEndpointDesc.getWebServiceAnnotation());
+        assertNull(testEndpointDesc.getWebServiceProviderAnnotation());
+        assertEquals(className, testEndpointDesc.getWebServiceName());
+        assertEquals("", testEndpointDesc.getWebServiceEndpointInterface());
+        assertEquals("http://description.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
+        assertEquals(className + "Service", testEndpointDesc.getWebServiceServiceName());
+        assertEquals(className + "Port", testEndpointDesc.getWebServicePortName());
+        assertEquals("", testEndpointDesc.getWebServiceWSDLLocation());
+    }
+    
+    public void testWebServiceProviderDefaults() {
+        String className = "WebServiceProviderDefaultTest";
+        EndpointDescription testEndpointDesc = getEndpointDesc(WebServiceProviderDefaultTest.class);
+        assertNull(testEndpointDesc.getWebServiceAnnotation());
+        assertNotNull(testEndpointDesc.getWebServiceProviderAnnotation());
+        // name element not allowed on WebServiceProvider
+        assertEquals("", testEndpointDesc.getWebServiceName());
+        // EndpointInterface element not allowed on WebServiceProvider
+        assertEquals("", testEndpointDesc.getWebServiceEndpointInterface());
+        assertEquals("http://description.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
+        assertEquals(className + "Service", testEndpointDesc.getWebServiceServiceName());
+        assertEquals(className + "Port", testEndpointDesc.getWebServicePortName());
+        assertEquals("", testEndpointDesc.getWebServiceWSDLLocation());
+    }
+    
+    public void testWebServiceName() {
+        String className = "WebServiceName"; 
+        EndpointDescription testEndpointDesc = getEndpointDesc(WebServiceName.class);
+        assertNotNull(testEndpointDesc.getWebServiceAnnotation());
+        assertNull(testEndpointDesc.getWebServiceProviderAnnotation());
+        assertEquals("WebServiceNameElement", testEndpointDesc.getWebServiceName());
+        assertEquals("", testEndpointDesc.getWebServiceEndpointInterface());
+        assertEquals("http://description.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
+        // Note that per JSR-181 MR Sec 4.1 pg 16, the portName uses WebService.name, but serviceName does not!
+        assertEquals(className + "Service", testEndpointDesc.getWebServiceServiceName());
+        assertEquals("WebServiceNameElementPort", testEndpointDesc.getWebServicePortName());
+        assertEquals("", testEndpointDesc.getWebServiceWSDLLocation());
+    }
+    
+    public void testWebServiceNameAndPort() {
+        String className = "WebServiceNameAndPort"; 
+        EndpointDescription testEndpointDesc = getEndpointDesc(WebServiceNameAndPort.class);
+        assertNotNull(testEndpointDesc.getWebServiceAnnotation());
+        assertNull(testEndpointDesc.getWebServiceProviderAnnotation());
+        assertEquals("WebServiceNameAndPortElement", testEndpointDesc.getWebServiceName());
+        assertEquals("", testEndpointDesc.getWebServiceEndpointInterface());
+        assertEquals("http://description.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
+        // Note that per JSR-181 MR Sec 4.1 pg 16, the portName uses WebService.name, but serviceName does not!
+        assertEquals(className + "Service", testEndpointDesc.getWebServiceServiceName());
+        assertEquals("WebServicePortName", testEndpointDesc.getWebServicePortName());
+        assertEquals("", testEndpointDesc.getWebServiceWSDLLocation());
+    }
+    
+    public void testWebServiceAll() {
+        String className = "WebServiceAll"; 
+        EndpointDescription testEndpointDesc = getEndpointDesc(WebServiceAll.class);
+        assertNotNull(testEndpointDesc.getWebServiceAnnotation());
+        assertNull(testEndpointDesc.getWebServiceProviderAnnotation());
+        assertEquals("WebServiceAllNameElement", testEndpointDesc.getWebServiceName());
+        assertEquals("org.apache.axis2.jaxws.description.MyEndpointInterface", testEndpointDesc.getWebServiceEndpointInterface());
+        assertEquals("http://namespace.target.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
+        assertEquals("WebServiceAllServiceElement", testEndpointDesc.getWebServiceServiceName());
+        assertEquals("WebServiceAllPortElement", testEndpointDesc.getWebServicePortName());
+        assertEquals("http://my.wsdl.location/foo.wsdl", testEndpointDesc.getWebServiceWSDLLocation());
+    }
+    
+    public void testWebServiceProviderAll() {
+        String className = "WebServiceProviderAll"; 
+        EndpointDescription testEndpointDesc = getEndpointDesc(WebServiceProviderAll.class);
+        assertNull(testEndpointDesc.getWebServiceAnnotation());
+        assertNotNull(testEndpointDesc.getWebServiceProviderAnnotation());
+        assertEquals("", testEndpointDesc.getWebServiceName());
+        assertEquals("", testEndpointDesc.getWebServiceEndpointInterface());
+        assertEquals("http://namespace.target.jaxws.axis2.apache.org/", testEndpointDesc.getWebServiceTargetNamespace());
+        assertEquals("WebServiceProviderAllServiceElement", testEndpointDesc.getWebServiceServiceName());
+        assertEquals("WebServiceProviderAllPortElement", testEndpointDesc.getWebServicePortName());
+        assertEquals("http://my.wsdl.other.location/foo.wsdl", testEndpointDesc.getWebServiceWSDLLocation());
+        
+    }
+    
+    /*
+     * Method to return the endpoint interface description for a given implementation class.
+     */
+    private EndpointDescription getEndpointDesc(Class implementationClass) {
+        // Use the description factory directly; this will be done within the JAX-WS runtime
+        ServiceDescription serviceDesc = 
+            DescriptionFactory.createServiceDescriptionFromServiceImpl(implementationClass, null);
+        assertNotNull(serviceDesc);
+        
+        EndpointDescription[] endpointDesc = serviceDesc.getEndpointDescriptions();
+        assertNotNull(endpointDesc);
+        assertEquals(1, endpointDesc.length);
+        
+        // TODO: How will the JAX-WS dispatcher get the appropriate port (i.e. endpoint)?  Currently assumes [0]
+        EndpointDescription testEndpointDesc = endpointDesc[0];
+        return testEndpointDesc;
+    }
+}
+
+// ===============================================
+// WebService Defaults test impl
+// ===============================================
+@WebService()
+class WebServiceDefaultTest {
+    
+}
+
+@WebServiceProvider()
+class WebServiceProviderDefaultTest {
+    
+}
+
+// ===============================================
+// WebService Name test impl
+// ===============================================
+// Note that name is only allowed on @WebService; not @WebServiceProvider
+@WebService(name="WebServiceNameElement")
+class WebServiceName {
+    
+}
+
+@WebService(name="WebServiceNameAndPortElement", portName="WebServicePortName")
+class WebServiceNameAndPort {
+    
+}
+
+// ===============================================
+// WebService All test impl
+// ===============================================
+@WebService(
+        name="WebServiceAllNameElement", 
+        endpointInterface="org.apache.axis2.jaxws.description.MyEndpointInterface",
+        targetNamespace="http://namespace.target.jaxws.axis2.apache.org/",
+        serviceName="WebServiceAllServiceElement",
+        portName="WebServiceAllPortElement",
+        wsdlLocation="http://my.wsdl.location/foo.wsdl")
+class WebServiceAll {
+    
+}
+
+@WebService()
+interface MyEndpointInterface {
+    
+}
+
+@WebServiceProvider(
+        targetNamespace="http://namespace.target.jaxws.axis2.apache.org/",
+        serviceName="WebServiceProviderAllServiceElement",
+        portName="WebServiceProviderAllPortElement",
+        wsdlLocation="http://my.wsdl.other.location/foo.wsdl")
+class WebServiceProviderAll {
+    
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=454026&r1=454025&r2=454026
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Sat Oct  7 14:25:56 2006
@@ -26,6 +26,7 @@
 import org.apache.axis2.jaxws.description.AnnotationDescriptionTests;
 import org.apache.axis2.jaxws.description.AnnotationProviderImplDescriptionTests;
 import org.apache.axis2.jaxws.description.AnnotationServiceImplDescriptionTests;
+import org.apache.axis2.jaxws.description.ServiceAnnotationTests;
 import org.apache.axis2.jaxws.description.ServiceDescriptionTests;
 import org.apache.axis2.jaxws.description.WSDLDescriptionTests;
 import org.apache.axis2.jaxws.description.WSDLTests;
@@ -68,6 +69,7 @@
         suite.addTestSuite(SOAP12Tests.class);
         suite.addTestSuite(MTOMSerializationTests.class);
         
+        suite.addTestSuite(ServiceAnnotationTests.class);
         suite.addTestSuite(WSDLTests.class);
         suite.addTestSuite(DescriptionBuilderTests.class);
         suite.addTestSuite(ServiceDescriptionTests.class);



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