You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/11/30 22:31:30 UTC
svn commit: r481085 - in
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws:
description/ description/impl/ marshaller/impl/alt/
Author: scheu
Date: Thu Nov 30 13:31:28 2006
New Revision: 481085
URL: http://svn.apache.org/viewvc?view=rev&rev=481085
Log:
AXIS2-1797
Contributor: Rich Scheuerle
Get return type during annotation walk
Modified:
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/description/impl/OperationDescriptionImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
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=481085&r1=481084&r2=481085
==============================================================================
--- 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 Thu Nov 30 13:31:28 2006
@@ -74,12 +74,29 @@
public String getAction();
public boolean isOneWay();
public boolean isExcluded();
+ public boolean isAsync();
public boolean isOperationReturningResult();
public String getResultName();
public String getResultTargetNamespace();
public String getResultPartName();
public boolean isResultHeader();
+
+
+
+ /**
+ * Return the Class of the type
+ * @return Class
+ */
+ public Class getResultType();
+
+ /**
+ * Return the actual Class of the type.
+ * This method returns the actual Class that may be embedded
+ * inside a Response or Callback
+ * @return actual Class
+ */
+ public Class getResultActualType();
public String getRequestWrapperClassName();
public String getRequestWrapperTargetNamespace();
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?view=diff&rev=481085&r1=481084&r2=481085
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java Thu Nov 30 13:31:28 2006
@@ -20,10 +20,12 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.concurrent.Future;
import javax.jws.Oneway;
import javax.jws.WebMethod;
@@ -31,7 +33,9 @@
import javax.jws.WebParam.Mode;
import javax.jws.soap.SOAPBinding;
import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.Response;
import javax.xml.ws.ResponseWrapper;
import javax.xml.ws.WebFault;
@@ -1139,4 +1143,56 @@
return returnWrapperClassName;
}
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.OperationDescription#getResultType()
+ */
+ public Class getResultType() {
+ Method seiMethod = this.getSEIMethod();
+ return seiMethod.getReturnType();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.OperationDescription#getResultActualType()
+ */
+ public Class getResultActualType() {
+ Class returnType = getResultType();
+ if(isAsync()){
+ //pooling implementation
+ if(Response.class == returnType){
+ Type type = seiMethod.getGenericReturnType();
+ ParameterizedType pType = (ParameterizedType) type;
+ return (Class)pType.getActualTypeArguments()[0];
+ }
+ //Callback Implementation
+ else{
+ Type[] type = seiMethod.getGenericParameterTypes();
+ Class parameters[]= seiMethod.getParameterTypes();
+ int i=0;
+ for(Class param:parameters){
+ if(AsyncHandler.class.isAssignableFrom(param)){
+ ParameterizedType pType = (ParameterizedType)type[i];
+ return (Class)pType.getActualTypeArguments()[0];
+ }
+ i++;
+ }
+ }
+
+ }
+
+ return returnType;
+ }
+
+ /**
+ * @param operationDesc
+ * @return if asyc operation
+ */
+ public boolean isAsync(){
+ Method method = this.getSEIMethod();
+ if(method == null){
+ return false;
+ }
+ String methodName = method.getName();
+ Class returnType = method.getReturnType();
+ return methodName.endsWith("Async") && (returnType.isAssignableFrom(Response.class) || returnType.isAssignableFrom(Future.class));
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java?view=diff&rev=481085&r1=481084&r2=481085
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java Thu Nov 30 13:31:28 2006
@@ -158,6 +158,15 @@
if (pkg != null) {
set.add(pkg);
}
+
+ // Finally consider the result type
+ Class cls = opDesc.getResultActualType();
+ if (cls != null && cls != void.class && cls != Void.class) {
+ pkg = cls.getPackage();
+ if (pkg != null) {
+ set.add(pkg);
+ }
+ }
}
/**
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?view=diff&rev=481085&r1=481084&r2=481085
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java Thu Nov 30 13:31:28 2006
@@ -78,7 +78,7 @@
Set<Package> packages = endpointDesc.getPackages();
// Get the return value.
- Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+ Class returnType = operationDesc.getResultActualType();
Object returnValue = null;
if (returnType != void.class) {
returnValue = MethodMarshallerUtils.getReturnValue(packages, message, null);
@@ -157,7 +157,7 @@
Message m = mf.create(protocol);
// Put the return object onto the message
- Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+ Class returnType = operationDesc.getResultActualType();
if (returnType != void.class) {
MethodMarshallerUtils.toMessage(returnObject, returnType,
operationDesc.getResultTargetNamespace(),
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java?view=diff&rev=481085&r1=481084&r2=481085
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java Thu Nov 30 13:31:28 2006
@@ -93,7 +93,7 @@
// The wrapper element
// or null
Object returnValue = null;
- Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+ Class returnType = operationDesc.getResultActualType();
boolean isChildReturn = (operationDesc instanceof OperationDescriptionJava) &&
((OperationDescriptionJava) operationDesc).isWebResultAnnotationSpecified();
boolean isNoReturn = (returnType == void.class);
@@ -301,7 +301,7 @@
}
// Add the return object to the nameList and objectList
- Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+ Class returnType = operationDesc.getResultActualType();
if (returnType != void.class) {
String name = operationDesc.getResultName();
nameList.add(name);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?view=diff&rev=481085&r1=481084&r2=481085
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Thu Nov 30 13:31:28 2006
@@ -395,41 +395,6 @@
}
/**
- * Utility method to get the Class representing the actual return type
- *
- * @param operationDesc
- * @return actual return type
- */
- static Class getActualReturnType(OperationDescription operationDesc){
- Method seiMethod = operationDesc.getSEIMethod();
- Class returnType = seiMethod.getReturnType();
- if(isAsync(operationDesc)){
- //pooling implementation
- if(Response.class == returnType){
- Type type = seiMethod.getGenericReturnType();
- ParameterizedType pType = (ParameterizedType) type;
- return (Class)pType.getActualTypeArguments()[0];
- }
- //Callback Implementation
- else{
- Type[] type = seiMethod.getGenericParameterTypes();
- Class parameters[]= seiMethod.getParameterTypes();
- int i=0;
- for(Class param:parameters){
- if(AsyncHandler.class.isAssignableFrom(param)){
- ParameterizedType pType = (ParameterizedType)type[i];
- return (Class)pType.getActualTypeArguments()[0];
- }
- i++;
- }
- }
-
- }
-
- return returnType;
- }
-
- /**
* Marshaling a fault is essentially the same for rpc/lit and doc/lit.
* This method is used by all of the MethodMarshallers
* @param throwable Throwable to marshal
@@ -595,19 +560,7 @@
return exception;
}
- /**
- * @param operationDesc
- * @return if asyc operation
- */
- static boolean isAsync(OperationDescription operationDesc){
- Method method = operationDesc.getSEIMethod();
- if(method == null){
- return false;
- }
- String methodName = method.getName();
- Class returnType = method.getReturnType();
- return methodName.endsWith("Async") && (returnType.isAssignableFrom(Response.class) || returnType.isAssignableFrom(Future.class));
- }
+
/**
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java?view=diff&rev=481085&r1=481084&r2=481085
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java Thu Nov 30 13:31:28 2006
@@ -199,7 +199,7 @@
m.setOperationElement(responseOp);
// Put the return object onto the message
- Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+ Class returnType = operationDesc.getResultActualType();
if (returnType != void.class) {
MethodMarshallerUtils.toMessage(returnObject,
returnType,
@@ -258,7 +258,7 @@
message.setStyle(Style.RPC);
// Get the return value.
- Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+ Class returnType = operationDesc.getResultActualType();
Object returnValue = null;
if (returnType != void.class) {
returnValue = MethodMarshallerUtils.getReturnValue(packages, message, returnType);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org