axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r432691 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/proxy/ src/org/apache/axis2/jaxws/description/ src/org/apache/axis2/jaxws/server/dispatcher/ test/org/apache/axis2/jaxws/description/
Date Fri, 18 Aug 2006 19:24:08 GMT
Author: ngallardo
Date: Fri Aug 18 12:24:07 2006
New Revision: 432691

URL: http://svn.apache.org/viewvc?rev=432691&view=rev
Log:
AXIS2-1039
Contributor: Jeff Barrett

This is Jeff's patch for AXIS2-1039

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/DescriptionUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java?rev=432691&r1=432690&r2=432691&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java
Fri Aug 18 12:24:07 2006
@@ -18,6 +18,7 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 import javax.jws.SOAPBinding;
 import javax.jws.WebParam;
@@ -41,146 +42,47 @@
 	
 	private Class seiClazz = null;
 	private Method seiMethod = null;
-	private SOAPBinding soapBinding = null;
-	private RequestWrapper requestWrapper= null;
-	private ResponseWrapper responseWrapper= null;
-	private WebParam[] webParam = null;
-	private WebResult webResult = null;
 	private PortData port = null;
-	//TODO replace annotation work once serviceDescription is ready
-	private ServiceDescription serviceDescription= null;
-	//TODO replace annotation work once operationDescription is ready
+
+    private ServiceDescription serviceDescription= null;
 	private OperationDescription operationDescription= null;
-	//TODO replace annotation work once endpointDescription is ready
 	private EndpointDescription endpointDescription = null;
 
 	//TODO Need to put validation to check if seiMethod is null;
 	public ProxyDescriptor(Class seiClazz, ServiceDescription serviceDescription){
 		this.seiClazz = seiClazz;
         this.serviceDescription = serviceDescription;
-        // TODO: (JLB) Does this need to be more robust; can there be > 1 endpoints; if
so, how choose which one?
+        // TODO: (JLB) This probably needs to be more robust; can there be > 1 endpoints;
if so, how choose which one?
         this.endpointDescription = serviceDescription.getEndpointDescription(seiClazz)[0];
 	}
 	
-	//TODO remove this once OperationDescription is implemented
-	public RequestWrapper getRequestWrapper() {
-		if(requestWrapper == null){
-			requestWrapper = operationDescription.getRequestWrapper();
-		}
-		return requestWrapper;
-	}
-	
-	//TODO remove this once OperationDescription is implemented
-	public ResponseWrapper getResponseWrapper() {
-		if(responseWrapper == null){
-			responseWrapper = operationDescription.getResponseWrapper();
-		}
-		return responseWrapper;
-	}
-	
-	//TODO remove this once OperationDescription is implemented
-	public WebParam[] getWebParam() {
-		if(webParam == null){
-			webParam = operationDescription.getWebParam();
-		}
-		return webParam;
-	}
-	
-	//TODO remove this once OperationDescription is implemented
-	public WebResult getWebResult(){
-		if(webResult == null){
-			webResult = operationDescription.getWebResult();
-		}
-		return webResult;
-	}
-	
-	//TODO: refactor this once PropertyDescriptor is implemented.
-    // TODO: (JLB) Move to OperationDescription?
 	public Class getRequestWrapperClass(boolean isAsync) throws ClassNotFoundException{
-		RequestWrapper requestWrapper = getRequestWrapper();
-		String className = null;
-		if(requestWrapper == null){
-			Class clazz = seiMethod.getDeclaringClass();
-			String packageName =clazz.getPackage().getName();
-			String capitalized = toClass(seiMethod.getName());
-			className = packageName+"."+capitalized;
-		}
-		if(requestWrapper!=null){
-			className = requestWrapper.className();
-		}
+		String className = operationDescription.getRequestWrapperClassName();
 		return Class.forName(className, true, ClassLoader.getSystemClassLoader());
 	}
 	
-    // TODO: (JLB) Move to OperationDescription?
 	public String getRequestWrapperClassName(){
-		if(getRequestWrapper()== null){
-			Class clazz = seiMethod.getDeclaringClass();
-			String packageName =clazz.getPackage().getName();
-			String className = toClass(seiMethod.getName());
-			return packageName+"."+className;
-		}
-		return getRequestWrapper().className();
+		return operationDescription.getRequestWrapperClassName();
 	}
 	
-    // TODO: (JLB) Move to OperationDescription?
 	public String getRequestWrapperLocalName(){
-		if(getRequestWrapper() == null){
-			return seiMethod.getName();
-		}
-		return getRequestWrapper().localName();
+		return operationDescription.getRequestWrapperLocalName();
 	}
-	//TODO remove this once OperationDescription is implemented
-    // TODO: (JLB) Move to OperationDescription?
+
 	public Class getResponseWrapperClass(boolean isAsync) throws ClassNotFoundException{
-		ResponseWrapper responseWrapper = getResponseWrapper();
-		String className = null;
-		if( responseWrapper==null && isAsync){
-			//As per jaxws spec section 2.3.4.4
-			className = toClass(seiMethod.getName()) + "Response";
-		}
-		if(responseWrapper == null){
-			return seiMethod.getReturnType();
-		}
-		if(responseWrapper !=null){
-			className = responseWrapper.className();
-		}
+		String className = operationDescription.getResponseWrapperClassName();
 		return Class.forName(className, true, ClassLoader.getSystemClassLoader());
 	}
 
 	public String getResponseWrapperLocalName(){
-		if(getResponseWrapper()==null){
-			return null;
-		}
-		return getResponseWrapper().localName();
-	}
-	//TODO remove this once OperationDescription is implemented
-    // TODO: (JLB) Move to OperationDescription?
-	public String getWebResultName(boolean isAsync){
-		WebResult webResult = getWebResult();
-		if(webResult == null &&!isAsync){
-			if(!isOneWay() && !seiMethod.getReturnType().getName().equals("void")){
-				return "return";
-			}
-		}
-		if(webResult == null){
-			//I will return null here and when creating result in ProxyHandler I will check for null
and return the wrapperObject if no webResultName found.
-			return null;
-		}
-		return getWebResult().name();
+		return operationDescription.getResponseWrapperLocalName();
+	}
+    public String getWebResultName(boolean isAsync){
+        return operationDescription.getWebResultName();
 	}
-    // TODO: (JLB) Move to OperationDescription?
+
 	public ArrayList<String> getParamNames(){
-		//TODO what if the param itself is a holder class;
-		WebParam[] params = getWebParam();
-		ArrayList<String> names = new ArrayList<String>();
-		for(WebParam webParam:params){
-			//skip asyncHandler, method param name will be asyncHandler as per jaxws specification.
-			if(webParam.name().equals("asyncHandler")){
-				continue;
-			}
-			names.add(webParam.name());
-		}
-		return names;
+        return new ArrayList<String>(Arrays.asList(operationDescription.getWebParamNames()));
 	}
 	public PortData getPort() {
 		return port;
@@ -195,22 +97,10 @@
 		this.seiMethod = seiMethod;
         operationDescription = endpointDescription.getEndpointInterfaceDescription().getOperation(seiMethod);
 	}
-	public SOAPBinding getSoapBindingOnClazz(){
-		if(soapBinding == null){
-			soapBinding = endpointDescription.getEndpointInterfaceDescription().getSoapBinding();
-		}
-		return soapBinding;
-	}
-	public SOAPBinding getSoapBindingOnMethod(){
-		//TODO who has presendence if there is SOAPBinding on Class and method.
-		return operationDescription.getSoapBinding();
-	}
-	//TODO read soap binding on method too, make sure if Binding style is different from binding
style in Clazz throw Exception.
+
+    //TODO read soap binding on method too, make sure if Binding style is different from
binding style in Clazz throw Exception.
 	public Style getBindingStyle(){
-		if(getSoapBindingOnClazz()== null){
-			return SOAPBinding.Style.DOCUMENT;
-		}
-		return getSoapBindingOnClazz().style(); 
+        return endpointDescription.getEndpointInterfaceDescription().getSoapBindingStyle();

 	}
 	public Class getSeiClazz() {
 		return seiClazz;
@@ -221,18 +111,8 @@
     public boolean isOneWay(){
         return operationDescription.isOneWay();
     }
-	/*
-	 * Convert getString to GetString. Converts method to clazz;
-	 */
-	private String toClass(String method){
-		if(method == null){
-			//Throw exception but I should have check this even before this method is Invoked.
-		}
-		StringBuffer methodName = new StringBuffer(method);
-		return methodName.replace(0,1, methodName.substring(0,1).toUpperCase()).toString();
-	}
-	
-	public String filterAsync(String method){
+
+    public String filterAsync(String method){
 		if(method.endsWith("Async")){
 			int index =method.lastIndexOf("Async");
 			return method.substring(0,index);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/DescriptionUtils.java?rev=432691&r1=432690&r2=432691&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/DescriptionUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/DescriptionUtils.java
Fri Aug 18 12:24:07 2006
@@ -33,4 +33,19 @@
         return qname == null || isEmpty(qname.getLocalPart());
     }
 
+    /**
+     * Creat a java class name given a java method name (i.e. capitalize the first letter)
+     * @param name
+     * @return
+     */
+    public static String javaMethodtoClassName(String methodName) {
+        String className = null;
+        if(methodName != null){
+            StringBuffer buildClassName = new StringBuffer(methodName);
+            buildClassName.replace(0, 1, methodName.substring(0,1).toUpperCase());
+            className = buildClassName.toString();
+        }
+        return className;
+    }
+
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java?rev=432691&r1=432690&r2=432691&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java
Fri Aug 18 12:24:07 2006
@@ -71,6 +71,12 @@
     private ArrayList<OperationDescription> operationDescriptions = new ArrayList<OperationDescription>();
     private Class seiClass;
     
+    // Annotations and cached values
+    private SOAPBinding         soapBindingAnnotation;
+    // TODO: (JLB) Should this be using the jaxws annotation values or should that be wrappered?
+    private javax.jws.SOAPBinding.Style soapBindingStyle;
+
+    
     void addOperation(OperationDescription operation) {
         operationDescriptions.add(operation);
     }
@@ -104,6 +110,7 @@
      * @param javaMethodName String representing a Java Method Name
      * @return
      */
+    // TODO: (JLB) This is confusing; somet getOperations use the QName from the WSDL or
annotation; this one uses the java method name; rename this signature I think; add on that
takes a String but does a QName lookup against the WSDL/Annotation
     public OperationDescription[] getOperation(String javaMethodName) {
         if (javaMethodName == null) {
             return null;
@@ -192,9 +199,29 @@
         return seiClass;
     }
     // Annotation-realted getters
-    public SOAPBinding getSoapBinding(){
+    
+    // ========================================
+    // SOAP Binding annotation realted methods
+    // ========================================
+    SOAPBinding getSoapBinding(){
         // TODO: (JLB) Test with sei Null, not null, SOAP Binding annotated, not annotated
-        return (seiClass != null ? (SOAPBinding) seiClass.getAnnotation(SOAPBinding.class)
: null);
+        if (soapBindingAnnotation == null && seiClass != null) {
+            soapBindingAnnotation = (SOAPBinding) seiClass.getAnnotation(SOAPBinding.class);
+        }
+        return soapBindingAnnotation;
+    }
+    
+    public javax.jws.SOAPBinding.Style getSoapBindingStyle() {
+        if (soapBindingStyle == null) {
+            if (getSoapBinding() != null && getSoapBinding().style() != null) {
+                soapBindingStyle = getSoapBinding().style();
+            }
+            else {
+                soapBindingStyle = javax.jws.SOAPBinding.Style.DOCUMENT;
+            }
+        }
+        return soapBindingStyle;
     }
+
 
 }

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?rev=432691&r1=432690&r2=432691&view=diff
==============================================================================
--- 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
Fri Aug 18 12:24:07 2006
@@ -79,12 +79,41 @@
 //       support overloaded methods in the WSDL; the operations are stored on AxisService
as children in a HashMap with the wsdl
 //       operation name as the key.
 
+// TODO: Need tests for all the "default" code paths in the annotation getters.
+// TODO: Need tests for each when annotation is not present where that is allowed by the
spec. 
 public class OperationDescription {
     private EndpointInterfaceDescription parentEndpointInterfaceDescription;
     private AxisOperation axisOperation;
     private QName operationName;
     private Method seiMethod;
-    private WebMethod webMethodAnnotation;
+
+    // Annotations and related cached values
+    private Oneway              onewayAnnotation;
+    private Boolean             onewayIsOneway;
+    
+    private RequestWrapper      requestWrapperAnnotation;
+    private String              requestWrapperTargetNamespace;
+    private String              requestWrapperLocalName;
+    private String              requestWrapperClassName;
+    
+    private ResponseWrapper     responseWrapperAnnotation;
+    private String              responseWrapperLocalName;
+    private String              responseWrapperTargetNamespace;
+    private String              responseWrapperClassName;
+    
+    private SOAPBinding         soapBindingAnnotation;
+    // TODO: (JLB) Should this be using the jaxws annotation values or should that be wrappered?
+    private javax.jws.SOAPBinding.Style soapBindingStyle;
+    
+    private WebMethod           webMethodAnnotation;
+    private String              webMethodOperationName;
+    
+    // TODO: (JLB) Should WebParam annotation be moved to the ParameterDescription?
+    private WebParam[]          webParamAnnotations;
+    private String[]            webParamNames;
+    
+    private WebResult           webResultAnnotation;
+    private String              webResultName;
     
     OperationDescription(Method method, EndpointInterfaceDescription parent) {
         // TODO: (JLB) Look for WebMethod anno; get name and action off of it
@@ -92,14 +121,7 @@
         seiMethod = method;
         webMethodAnnotation = seiMethod.getAnnotation(WebMethod.class);
         
-        // Per JSR-181, if @WebMethod specifies and operation name, use that.  Otherwise
-        // default is the Java method name
-        String methodName;
-        if (webMethodAnnotation != null && webMethodAnnotation.operationName() !=
null && !"".equals(webMethodAnnotation.operationName()))
-            methodName = webMethodAnnotation.operationName();
-        else
-            methodName = method.getName();
-        this.operationName = new QName(methodName);
+        this.operationName = new QName(getWebMethodOperationName());
     }
     OperationDescription(AxisOperation operation, EndpointInterfaceDescription parent) {
         parentEndpointInterfaceDescription = parent;
@@ -147,35 +169,251 @@
     }
 
     // Annotation-related getters
-    // TODO: (JLB) The getters should return processed information rather than the actual
annotations?
-    // TODO: (JLB) Should there be protected getters to return annotations and WSDL constructs
directly
-    // TODO: (JLB) These should cache the information rather than re-getting it each time.
-    public RequestWrapper getRequestWrapper() {
-        return seiMethod.getAnnotation(RequestWrapper.class);
-    }
-    public ResponseWrapper getResponseWrapper() {
-        return seiMethod.getAnnotation(ResponseWrapper.class);
-    }
-    public WebParam[] getWebParam() {
-        Annotation[][] paramAnnotation = seiMethod.getParameterAnnotations();
-        ArrayList<WebParam> webParamList = new ArrayList<WebParam>();
-        for(Annotation[] pa:paramAnnotation){
-            for(Annotation webParam:pa){
-                if(webParam.annotationType() == WebParam.class){
-                    webParamList.add((WebParam)webParam);
+    
+    // =====================================
+    // WebMethod annotation related methods
+    // =====================================
+    WebMethod getWebMethod() {
+        return webMethodAnnotation;
+    }
+    public String getWebMethodOperationName() {
+        if (webMethodOperationName == null) {
+            // Per JSR-181, if @WebMethod specifies and operation name, use that.  Otherwise
+            // default is the Java method name
+            if (getWebMethod() != null && !DescriptionUtils.isEmpty(getWebMethod().operationName()))
{
+                webMethodOperationName = getWebMethod().operationName();
+            }
+            else {
+                webMethodOperationName = seiMethod.getName();
+            }
+        }
+        return webMethodOperationName;
+    }
+    
+    // ==========================================
+    // RequestWrapper Annotation related methods
+    // ==========================================
+    RequestWrapper getRequestWrapper() {
+        if (requestWrapperAnnotation == null) {
+            requestWrapperAnnotation = seiMethod.getAnnotation(RequestWrapper.class); 
+        }
+        return requestWrapperAnnotation;
+    }
+    
+    public String getRequestWrapperLocalName() {
+        if (requestWrapperLocalName == null) {
+            if (getRequestWrapper() != null && !DescriptionUtils.isEmpty(getRequestWrapper().localName()))
{
+                requestWrapperLocalName = getRequestWrapper().localName();
+            }
+            else { 
+                // The default value of localName is the value of operationName as 
+                // defined in the WebMethod annotation. [JAX-WS Sec. 7.3, p. 80]
+                requestWrapperLocalName = getWebMethodOperationName();
+            }
+        }
+        return requestWrapperLocalName;
+    }
+    
+    public String getRequestWrapperTargetNamespace() {
+        if (requestWrapperTargetNamespace == null) {
+            if (getRequestWrapper() != null && !DescriptionUtils.isEmpty(getRequestWrapper().targetNamespace()))
{
+                requestWrapperTargetNamespace = getRequestWrapper().targetNamespace();
+            }
+            else {
+                // The default value for targetNamespace is the target namespace of the SEI.
[JAX-WS Sec 7.3, p. 80]
+                // TODO: (JLB) Get the TNS from the SEI via the endpoint interface desc.
+                throw new UnsupportedOperationException("RequestWrapper.targetNamespace default
not implented yet");
+            }
+        }
+        return requestWrapperTargetNamespace;
+    }
+    
+    public String getRequestWrapperClassName() {
+        if (requestWrapperClassName == null) {
+            if (getRequestWrapper() != null && !DescriptionUtils.isEmpty(getRequestWrapper().className()))
{
+                requestWrapperClassName = getRequestWrapper().className();
+            }
+            else {
+                // Not sure what the default value should be (if any).  None is listed in
Sec. 7.3 on p. 80 of
+                // the JAX-WS spec, BUT Conformance(Using javax.xml.ws.RequestWrapper) in
Sec 2.3.1.2 on p. 13
+                // says the entire annotation "...MAY be omitted if all its properties would
have default vaules."
+                // implying there IS some sort of default.  We'll try this for now:
+                Class clazz = seiMethod.getDeclaringClass();
+                String packageName = clazz.getPackage().getName();
+                String className = DescriptionUtils.javaMethodtoClassName(seiMethod.getName());
+                requestWrapperClassName = packageName + "." + className;
+            }
+        }
+        return requestWrapperClassName;
+    }
+    
+    // ===========================================
+    // ResponseWrapper Annotation related methods
+    // ===========================================
+    ResponseWrapper getResponseWrapper() {
+        if (responseWrapperAnnotation == null) {
+            responseWrapperAnnotation = seiMethod.getAnnotation(ResponseWrapper.class);
+        }
+        return responseWrapperAnnotation;
+    }
+    
+    public String getResponseWrapperLocalName() {
+        if (responseWrapperLocalName == null) {
+            if (getResponseWrapper() != null && !DescriptionUtils.isEmpty(getResponseWrapper().localName()))
{
+                responseWrapperLocalName = getResponseWrapper().localName();
+            }
+            else { 
+                // The default value of localName is the value of operationName as 
+                // defined in the WebMethod annotation appended with "Response". [JAX-WS
Sec. 7.4, p. 81]
+                responseWrapperLocalName = getWebMethodOperationName() + "Response";
+            }
+        }
+        return responseWrapperLocalName;
+    }
+    
+    public String getResponseWrapperTargetNamespace() {
+        if (responseWrapperTargetNamespace == null) {
+            if (getResponseWrapper() != null && !DescriptionUtils.isEmpty(getResponseWrapper().targetNamespace()))
{
+                responseWrapperTargetNamespace = getResponseWrapper().targetNamespace();
+            }
+            else {
+                // The default value for targetNamespace is the target namespace of the SEI.
[JAX-WS Sec 7.4, p. 81]
+                // TODO: (JLB) Get the TNS from the SEI via the endpoint interface desc.
+                throw new UnsupportedOperationException("ResponseWrapper.targetNamespace
default not implented yet");
+            }
+        }
+        return responseWrapperTargetNamespace;
+    }
+    
+    public String getResponseWrapperClassName() {
+        if (responseWrapperClassName == null) {
+            if (getResponseWrapper() != null && !DescriptionUtils.isEmpty(getResponseWrapper().className()))
{
+                responseWrapperClassName = getResponseWrapper().className();
+            }
+            else {
+                // Not sure what the default value should be (if any).  None is listed in
Sec. 7.4 on p. 81 of
+                // the JAX-WS spec, BUT Conformance(Using javax.xml.ws.ResponseWrapper) in
Sec 2.3.1.2 on p. 13
+                // says the entire annotation "...MAY be omitted if all its properties would
have default vaules."
+                // implying there IS some sort of default.  We'll try this for now:
+                Class clazz = seiMethod.getDeclaringClass();
+                String packageName = clazz.getPackage().getName();
+                String className = DescriptionUtils.javaMethodtoClassName(seiMethod.getName());
+                responseWrapperClassName = packageName + "." + className;
+            }
+        }
+        return responseWrapperClassName;
+    }
+
+    // ===========================================
+    // WebParam Annotation related methods
+    // ===========================================
+    // TODO: (JLB) Should this annotation be moved to ParameterDescription 
+    WebParam[] getWebParam() {
+        if (webParamAnnotations == null) {
+            Annotation[][] paramAnnotation = seiMethod.getParameterAnnotations();
+            ArrayList<WebParam> webParamList = new ArrayList<WebParam>();
+            for(Annotation[] pa:paramAnnotation){
+                for(Annotation webParam:pa){
+                    if(webParam.annotationType() == WebParam.class){
+                        webParamList.add((WebParam)webParam);
+                    }
                 }
             }
+            webParamAnnotations = webParamList.toArray(new WebParam[0]);
         }
-        return webParamList.toArray(new WebParam[0]);
+        return webParamAnnotations;
     }
-    public WebResult getWebResult() {
-        return seiMethod.getAnnotation(WebResult.class);
+    
+    public String[] getWebParamNames() {
+        if (webParamNames == null) {
+            ArrayList<String> buildNames = new ArrayList<String>();
+            WebParam[] webParams = getWebParam();
+            for (WebParam currentParam:webParams) {
+                // TODO: (JLB) Is skipping param names of "asyncHandler" correct?  This came
from original ProxyDescription class and ProxyTest fails without this code
+                //       Due to code in DocLitProxyHandler.getParamValues() which does not
add values for AsyncHandler objects.
+                //       It probably DOES need to be skipped, albeit more robustly (check
that the type of the param is javax.xml.ws.AsyncHandler also)
+                //       The reason is that the handler is part of the JAX-WS async callback
programming model; it is NOT part of the formal params
+                //       to the actual method and therefore is NOT part of the JAXB request
wrapper
+                if(!currentParam.name().equals("asyncHandler")){
+                    buildNames.add(currentParam.name());
+                }
+            }
+            webParamNames = buildNames.toArray(new String[0]);
+        }
+        return webParamNames;
+        
     }
-    public SOAPBinding getSoapBinding() {
-        return seiMethod.getAnnotation(SOAPBinding.class);
+    
+    // ===========================================
+    // WebResult Annotation related methods
+    // ===========================================
+    WebResult getWebResult() {
+        if (webResultAnnotation == null) {
+            webResultAnnotation = seiMethod.getAnnotation(WebResult.class);
+        }
+        return webResultAnnotation;
     }
-    public boolean isOneWay() {
-        return seiMethod.isAnnotationPresent(Oneway.class);
+    public boolean isWebResultAnnotationSpecified() {
+        return getWebResult() != null;
     }
 
+    // TODO: (JLB) This method returns null if the annotation is not specified; others return
default values.  I think null is the correct thing to return; change the others
+    public String getWebResultName() {
+        if (isWebResultAnnotationSpecified() && webResultName == null) {
+            if (!DescriptionUtils.isEmpty(getWebResult().name())) {
+                webResultName = getWebResult().name();
+            }
+            else {
+                // Defeault value is "return" per JSR-181 Sec. 4.5.1, p. 22
+                webResultName = "return";
+            }
+        }
+        return webResultName;
+    }
+
+    // ===========================================
+    // SOAPBinding Annotation related methods
+    // ===========================================
+    SOAPBinding getSoapBinding() {
+        if (soapBindingAnnotation == null) {
+            soapBindingAnnotation = seiMethod.getAnnotation(SOAPBinding.class);
+        }
+        return soapBindingAnnotation;
+    }
+    
+    public javax.jws.SOAPBinding.Style getSoapBindingStyle() {
+        if (soapBindingStyle == null) {
+            if (getSoapBinding() != null && getSoapBinding().style() != null) {
+                soapBindingStyle = getSoapBinding().style();
+            }
+            else {
+                soapBindingStyle = javax.jws.SOAPBinding.Style.DOCUMENT;
+            }
+        }
+        return soapBindingStyle;
+    }
+    
+    // ===========================================
+    // OneWay Annotation related methods
+    // ===========================================
+    Oneway getOnewayAnnotation() {
+        if (onewayAnnotation == null) {
+            onewayAnnotation = seiMethod.getAnnotation(Oneway.class);
+        }
+        return onewayAnnotation;
+    }
+
+    public boolean isOneWay() {
+        if (onewayIsOneway == null) {
+            if (getOnewayAnnotation() != null) {
+                // The presence of the annotation indicates the method is oneway
+                onewayIsOneway = new Boolean(true);
+            }
+            else {
+                // If the annotation is not present, the default is this is NOT a One Way
method
+                onewayIsOneway = new Boolean(false);
+            }
+        }
+        return onewayIsOneway.booleanValue();   
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java?rev=432691&r1=432690&r2=432691&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
Fri Aug 18 12:24:07 2006
@@ -18,6 +18,7 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -150,12 +151,9 @@
             
             JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
             
-            WebParam[] webParams = opDesc.getWebParam();
-            ArrayList<String> elements = new ArrayList<String>();
-            for (int i = 0; i < webParams.length; ++i) {
-                elements.add(webParams[i].name());
-            }
-            
+            String[] webParamNames = opDesc.getWebParamNames();
+            ArrayList<String> elements = new ArrayList<String>(Arrays.asList(webParamNames));
+
             Object param = wrapper.getBusinessObject(true);
             Object[] contents = wrapperTool.unWrap(param, elements);
             return contents;
@@ -211,9 +209,8 @@
     private JAXBContext createJAXBContext(OperationDescription opDesc) {
         // This will only support Doc/Lit Wrapped params for now.
         try {
-            RequestWrapper wrapper = opDesc.getRequestWrapper();
-            if (wrapper != null) {
-                String wrapperClass = wrapper.className();
+            String wrapperClass = opDesc.getRequestWrapperClassName();
+            if (wrapperClass != null) {
                 String wrapperPkg = wrapperClass.substring(0, wrapperClass.lastIndexOf("."));
                 JAXBContext jbc = JAXBContext.newInstance(wrapperPkg);
                 return jbc;
@@ -233,19 +230,19 @@
             BlockFactory bfactory = (BlockFactory) FactoryRegistry.getFactory(
                     JAXBBlockFactory.class);
             
-            String responseWrapper = opDesc.getResponseWrapper().className();
+            String responseWrapper = opDesc.getResponseWrapperClassName();
             Class responseWrapperClass = Class.forName(responseWrapper);
             JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
 
-            WebResult webResult = opDesc.getWebResult();
+            String webResult = opDesc.getWebResultName();
             ArrayList<String> responseParams = new ArrayList<String>();
-            responseParams.add(webResult.name());
+            responseParams.add(webResult);
  
             ArrayList<String> elements = new ArrayList<String>();
-            elements.add(webResult.name());
+            elements.add(webResult);
             
             Map<String, Object> responseParamValues = new HashMap<String, Object>();
-            responseParamValues.put(webResult.name(), response);
+            responseParamValues.put(webResult, response);
             
             Object wrapper = wrapperTool.wrap(responseWrapperClass, 
                     responseWrapper, responseParams, responseParamValues);

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?rev=432691&r1=432690&r2=432691&view=diff
==============================================================================
--- 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
Fri Aug 18 12:24:07 2006
@@ -18,6 +18,8 @@
 
 package org.apache.axis2.jaxws.description;
 
+import javax.jws.SOAPBinding;
+
 import junit.framework.TestCase;
 
 import org.apache.axis2.description.AxisService;
@@ -65,6 +67,23 @@
         assertNotNull(paramTypes);
         assertEquals(paramTypes.length, 1);
         assertEquals("javax.xml.ws.Holder", paramTypes[0]);
+        
+        // Test RequestWrapper annotations
+        assertEquals(operations[0].getRequestWrapperLocalName(), "Echo");
+        assertEquals(operations[0].getRequestWrapperTargetNamespace(), "http://ws.apache.org/axis2/tests");
+        assertEquals(operations[0].getRequestWrapperClassName(), "org.apache.ws.axis2.tests.Echo");
+        
+        // Test ResponseWrapper annotations
+        assertEquals(operations[0].getResponseWrapperLocalName(), "EchoResponse");
+        assertEquals(operations[0].getResponseWrapperTargetNamespace(), "http://ws.apache.org/axis2/tests");
+        assertEquals(operations[0].getResponseWrapperClassName(), "org.apache.ws.axis2.tests.EchoResponse");
+        
+        // Test SOAPBinding default; that annotation is not present in the SEI
+        // Note that annotation could occur on the operation or the type
+        // (although on this SEI it doesn't occur either place).
+        assertEquals(SOAPBinding.Style.DOCUMENT, operations[0].getSoapBindingStyle());
+        assertEquals(SOAPBinding.Style.DOCUMENT, endpointIntfDesc.getSoapBindingStyle());
+        
     }
     
     public void testAxisServiceBackpointer() {
@@ -107,11 +126,21 @@
         assertEquals(operations[0].getJavaMethodName(), "invokeAsync");
         assertEquals(operations[1].getJavaMethodName(), "invokeAsync");
         
-        // Check the parameters for each operation
+        // Check the Java parameters, WebParam names, and WebResult (actually lack thereof)
for each of these operations
+        
+        // Note regarding WebParam names:
+        // Unlike the Java paramaters, the WebParam names will remove the JAX-WS AsyncHandler
+        // parameter.  That is because it is NOT part of the contract, and thus it is NOT
part of
+        // the JAXB object constructed for the method invocation.  The AsyncHandler is part
of the 
+        // JAX-WS programming model to support an asynchronous callback to receive the response.
+        
+        // Note regarding WebResult annotation:
+        // The async methods on this SEI do not carry a WebResult annotations.
         boolean twoArgSignatureChecked = false;
         boolean oneArgSignatureChecked = false;
         for (OperationDescription operation:operations) {
             String[] checkParams = operation.getJavaParameters();
+            String[] webParamNames = operation.getWebParamNames();
             if (checkParams.length == 1) {
                 // Check the one arguement signature
                 if (oneArgSignatureChecked) {
@@ -119,7 +148,14 @@
                 }
                 else {
                     oneArgSignatureChecked = true;
+                    // Check the Java parameter
                     assertEquals(checkParams[0], "java.lang.String");
+                    // Check the WebParam Names (see note above) 
+                    assertEquals(1, webParamNames.length);
+                    assertEquals("invoke_str", webParamNames[0]);
+                    // Check the lack of a WebResult annotation
+                    assertEquals(false, operation.isWebResultAnnotationSpecified());
+                    assertEquals(null, operation.getWebResultName());
                 }
             }
             else if (checkParams.length == 2) {
@@ -129,25 +165,22 @@
                 }
                 else {
                     twoArgSignatureChecked = true;
+                    // Check the Java parameter
                     assertEquals(checkParams[0], "java.lang.String" );
                     assertEquals(checkParams[1], "javax.xml.ws.AsyncHandler");
+                    // Check the WebParam Names (see note above) 
+                    assertEquals(1, webParamNames.length);
+                    assertEquals("invoke_str", webParamNames[0]);
+                    // Check the lack of a WebResult annotation
+                    assertEquals(false, operation.isWebResultAnnotationSpecified());
+                    assertEquals(null, operation.getWebResultName());
                 }
             }
             else {
                 fail("Wrong number of parameters returned");
             }
-            
         }
 
-        // Test for a method with no parameters which also is not overloaded
-        operations = endpointIntfDesc.getOperation("oneWayVoid");
-        assertNotNull(operations);
-        assertEquals(operations.length, 1);
-        assertEquals(operations[0].getJavaMethodName(), "oneWayVoid");
-        String[] checkEmptyParams = operations[0].getJavaParameters();
-        assertNotNull(checkEmptyParams);
-        assertEquals(checkEmptyParams.length, 0);
-        
         // Test for a method with parameters of primitive types.  Note
         // this method IS overloaded
         operations = endpointIntfDesc.getOperation("twoWayHolderAsync");
@@ -161,6 +194,7 @@
         boolean threeArgSignatureChecked = false;
         for (OperationDescription operation:operations) {
             String[] checkParams = operation.getJavaParameters();
+            String[] webParamNames = operation.getWebParamNames();
             if (checkParams.length == 3) {
                 // Check the one arguement signature
                 if (threeArgSignatureChecked) {
@@ -171,6 +205,13 @@
                     assertEquals(checkParams[0], "java.lang.String");
                     assertEquals(checkParams[1], "int");
                     assertEquals(checkParams[2], "javax.xml.ws.AsyncHandler");
+                    // Check the WebParam Names (see note above) 
+                    assertEquals(2, webParamNames.length);
+                    assertEquals("twoWayHolder_str", webParamNames[0]);
+                    assertEquals("twoWayHolder_int", webParamNames[1]);
+                    // Check the lack of a WebResult annotation
+                    assertEquals(false, operation.isWebResultAnnotationSpecified());
+                    assertEquals(null, operation.getWebResultName());
                 }
             }
             else if (checkParams.length == 2) {
@@ -182,11 +223,38 @@
                     twoArgSignatureChecked = true;
                     assertEquals(checkParams[0], "java.lang.String" );
                     assertEquals(checkParams[1], "int");
+                    // Check the WebParam Names (see note above) 
+                    assertEquals(2, webParamNames.length);
+                    assertEquals("twoWayHolder_str", webParamNames[0]);
+                    assertEquals("twoWayHolder_int", webParamNames[1]);
+                    // Check the lack of a WebResult annotation
+                    assertEquals(false, operation.isWebResultAnnotationSpecified());
+                    assertEquals(null, operation.getWebResultName());
                 }
             }
             else {
                 fail("Wrong number of parameters returned");
             }
         }
+
+        // Test for a one-way, void method with no parameters which also is not overloaded
+        operations = endpointIntfDesc.getOperation("oneWayVoid");
+        assertNotNull(operations);
+        assertEquals(operations.length, 1);
+        assertEquals(operations[0].getJavaMethodName(), "oneWayVoid");
+        String[] checkEmptyParams = operations[0].getJavaParameters();
+        assertNotNull(checkEmptyParams);
+        assertEquals(checkEmptyParams.length, 0);
+        assertEquals(true, operations[0].isOneWay());
+        assertEquals(false, operations[0].isWebResultAnnotationSpecified());
+        assertEquals(null, operations[0].getWebResultName());
+        
+        // Test two-way method for lack of OneWay annotation and WebResult annotation
+        operations = endpointIntfDesc.getOperation("invoke");
+        assertNotNull(operations);
+        assertEquals(1, operations.length);
+        assertEquals(false, operations[0].isOneWay());
+        assertEquals(true, operations[0].isWebResultAnnotationSpecified());
+        assertEquals("return_str", operations[0].getWebResultName());
     }
 }



---------------------------------------------------------------------
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