From scm-return-6262-apmail-geronimo-scm-archive=geronimo.apache.org@geronimo.apache.org Tue Mar 01 02:36:49 2005 Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 97306 invoked from network); 1 Mar 2005 02:36:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Mar 2005 02:36:49 -0000 Received: (qmail 70215 invoked by uid 500); 1 Mar 2005 02:36:49 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 70184 invoked by uid 500); 1 Mar 2005 02:36:48 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 70168 invoked by uid 99); 1 Mar 2005 02:36:48 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 28 Feb 2005 18:36:46 -0800 Received: (qmail 97285 invoked by uid 65534); 1 Mar 2005 02:36:45 -0000 Message-ID: <20050301023645.97284.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Tue, 01 Mar 2005 02:36:45 -0000 Subject: svn commit: r155737 - in geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder: AxisBuilder.java HeavyweightOperationDescBuilder.java LightweightOperationDescBuilder.java OperationDescBuilder.java TypeDescBuilder.java To: scm@geronimo.apache.org From: dblevins@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: dblevins Date: Mon Feb 28 18:36:44 2005 New Revision: 155737 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D155737 Log: Split the AxisBuilder apart so it can be more easily reused for building th= e server-side web services. Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/HeavyweightOperationDescBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/LightweightOperationDescBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/OperationDescBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/TypeDescBuilder.java Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/AxisBuilder.java Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/= axis/builder/AxisBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/= java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=3Ddiff&r1=3D155= 736&r2=3D155737 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/AxisBuilder.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/AxisBuilder.java Mon Feb 28 18:36:44 2005 @@ -25,32 +25,11 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Collections; +import java.util.*; import java.util.jar.JarFile; -import java.beans.PropertyDescriptor; -import java.beans.Introspector; -import java.beans.IntrospectionException; -import javax.wsdl.Binding; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.Definition; -import javax.wsdl.Fault; -import javax.wsdl.Message; -import javax.wsdl.Operation; -import javax.wsdl.Part; -import javax.wsdl.Port; -import javax.wsdl.PortType; +import javax.wsdl.*; import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.extensions.soap.SOAPBinding; -import javax.wsdl.extensions.soap.SOAPBody; -import javax.wsdl.extensions.soap.SOAPOperation; import javax.xml.namespace.QName; import javax.xml.rpc.handler.HandlerInfo; =20 @@ -63,28 +42,13 @@ import net.sf.cglib.reflect.FastConstructor; import org.apache.axis.client.Service; import org.apache.axis.constants.Style; -import org.apache.axis.constants.Use; -import org.apache.axis.description.FaultDesc; -import org.apache.axis.description.OperationDesc; -import org.apache.axis.description.ParameterDesc; import org.apache.axis.description.TypeDesc; -import org.apache.axis.description.FieldDesc; -import org.apache.axis.description.AttributeDesc; -import org.apache.axis.description.ElementDesc; import org.apache.axis.encoding.ser.ArrayDeserializerFactory; import org.apache.axis.encoding.ser.ArraySerializerFactory; import org.apache.axis.encoding.ser.BeanDeserializerFactory; import org.apache.axis.encoding.ser.BeanSerializerFactory; import org.apache.axis.soap.SOAPConstants; -import org.apache.geronimo.axis.client.GenericServiceEndpointWrapper; -import org.apache.geronimo.axis.client.NoOverrideCallbackFilter; -import org.apache.geronimo.axis.client.OperationInfo; -import org.apache.geronimo.axis.client.SEIFactory; -import org.apache.geronimo.axis.client.SEIFactoryImpl; -import org.apache.geronimo.axis.client.SerializableNoOp; -import org.apache.geronimo.axis.client.ServiceImpl; -import org.apache.geronimo.axis.client.ServiceMethodInterceptor; -import org.apache.geronimo.axis.client.TypeMappingInfo; +import org.apache.geronimo.axis.client.*; import org.apache.geronimo.common.DeploymentException; import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.gbean.GBeanData; @@ -96,22 +60,11 @@ import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; import org.apache.geronimo.kernel.ClassLoading; import org.apache.geronimo.naming.reference.DeserializingReference; -import org.apache.geronimo.xbeans.j2ee.ConstructorParameterOrderType; -import org.apache.geronimo.xbeans.j2ee.ExceptionMappingType; import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType; import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType; -import org.apache.geronimo.xbeans.j2ee.MethodParamPartsMappingType; import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType; import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType; -import org.apache.geronimo.xbeans.j2ee.WsdlMessageMappingType; -import org.apache.geronimo.xbeans.j2ee.WsdlReturnValueMappingType; -import org.apache.geronimo.xbeans.j2ee.VariableMappingType; import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.SchemaProperty; -import org.objectweb.asm.Type; -import org.w3.x2001.xmlSchema.ComplexType; -import org.w3.x2001.xmlSchema.ExplicitGroup; -import org.w3.x2001.xmlSchema.LocalElement; =20 /** * @version $Rev: $ $Date: $ @@ -397,69 +350,7 @@ } =20 private TypeDesc getTypeDescriptor(Class javaClass, QName typeQName, J= avaXmlTypeMappingType javaXmlTypeMapping, SchemaType schemaType) throws Dep= loymentException { - boolean isRestriction =3D schemaType.getDerivationType() =3D=3D Sc= hemaType.DT_RESTRICTION; - TypeDesc typeDesc =3D new TypeDesc(javaClass, !isRestriction); - //TODO typeQName may be a 'anonymous" QName like construct. Is th= is what axis expects? - typeDesc.setXmlType(typeQName); - VariableMappingType[] variableMappings =3D javaXmlTypeMapping.getV= ariableMappingArray(); - FieldDesc[] fields =3D new FieldDesc[variableMappings.length]; - - PropertyDescriptor[] propertyDescriptors =3D new java.beans.Proper= tyDescriptor[0]; - try { - propertyDescriptors =3D Introspector.getBeanInfo(javaClass).ge= tPropertyDescriptors(); - } catch (IntrospectionException e) { - throw new DeploymentException("Class " + javaClass + " is not = a valid javabean", e); - } - Map properties =3D new HashMap(); - for (int i =3D 0; i < propertyDescriptors.length; i++) { - PropertyDescriptor propertyDescriptor =3D propertyDescriptors[= i]; - properties.put(propertyDescriptor.getName(), propertyDescripto= r=2EgetPropertyType()); - } - for (int i =3D 0; i < variableMappings.length; i++) { - VariableMappingType variableMapping =3D variableMappings[i]; - String fieldName =3D variableMapping.getJavaVariableName().get= StringValue().trim(); - - if (variableMapping.isSetXmlAttributeName()) { - AttributeDesc attributeDesc =3D new AttributeDesc(); - //setting attribute name sets the xmlName with "" namespac= e, so don't do it -// attributeDesc.setAttributeName(fieldName); - attributeDesc.setFieldName(fieldName); - Class javaType =3D (Class) properties.get(fieldName); - if (javaType =3D=3D null) { - throw new DeploymentException("field name " + fieldNam= e + " not found in " + properties); - } - attributeDesc.setJavaType(javaType); - //TODO correct namespace??? - String namespace =3D ""; - QName xmlName =3D new QName(namespace, variableMapping.get= XmlAttributeName().getStringValue().trim()); - attributeDesc.setXmlName(xmlName); - QName xmlType =3D schemaType.getName(); - attributeDesc.setXmlType(xmlType); - fields[i] =3D attributeDesc; - } else { - ElementDesc elementDesc =3D new ElementDesc(); - elementDesc.setFieldName(fieldName); - Class javaType =3D (Class) properties.get(fieldName); - if (javaType =3D=3D null) { - throw new DeploymentException("field name " + fieldNam= e + " not found in " + properties); - } - elementDesc.setJavaType(javaType); - //TODO correct namespace??? - String namespace =3D ""; - QName xmlName =3D new QName(namespace, variableMapping.get= XmlElementName().getStringValue().trim()); - elementDesc.setXmlName(xmlName); - QName xmlType =3D schemaType.getName(); - elementDesc.setXmlType(xmlType); - //TODO figure out how to find these: -// elementDesc.setArrayType(null); -// elementDesc.setMinOccurs(0); -// elementDesc.setMaxOccurs(0); -// elementDesc.setNillable(false); - fields[i] =3D elementDesc; - } - } - typeDesc.setFields(fields); - return typeDesc; + return TypeDescBuilder.getTypeDescriptor(javaClass, typeQName, jav= aXmlTypeMapping, schemaType); } =20 private Method getMethodForOperation(Class enhancedServiceEndpointClas= s, Operation operation) throws DeploymentException { @@ -546,343 +437,13 @@ } =20 public OperationInfo buildOperationInfoLightweight(Method method, Bind= ingOperation bindingOperation, Style defaultStyle, SOAPConstants soapVersio= n) throws DeploymentException { - - if (bindingOperation =3D=3D null) { - throw new DeploymentException("No BindingOperation supplied fo= r method " + method.getName()); - } - Operation operation =3D bindingOperation.getOperation(); - String operationName =3D operation.getName(); - //section 7.3.2, we don't have to look at parameter ordering. - //unless it turns out we have to validate it. -// List order =3D operation.getParameterOrdering(); - List parameterList =3D new ArrayList(); - - QName returnType =3D null; - QName returnQName =3D null; - - Message inputMessage =3D operation.getInput().getMessage(); - Message outputMessage =3D operation.getOutput() =3D=3D null ? null= : operation.getOutput().getMessage(); - - if (outputMessage !=3D null && outputMessage.getParts().size() > 1= ) { - throw new DeploymentException("Lightweight mapping has at most= one part in the (optional) output message, not: " + outputMessage.getParts= ().size()); - } - Class[] methodParamTypes =3D method.getParameterTypes(); - List inputParts =3D inputMessage.getOrderedParts(null); - if (methodParamTypes.length !=3D inputParts.size()) { - throw new DeploymentException("mismatch in parameter counts: m= ethod has " + methodParamTypes.length + " whereas the input message has " += inputParts.size()); - } - int i =3D 0; - for (Iterator parts =3D inputParts.iterator(); parts.hasNext();) { - Part part =3D (Part) parts.next(); - String partName =3D part.getName(); - QName name =3D new QName("", partName); - byte mode =3D ParameterDesc.IN; - QName typeQName =3D part.getTypeName() =3D=3D null ? part.getE= lementName() : part.getTypeName(); - Class javaClass =3D methodParamTypes[i++]; - //lightweight mapping has no parts in headers, so inHeader and= outHeader are false - ParameterDesc parameter =3D new ParameterDesc(name, mode, type= QName, javaClass, false, false); - parameterList.add(parameter); - } - if (outputMessage !=3D null && outputMessage.getParts().size() =3D= =3D 1) { - returnQName =3D outputMessage.getQName(); - Part part =3D (Part) outputMessage.getParts().values().iterato= r().next(); - returnType =3D part.getTypeName() =3D=3D null ? part.getElemen= tName() : part.getTypeName(); - } - ParameterDesc[] parameterDescs =3D (ParameterDesc[]) parameterList= .toArray(new ParameterDesc[parameterList.size()]); - OperationDesc operationDesc =3D new OperationDesc(operationName, p= arameterDescs, returnQName); - operationDesc.setReturnType(returnType); - Class returnClass =3D method.getReturnType(); - operationDesc.setReturnClass(returnClass); - - SOAPOperation soapOperation =3D (SOAPOperation) WSDescriptorParser= .getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibi= lityElements()); - String soapActionURI =3D soapOperation.getSoapActionURI(); - String styleString =3D soapOperation.getStyle(); - Style style =3D Style.getStyle(styleString, defaultStyle); - BindingInput bindingInput =3D bindingOperation.getBindingInput(); - SOAPBody soapBody =3D (SOAPBody) WSDescriptorParser.getExtensibili= tyElement(SOAPBody.class, bindingInput.getExtensibilityElements()); - String useString =3D soapBody.getUse(); - Use use =3D Use.getUse(useString); - operationDesc.setStyle(style); - operationDesc.setUse(use); - //TODO add faults -// TFault[] faults =3D tOperation.getFaultArray(); -// for (int i =3D 0; i < faults.length; i++) { -// TFault fault =3D faults[i]; -// QName faultQName =3D new QName("", fault.getName()); -// String className =3D ; -// QName faultTypeQName =3D ; -// boolean isComplex =3D ; -// FaultDesc faultDesc =3D new FaultDesc(faultQName, className,= faultTypeQName, isComplex) -// } - boolean usesSOAPAction =3D (soapActionURI !=3D null); - QName operationQName =3D new QName("", operation.getName()); - - String methodName =3D method.getName(); - String methodDesc =3D Type.getMethodDescriptor(method); - OperationInfo operationInfo =3D new OperationInfo(operationDesc, u= sesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, meth= odDesc); - return operationInfo; + LightweightOperationDescBuilder operationDescBuilder =3D new Light= weightOperationDescBuilder(bindingOperation, method); + return operationDescBuilder.buildOperationInfo(soapVersion); } =20 public OperationInfo buildOperationInfoHeavyweight(ServiceEndpointMeth= odMappingType methodMapping, BindingOperation bindingOperation, Style defau= ltStyle, SOAPConstants soapVersion, Map exceptionMap, Map complexTypeMap, J= avaWsdlMappingType mapping, ClassLoader classLoader) throws DeploymentExcep= tion { - - //TODO how can bindingOperation be null? - Operation operation =3D bindingOperation.getOperation(); - String operationName =3D operation.getName(); - - - Message inputMessage =3D operation.getInput().getMessage(); - Message outputMessage =3D operation.getOutput() =3D=3D null ? null= : operation.getOutput().getMessage(); - - boolean isWrappedElement =3D methodMapping.isSetWrappedElement(); - - MethodParamPartsMappingType[] paramMappings =3D methodMapping.getM= ethodParamPartsMappingArray(); - Type[] parameterASMTypes =3D new Type[paramMappings.length]; - ParameterDesc[] parameterDescriptions =3D new ParameterDesc[paramM= appings.length]; - - Set inParamNames =3D new HashSet(); - Set outParamNames =3D new HashSet(); - for (int i =3D 0; i < paramMappings.length; i++) { - MethodParamPartsMappingType paramMapping =3D paramMappings[i]; - int position =3D paramMapping.getParamPosition().getBigInteger= Value().intValue(); - - WsdlMessageMappingType wsdlMessageMappingType =3D paramMapping= .getWsdlMessageMapping(); - QName wsdlMessageQName =3D wsdlMessageMappingType.getWsdlMessa= ge().getQNameValue(); - String wsdlMessagePartName =3D wsdlMessageMappingType.getWsdlM= essagePartName().getStringValue().trim(); - - String parameterMode =3D wsdlMessageMappingType.getParameterMo= de().getStringValue().trim(); - byte mode =3D ParameterDesc.modeFromString(parameterMode); - boolean isInParam =3D mode =3D=3D ParameterDesc.IN || mode =3D= =3D ParameterDesc.INOUT; - boolean isOutParam =3D mode =3D=3D ParameterDesc.OUT || mode = =3D=3D ParameterDesc.INOUT; - - if (isOutParam && outputMessage =3D=3D null) { - throw new DeploymentException("Mapping for output paramete= r " + wsdlMessagePartName + " found, but no output message for operation " = + operationName); - } - boolean isSoapHeader =3D wsdlMessageMappingType.isSetSoapHeade= r(); - boolean inHeader =3D isSoapHeader && isInParam; - boolean outHeader =3D isSoapHeader && isOutParam; - - Part part; - if (isInParam) { - if (!wsdlMessageQName.equals(inputMessage.getQName())) { - throw new DeploymentException("QName of input message:= " + inputMessage.getQName() + - " does not match mapping message QName: " + ws= dlMessageQName + " for operation " + operationName); - } - part =3D inputMessage.getPart(wsdlMessagePartName); - if (part =3D=3D null) { - throw new DeploymentException("No part for wsdlMessage= PartName " + wsdlMessagePartName + " in input message for operation " + ope= rationName); - } - inParamNames.add(wsdlMessagePartName); - if (isOutParam) { - //inout, check that part of same name and type is in o= utput message - Part outPart =3D outputMessage.getPart(wsdlMessagePart= Name); - if (outPart =3D=3D null) { - throw new DeploymentException("No part for wsdlMes= sagePartName " + wsdlMessagePartName + " in output message for INOUT parame= ter of operation " + operationName); - } - if (!part.getName().equals(outPart.getName())) { - throw new DeploymentException("Mismatched input pa= rt name: " + part.getName() + " and output part name: " + outPart.getName()= + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + = " for operation " + operationName); - } - if (!(part.getElementName() =3D=3D null ? outPart.getE= lementName() =3D=3D null : part.getElementName().equals(outPart.getElementN= ame()))) { - throw new DeploymentException("Mismatched input pa= rt element name: " + part.getElementName() + " and output part element name= : " + outPart.getElementName() + " for INOUT parameter for wsdlMessagePartN= ame " + wsdlMessagePartName + " for operation " + operationName); - } - if (!(part.getTypeName() =3D=3D null ? outPart.getType= Name() =3D=3D null : part.getTypeName().equals(outPart.getTypeName()))) { - throw new DeploymentException("Mismatched input pa= rt type name: " + part.getTypeName() + " and output part type name: " + out= Part.getTypeName() + " for INOUT parameter for wsdlMessagePartName " + wsdl= MessagePartName + " for operation " + operationName); - } - outParamNames.add(wsdlMessagePartName); - } - } else if (isOutParam) { - if (!wsdlMessageQName.equals(outputMessage.getQName())) { - throw new DeploymentException("QName of output message= : " + outputMessage.getQName() + - " does not match mapping message QName: " + ws= dlMessageQName + " for operation " + operationName); - } - part =3D outputMessage.getPart(wsdlMessagePartName); - if (part =3D=3D null) { - throw new DeploymentException("No part for wsdlMessage= PartName " + wsdlMessagePartName + " in output message for operation " + op= erationName); - } - outParamNames.add(wsdlMessagePartName); - } else { - throw new AssertionError("a param mapping has to be IN or = OUT or INOUT"); - } - - //TODO this makes little sense but may be correct, see comment= s in axis Parameter class - //the part name qname is really odd. - QName partQName =3D isWrappedElement ? part.getElementName() := new QName("", part.getName()); - QName partTypeQName =3D part.getTypeName(); - - //use complexTypeMap - boolean isComplexType =3D complexTypeMap.containsKey(partTypeQ= Name); - String paramJavaTypeName =3D paramMapping.getParamType().getSt= ringValue().trim(); - boolean isInOnly =3D mode =3D=3D ParameterDesc.IN; - Class actualParamJavaType =3D WSDescriptorParser.getHolderType= (paramJavaTypeName, isInOnly, partTypeQName, isComplexType, mapping, classL= oader); - - ParameterDesc parameterDesc =3D new ParameterDesc(partQName, m= ode, partTypeQName, actualParamJavaType, inHeader, outHeader); - parameterDescriptions[position] =3D parameterDesc; - parameterASMTypes[position] =3D Type.getType(actualParamJavaTy= pe); - } - - //check that all the parameters are there - for (int i =3D 0; i < parameterDescriptions.length; i++) { - ParameterDesc parameterDescription =3D parameterDescriptions[i= ]; - if (parameterDescription =3D=3D null) { - throw new DeploymentException("There is no mapping for par= ameter number " + i + " for operation " + operationName); - } - } - - //check that all input message parts are mapped - if (!inParamNames.equals(inputMessage.getParts().keySet())) { - throw new DeploymentException("Not all input message parts wer= e mapped for operation name" + operationName); - } - - - QName returnType =3D null; - QName returnQName =3D null; - Class returnClass =3D null; - Type returnASMType =3D Type.VOID_TYPE; - - if (methodMapping.isSetWsdlReturnValueMapping()) { - if (outputMessage =3D=3D null) { - throw new DeploymentException("No output message, but a ma= pping for it for operation " + operationName); - } - WsdlReturnValueMappingType wsdlReturnValueMapping =3D methodMa= pping.getWsdlReturnValueMapping(); - String returnClassName =3D wsdlReturnValueMapping.getMethodRet= urnValue().getStringValue().trim(); - try { - returnClass =3D ClassLoading.loadClass(returnClassName, cl= assLoader); - } catch (ClassNotFoundException e) { - throw new DeploymentException("Could not load return type = for operation " + operationName, e); - } - - QName wsdlMessageQName =3D wsdlReturnValueMapping.getWsdlMessa= ge().getQNameValue(); - - if (!wsdlMessageQName.equals(outputMessage.getQName())) { - throw new DeploymentException("OutputMessage has QName: " = + outputMessage.getQName() + " but mapping specifies: " + wsdlMessageQName = + " for operation " + operationName); - } - - if (wsdlReturnValueMapping.isSetWsdlMessagePartName()) { - String wsdlMessagePartName =3D wsdlReturnValueMapping.getW= sdlMessagePartName().getStringValue().trim(); - if (outParamNames.contains(wsdlMessagePartName)) { - throw new DeploymentException("output message part " += wsdlMessagePartName + " has both an INOUT or OUT mapping and a return valu= e mapping for operation " + operationName); - } - Part part =3D outputMessage.getPart(wsdlMessagePartName); - returnQName =3D part.getElementName(); - returnType =3D part.getTypeName(); - - outParamNames.add(wsdlMessagePartName); - - } else { - //what does this mean???? - } - - returnASMType =3D Type.getType(returnClass); - - } - - if (outputMessage !=3D null && !outParamNames.equals(outputMessage= .getParts().keySet())) { - throw new DeploymentException("Not all output message parts we= re mapped to parameters or a return value for operation " + operationName); - } - - OperationDesc operationDesc =3D new OperationDesc(operationName, p= arameterDescriptions, returnQName); - operationDesc.setReturnType(returnType); - operationDesc.setReturnClass(returnClass); - - SOAPOperation soapOperation =3D (SOAPOperation) WSDescriptorParser= .getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibi= lityElements()); - String soapActionURI =3D soapOperation.getSoapActionURI(); - String styleString =3D soapOperation.getStyle(); - Style style =3D Style.getStyle(styleString, defaultStyle); - BindingInput bindingInput =3D bindingOperation.getBindingInput(); - SOAPBody soapBody =3D (SOAPBody) WSDescriptorParser.getExtensibili= tyElement(SOAPBody.class, bindingInput.getExtensibilityElements()); - String useString =3D soapBody.getUse(); - Use use =3D Use.getUse(useString); - operationDesc.setStyle(style); - operationDesc.setUse(use); - //TODO add faults - - Map faultMap =3D operation.getFaults(); - for (Iterator iterator =3D faultMap.entrySet().iterator(); iterato= r=2EhasNext();) { - Map.Entry entry =3D (Map.Entry) iterator.next(); - String faultName =3D (String) entry.getKey(); - Fault fault =3D (Fault) entry.getValue(); - Message message =3D fault.getMessage(); - QName messageQName =3D message.getQName(); - ExceptionMappingType exceptionMapping =3D (ExceptionMappingTyp= e) exceptionMap.get(messageQName); - if (exceptionMapping =3D=3D null) { - throw new DeploymentException("No exception mapping for fa= ult " + faultName + " and fault message " + messageQName + " for operation = " + operationName); - } - String className =3D exceptionMapping.getExceptionType().getSt= ringValue().trim(); - //this is weird, but I can't figure out what it should be. - QName faultQName =3D new QName("", faultName); - Part part; - if (exceptionMapping.isSetWsdlMessagePartName()) { - //According to schema documentation, this will only be set= when several headerfaults use the same message. - String headerFaultMessagePartName =3D exceptionMapping.get= WsdlMessagePartName().getStringValue(); - part =3D message.getPart(headerFaultMessagePartName); - } else { - part =3D (Part) message.getOrderedParts(null).iterator().n= ext(); - } - QName faultTypeQName =3D part.getElementName() =3D=3D null ? p= art.getTypeName() : part.getElementName(); - boolean isComplex =3D faultTypeQName !=3D null && complexTypeM= ap.containsKey(faultTypeQName); - FaultDesc faultDesc =3D new FaultDesc(faultQName, className, f= aultTypeQName, isComplex); - - //constructor parameters - if (exceptionMapping.isSetConstructorParameterOrder()) { - if (!isComplex) { - throw new DeploymentException("ConstructorParameterOrd= er can only be set for complex types, not " + faultTypeQName); - } - SchemaType complexType =3D (SchemaType) complexTypeMap.get= (faultTypeQName); - Map elementMap =3D new HashMap(); - SchemaProperty[] properties =3D complexType.getProperties(= ); - for (int i =3D 0; i < properties.length; i++) { - SchemaProperty property =3D properties[i]; - QName elementName =3D property.getName(); - SchemaType elementType =3D property.getType(); - QName elementTypeQName =3D elementType.getName(); - elementMap.put(elementName.getLocalPart(), elementType= QName); - } -// LocalElement[] elements =3D explicitGroup.getElementArra= y(); -// for (int i =3D 0; i < elements.length; i++) { -// LocalElement element =3D elements[i]; -// String elementName =3D element.getName(); -// QName elementType =3D element.getType(); -// elementMap.put(elementName, elementType); -// } - ArrayList parameterTypes =3D new ArrayList(); - ConstructorParameterOrderType constructorParameterOrder = =3D exceptionMapping.getConstructorParameterOrder(); - for (int i =3D 0; i < constructorParameterOrder.getElement= NameArray().length; i++) { - String elementName =3D constructorParameterOrder.getEl= ementNameArray(i).getStringValue().trim(); - QName elementType =3D (QName) elementMap.get(elementNa= me); - String javaElementTypeName; - if (complexTypeMap.containsKey(elementType)) { - String packageName =3D WSDescriptorParser.getPacka= geFromNamespace(elementType.getNamespaceURI(), mapping); - javaElementTypeName =3D packageName + "." + elemen= tType.getLocalPart(); - } else { - //TODO finish this - if (elementType.getLocalPart().equals("String")) { - javaElementTypeName =3D String.class.getName(); - } else { - throw new DeploymentException("most simple exc= eption constructor types not yet implemented"); - } - } - Class javaElementType; - try { - javaElementType =3D ClassLoading.loadClass(javaEle= mentTypeName, classLoader); - } catch (ClassNotFoundException e) { - throw new DeploymentException("Could not load exce= ption constructor parameter", e); - } - //todo faultTypeQName is speculative - //todo outheader might be true! - ParameterDesc parameterDesc =3D new ParameterDesc(faul= tTypeQName, ParameterDesc.OUT, elementType, javaElementType, false, false); - parameterTypes.add(parameterDesc); - } - faultDesc.setParameters(parameterTypes); - } - operationDesc.addFault(faultDesc); - } - - boolean usesSOAPAction =3D (soapActionURI !=3D null); - QName operationQName =3D new QName("", operation.getName()); - - String methodName =3D methodMapping.getJavaMethodName().getStringV= alue().trim(); - String methodDesc =3D Type.getMethodDescriptor(returnASMType, para= meterASMTypes); - OperationInfo operationInfo =3D new OperationInfo(operationDesc, u= sesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, meth= odDesc); - return operationInfo; + HeavyweightOperationDescBuilder operationDescBuilder =3D new Heavy= weightOperationDescBuilder(bindingOperation, mapping, methodMapping, defaul= tStyle, exceptionMap, complexTypeMap, classLoader); + return operationDescBuilder.buildOperationInfo(soapVersion); } =20 private static class ByteArrayRetrievingGeneratorStrategy extends Defa= ultGeneratorStrategy { Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axi= s/builder/HeavyweightOperationDescBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/= java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java?= view=3Dauto&rev=3D155737 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/HeavyweightOperationDescBuilder.java (added) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/HeavyweightOperationDescBuilder.java Mon Feb 28 18:36:44 2005 @@ -0,0 +1,357 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.axis.builder; + +import java.lang.String; +import java.util.*; +import javax.wsdl.*; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.xml.namespace.QName; + +import org.apache.axis.constants.Style; +import org.apache.axis.constants.Use; +import org.apache.axis.description.FaultDesc; +import org.apache.axis.description.OperationDesc; +import org.apache.axis.description.ParameterDesc; +import org.apache.axis.soap.SOAPConstants; +import org.apache.geronimo.axis.client.OperationInfo; +import org.apache.geronimo.common.DeploymentException; +import org.apache.geronimo.kernel.ClassLoading; +import org.apache.geronimo.xbeans.j2ee.*; +import org.apache.xmlbeans.SchemaProperty; +import org.apache.xmlbeans.SchemaType; +import org.objectweb.asm.Type; + +public class HeavyweightOperationDescBuilder extends OperationDescBuilder { + + private final JavaWsdlMappingType mapping; + private final ServiceEndpointMethodMappingType methodMapping; + private final SOAPBody soapBody; + + + private final Style defaultStyle; + private final Map exceptionMap; + private final Map complexTypeMap; + private final ClassLoader classLoader; + + /* Keep track of in and out parameter names so we can verify that + * everything has been mapped and mapped correctly + */ + private final Set inParamNames =3D new HashSet(); + private final Set outParamNames =3D new HashSet(); + + public HeavyweightOperationDescBuilder(BindingOperation bindingOperati= on, JavaWsdlMappingType mapping, ServiceEndpointMethodMappingType methodMap= ping, Style defaultStyle, Map exceptionMap, Map complexTypeMap, ClassLoader= classLoader) throws DeploymentException { + super(bindingOperation); + this.mapping =3D mapping; + this.methodMapping =3D methodMapping; + this.defaultStyle =3D defaultStyle; + this.exceptionMap =3D exceptionMap; + this.complexTypeMap =3D complexTypeMap; + this.classLoader =3D classLoader; + + BindingInput bindingInput =3D bindingOperation.getBindingInput(); + this.soapBody =3D (SOAPBody) WSDescriptorParser.getExtensibilityEl= ement(SOAPBody.class, bindingInput.getExtensibilityElements()); + } + + + public OperationInfo buildOperationInfo(SOAPConstants soapVersion) thr= ows DeploymentException { + buildOperationDesc(); + + String soapActionURI =3D soapOperation.getSoapActionURI(); + boolean usesSOAPAction =3D (soapActionURI !=3D null); + QName operationQName =3D new QName("", operation.getName()); + + String methodName =3D methodMapping.getJavaMethodName().getStringV= alue().trim(); + + ArrayList parameters =3D operationDesc.getParameters(); + Type[] parameterASMTypes =3D new Type[parameters.size()]; + for (int i =3D 0; i < parameters.size(); i++) { + ParameterDesc parameterDesc =3D (ParameterDesc) parameters.get= (i); + parameterASMTypes[i] =3D Type.getType(parameterDesc.getJavaTyp= e()); + } + + Type returnASMType =3D (operationDesc.getReturnClass() !=3D null) = ? Type.getType(operationDesc.getReturnClass()) : Type.VOID_TYPE; + + String methodDesc =3D Type.getMethodDescriptor(returnASMType, para= meterASMTypes); + OperationInfo operationInfo =3D new OperationInfo(operationDesc, u= sesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, meth= odDesc); + return operationInfo; + } + + public OperationDesc buildOperationDesc() throws DeploymentException { + if (built) { + return operationDesc; + } + built =3D true; + + // Set to 'document' or 'rpc' + Style style =3D Style.getStyle(soapOperation.getStyle(), defaultSt= yle); + operationDesc.setStyle(style); + + // Set to 'encoded' or 'literal' + Use use =3D Use.getUse(soapBody.getUse()); + operationDesc.setUse(use); + + + boolean isWrappedElement =3D methodMapping.isSetWrappedElement(); + + MethodParamPartsMappingType[] paramMappings =3D methodMapping.getM= ethodParamPartsMappingArray(); + + /* Put the ParameterDesc instance in an array so they can be order= ed properly + * before they are added to the the OperationDesc. + */ + ParameterDesc[] parameterDescriptions =3D new ParameterDesc[paramM= appings.length]; + + + // MAP PARAMETERS + for (int i =3D 0; i < paramMappings.length; i++) { + MethodParamPartsMappingType paramMapping =3D paramMappings[i]; + int position =3D paramMapping.getParamPosition().getBigInteger= Value().intValue(); + + ParameterDesc parameterDesc =3D mapParameter(paramMapping, isW= rappedElement); + + parameterDescriptions[position] =3D parameterDesc; + } + + //check that all input message parts are mapped + if (!inParamNames.equals(input.getParts().keySet())) { + throw new DeploymentException("Not all input message parts wer= e mapped for operation name" + operationName); + } + + //check that all the parameters are there + for (int i =3D 0; i < parameterDescriptions.length; i++) { + ParameterDesc parameterDescription =3D parameterDescriptions[i= ]; + if (parameterDescription =3D=3D null) { + throw new DeploymentException("There is no mapping for par= ameter number " + i + " for operation " + operationName); + } + operationDesc.addParameter(parameterDescription); + } + + // MAP RETURN TYPE + if (methodMapping.isSetWsdlReturnValueMapping()) { + mapReturnType(); + + } + + if (output !=3D null && !outParamNames.equals(output.getParts().ke= ySet())) { + throw new DeploymentException("Not all output message parts we= re mapped to parameters or a return value for operation " + operationName); + } + + Map faultMap =3D operation.getFaults(); + for (Iterator iterator =3D faultMap.entrySet().iterator(); iterato= r=2EhasNext();) { + Map.Entry entry =3D (Map.Entry) iterator.next(); + String faultName =3D (String) entry.getKey(); + Fault fault =3D (Fault) entry.getValue(); + FaultDesc faultDesc =3D mapException(faultName, fault); + + operationDesc.addFault(faultDesc); + } + return operationDesc; + } + + private FaultDesc mapException(String faultName, Fault fault) throws D= eploymentException { + Message message =3D fault.getMessage(); + QName messageQName =3D message.getQName(); + ExceptionMappingType exceptionMapping =3D (ExceptionMappingType) e= xceptionMap.get(messageQName); + if (exceptionMapping =3D=3D null) { + throw new DeploymentException("No exception mapping for fault = " + faultName + " and fault message " + messageQName + " for operation " + = operationName); + } + String className =3D exceptionMapping.getExceptionType().getString= Value().trim(); + //this is weird, but I can't figure out what it should be. + QName faultQName =3D new QName("", faultName); + Part part; + if (exceptionMapping.isSetWsdlMessagePartName()) { + //According to schema documentation, this will only be set whe= n several headerfaults use the same message. + String headerFaultMessagePartName =3D exceptionMapping.getWsdl= MessagePartName().getStringValue(); + part =3D message.getPart(headerFaultMessagePartName); + } else { + part =3D (Part) message.getOrderedParts(null).iterator().next(= ); + } + QName faultTypeQName =3D part.getElementName() =3D=3D null ? part.= getTypeName() : part.getElementName(); + boolean isComplex =3D faultTypeQName !=3D null && complexTypeMap.c= ontainsKey(faultTypeQName); + FaultDesc faultDesc =3D new FaultDesc(faultQName, className, fault= TypeQName, isComplex); + + //constructor parameters + if (exceptionMapping.isSetConstructorParameterOrder()) { + if (!isComplex) { + throw new DeploymentException("ConstructorParameterOrder c= an only be set for complex types, not " + faultTypeQName); + } + SchemaType complexType =3D (SchemaType) complexTypeMap.get(fau= ltTypeQName); + Map elementMap =3D new HashMap(); + SchemaProperty[] properties =3D complexType.getProperties(); + for (int i =3D 0; i < properties.length; i++) { + SchemaProperty property =3D properties[i]; + QName elementName =3D property.getName(); + SchemaType elementType =3D property.getType(); + QName elementTypeQName =3D elementType.getName(); + elementMap.put(elementName.getLocalPart(), elementTypeQNam= e); + } +// LocalElement[] elements =3D explicitGroup.getElementArra= y(); +// for (int i =3D 0; i < elements.length; i++) { +// LocalElement element =3D elements[i]; +// String elementName =3D element.getName(); +// QName elementType =3D element.getType(); +// elementMap.put(elementName, elementType); +// } + ArrayList parameterTypes =3D new ArrayList(); + ConstructorParameterOrderType constructorParameterOrder =3D ex= ceptionMapping.getConstructorParameterOrder(); + for (int i =3D 0; i < constructorParameterOrder.getElementName= Array().length; i++) { + String elementName =3D constructorParameterOrder.getElemen= tNameArray(i).getStringValue().trim(); + QName elementType =3D (QName) elementMap.get(elementName); + String javaElementTypeName; + if (complexTypeMap.containsKey(elementType)) { + String packageName =3D WSDescriptorParser.getPackageFr= omNamespace(elementType.getNamespaceURI(), mapping); + javaElementTypeName =3D packageName + "." + elementTyp= e=2EgetLocalPart(); + } else { + //TODO finish this + if (elementType.getLocalPart().equals("String")) { + javaElementTypeName =3D String.class.getName(); + } else { + throw new DeploymentException("most simple excepti= on constructor types not yet implemented"); + } + } + Class javaElementType; + try { + javaElementType =3D ClassLoading.loadClass(javaElement= TypeName, classLoader); + } catch (ClassNotFoundException e) { + throw new DeploymentException("Could not load exceptio= n constructor parameter", e); + } + //todo faultTypeQName is speculative + //todo outheader might be true! + ParameterDesc parameterDesc =3D new ParameterDesc(faultTyp= eQName, ParameterDesc.OUT, elementType, javaElementType, false, false); + parameterTypes.add(parameterDesc); + } + faultDesc.setParameters(parameterTypes); + } + return faultDesc; + } + + private void mapReturnType() throws DeploymentException { + QName returnType =3D null; + QName returnQName =3D null; + Class returnClass =3D null; + + if (output =3D=3D null) { + throw new DeploymentException("No output message, but a mappin= g for it for operation " + operationName); + } + WsdlReturnValueMappingType wsdlReturnValueMapping =3D methodMappin= g=2EgetWsdlReturnValueMapping(); + String returnClassName =3D wsdlReturnValueMapping.getMethodReturnV= alue().getStringValue().trim(); + try { + returnClass =3D ClassLoading.loadClass(returnClassName, classL= oader); + } catch (ClassNotFoundException e) { + throw new DeploymentException("Could not load return type for = operation " + operationName, e); + } + + QName wsdlMessageQName =3D wsdlReturnValueMapping.getWsdlMessage()= .getQNameValue(); + + if (!wsdlMessageQName.equals(output.getQName())) { + throw new DeploymentException("OutputMessage has QName: " + ou= tput.getQName() + " but mapping specifies: " + wsdlMessageQName + " for ope= ration " + operationName); + } + + if (wsdlReturnValueMapping.isSetWsdlMessagePartName()) { + String wsdlMessagePartName =3D wsdlReturnValueMapping.getWsdlM= essagePartName().getStringValue().trim(); + if (outParamNames.contains(wsdlMessagePartName)) { + throw new DeploymentException("output message part " + wsd= lMessagePartName + " has both an INOUT or OUT mapping and a return value ma= pping for operation " + operationName); + } + Part part =3D output.getPart(wsdlMessagePartName); + returnQName =3D part.getElementName(); + returnType =3D part.getTypeName(); + + outParamNames.add(wsdlMessagePartName); + + } else { + //what does this mean???? + } + + operationDesc.setReturnQName(returnQName); + operationDesc.setReturnType(returnType); + operationDesc.setReturnClass(returnClass); + } + + private ParameterDesc mapParameter(MethodParamPartsMappingType paramMa= pping, boolean wrappedElement) throws DeploymentException { + WsdlMessageMappingType wsdlMessageMappingType =3D paramMapping.get= WsdlMessageMapping(); + QName wsdlMessageQName =3D wsdlMessageMappingType.getWsdlMessage()= .getQNameValue(); + String wsdlMessagePartName =3D wsdlMessageMappingType.getWsdlMessa= gePartName().getStringValue().trim(); + + String parameterMode =3D wsdlMessageMappingType.getParameterMode()= .getStringValue().trim(); + byte mode =3D ParameterDesc.modeFromString(parameterMode); + boolean isInParam =3D mode =3D=3D ParameterDesc.IN || mode =3D=3D = ParameterDesc.INOUT; + boolean isOutParam =3D mode =3D=3D ParameterDesc.OUT || mode =3D= =3D ParameterDesc.INOUT; + + if (isOutParam && output =3D=3D null) { + throw new DeploymentException("Mapping for output parameter " = + wsdlMessagePartName + " found, but no output message for operation " + op= erationName); + } + boolean isSoapHeader =3D wsdlMessageMappingType.isSetSoapHeader(); + boolean inHeader =3D isSoapHeader && isInParam; + boolean outHeader =3D isSoapHeader && isOutParam; + + Part part; + if (isInParam) { + if (!wsdlMessageQName.equals(input.getQName())) { + throw new DeploymentException("QName of input message: " += input.getQName() + + " does not match mapping message QName: " + wsdlMe= ssageQName + " for operation " + operationName); + } + part =3D input.getPart(wsdlMessagePartName); + if (part =3D=3D null) { + throw new DeploymentException("No part for wsdlMessagePart= Name " + wsdlMessagePartName + " in input message for operation " + operati= onName); + } + inParamNames.add(wsdlMessagePartName); + if (isOutParam) { + //inout, check that part of same name and type is in outpu= t message + Part outPart =3D output.getPart(wsdlMessagePartName); + if (outPart =3D=3D null) { + throw new DeploymentException("No part for wsdlMessage= PartName " + wsdlMessagePartName + " in output message for INOUT parameter = of operation " + operationName); + } + if (!part.getName().equals(outPart.getName())) { + throw new DeploymentException("Mismatched input part n= ame: " + part.getName() + " and output part name: " + outPart.getName() + "= for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " fo= r operation " + operationName); + } + if (!(part.getElementName() =3D=3D null ? outPart.getEleme= ntName() =3D=3D null : part.getElementName().equals(outPart.getElementName(= )))) { + throw new DeploymentException("Mismatched input part e= lement name: " + part.getElementName() + " and output part element name: " = + outPart.getElementName() + " for INOUT parameter for wsdlMessagePartName = " + wsdlMessagePartName + " for operation " + operationName); + } + if (!(part.getTypeName() =3D=3D null ? outPart.getTypeName= () =3D=3D null : part.getTypeName().equals(outPart.getTypeName()))) { + throw new DeploymentException("Mismatched input part t= ype name: " + part.getTypeName() + " and output part type name: " + outPart= .getTypeName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMess= agePartName + " for operation " + operationName); + } + outParamNames.add(wsdlMessagePartName); + } + } else if (isOutParam) { + if (!wsdlMessageQName.equals(output.getQName())) { + throw new DeploymentException("QName of output message: " = + output.getQName() + + " does not match mapping message QName: " + wsdlMe= ssageQName + " for operation " + operationName); + } + part =3D output.getPart(wsdlMessagePartName); + if (part =3D=3D null) { + throw new DeploymentException("No part for wsdlMessagePart= Name " + wsdlMessagePartName + " in output message for operation " + operat= ionName); + } + outParamNames.add(wsdlMessagePartName); + } else { + throw new AssertionError("a param mapping has to be IN or OUT = or INOUT"); + } + + //TODO this makes little sense but may be correct, see comments in= axis Parameter class + //the part name qname is really odd. + QName partQName =3D wrappedElement ? part.getElementName() : new Q= Name("", part.getName()); + QName partTypeQName =3D part.getTypeName(); + + //use complexTypeMap + boolean isComplexType =3D complexTypeMap.containsKey(partTypeQName= ); + String paramJavaTypeName =3D paramMapping.getParamType().getString= Value().trim(); + boolean isInOnly =3D mode =3D=3D ParameterDesc.IN; + Class actualParamJavaType =3D WSDescriptorParser.getHolderType(par= amJavaTypeName, isInOnly, partTypeQName, isComplexType, mapping, classLoade= r); + + ParameterDesc parameterDesc =3D new ParameterDesc(partQName, mode,= partTypeQName, actualParamJavaType, inHeader, outHeader); + return parameterDesc; + } +} Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axi= s/builder/LightweightOperationDescBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/= java/org/apache/geronimo/axis/builder/LightweightOperationDescBuilder.java?= view=3Dauto&rev=3D155737 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/LightweightOperationDescBuilder.java (added) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/LightweightOperationDescBuilder.java Mon Feb 28 18:36:44 2005 @@ -0,0 +1,133 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.axis.builder; + +import java.lang.reflect.Method; +import java.util.List; +import java.util.Iterator; + +import javax.xml.namespace.QName; +import javax.wsdl.Part; +import javax.wsdl.BindingOperation; +import javax.wsdl.Operation; +import javax.wsdl.Message; +import javax.wsdl.extensions.soap.SOAPOperation; + +import org.apache.geronimo.axis.client.OperationInfo; +import org.apache.geronimo.common.DeploymentException; +import org.apache.axis.soap.SOAPConstants; +import org.apache.axis.description.OperationDesc; +import org.apache.axis.description.ParameterDesc; +import org.apache.axis.constants.Style; +import org.apache.axis.constants.Use; +import org.objectweb.asm.Type; + +public class LightweightOperationDescBuilder extends OperationDescBuilder { + + private final Method method; + + public LightweightOperationDescBuilder(BindingOperation bindingOperati= on, Method method) throws DeploymentException{ + super(bindingOperation); + if (bindingOperation =3D=3D null) { + throw new DeploymentException("No BindingOperation supplied fo= r method " + method.getName()); + } + + this.method =3D method; + + operationDesc.setName(operationName); + operationDesc.setStyle(Style.RPC); + operationDesc.setUse(Use.ENCODED); + } + + public OperationInfo buildOperationInfo(SOAPConstants soapVersion) thr= ows DeploymentException { + buildOperationDesc(); + String soapActionURI =3D soapOperation.getSoapActionURI(); + boolean usesSOAPAction =3D (soapActionURI !=3D null); + QName operationQName =3D new QName("", operation.getName()); + + String methodName =3D method.getName(); + String methodDesc =3D Type.getMethodDescriptor(method); + + + OperationInfo operationInfo =3D new OperationInfo(operationDesc, u= sesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, meth= odDesc); + return operationInfo; + } + + public OperationDesc buildOperationDesc() throws DeploymentException { + if (built) { + return operationDesc; + } + + built =3D true; + + //section 7.3.2, we don't have to look at parameter ordering. + //unless it turns out we have to validate it. +// List order =3D operation.getParameterOrdering(); + + // Verify we have the right number of args for this method + Class[] methodParamTypes =3D method.getParameterTypes(); + List inputParts =3D input.getOrderedParts(null); + if (methodParamTypes.length !=3D inputParts.size()) { + throw new DeploymentException("mismatch in parameter counts: m= ethod has " + methodParamTypes.length + " whereas the input message has " += inputParts.size()); + } + + // Map the input parts to method args + int i =3D 0; + for (Iterator parts =3D inputParts.iterator(); parts.hasNext();) { + Part part =3D (Part) parts.next(); + String partName =3D part.getName(); + QName name =3D new QName("", partName); + byte mode =3D ParameterDesc.IN; + QName typeQName =3D part.getTypeName() =3D=3D null ? part.getE= lementName() : part.getTypeName(); + Class javaClass =3D methodParamTypes[i++]; + //lightweight mapping has no parts in headers, so inHeader and= outHeader are false + ParameterDesc parameter =3D new ParameterDesc(name, mode, type= QName, javaClass, false, false); + operationDesc.addParameter(parameter); + } + + // Can't have multiple return values + if (output !=3D null && output.getParts().size() > 1) { + throw new DeploymentException("Lightweight mapping has at most= one part in the (optional) output message, not: " + output.getParts().size= ()); + } + + // Map the return message, if there is one + if (output !=3D null && output.getParts().size() =3D=3D 1) { + // Set the element name + operationDesc.setReturnQName(output.getQName()); + + // Set the element type + Part part =3D (Part) output.getParts().values().iterator().nex= t(); + QName returnType =3D part.getTypeName() =3D=3D null ? part.get= ElementName() : part.getTypeName(); + operationDesc.setReturnType(returnType); + + // Set the java class + operationDesc.setReturnClass(method.getReturnType()); + } + + //TODO add faults +// TFault[] faults =3D tOperation.getFaultArray(); +// for (int i =3D 0; i < faults.length; i++) { +// TFault fault =3D faults[i]; +// QName faultQName =3D new QName("", fault.getName()); +// String className =3D ; +// QName faultTypeQName =3D ; +// boolean isComplex =3D ; +// FaultDesc faultDesc =3D new FaultDesc(faultQName, className,= faultTypeQName, isComplex) +// } + return operationDesc; + } +} Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axi= s/builder/OperationDescBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/= java/org/apache/geronimo/axis/builder/OperationDescBuilder.java?view=3Dauto= &rev=3D155737 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/OperationDescBuilder.java (added) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/OperationDescBuilder.java Mon Feb 28 18:36:44 2005 @@ -0,0 +1,53 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.axis.builder; + +import javax.wsdl.BindingOperation; +import javax.wsdl.Operation; +import javax.wsdl.Message; +import javax.wsdl.extensions.soap.SOAPOperation; + +import org.apache.geronimo.axis.client.OperationInfo; +import org.apache.geronimo.common.DeploymentException; +import org.apache.axis.soap.SOAPConstants; +import org.apache.axis.description.OperationDesc; + +public abstract class OperationDescBuilder { + protected final OperationDesc operationDesc; + protected final BindingOperation bindingOperation; + protected final Operation operation; + protected final String operationName; + protected final Message input; + protected final Message output; + protected final SOAPOperation soapOperation; + protected boolean built; + + public OperationDescBuilder(BindingOperation bindingOperation) throws = DeploymentException { + this.bindingOperation =3D bindingOperation; + this.operation =3D bindingOperation.getOperation(); + this.soapOperation =3D (SOAPOperation) WSDescriptorParser.getExten= sibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityEleme= nts()); + + operationDesc =3D new OperationDesc(); + output =3D operation.getOutput() =3D=3D null ? null : operation.ge= tOutput().getMessage(); + operationName =3D operation.getName(); + input =3D operation.getInput().getMessage(); + } + + public abstract OperationInfo buildOperationInfo(SOAPConstants soapVer= sion) throws DeploymentException; + + public abstract OperationDesc buildOperationDesc() throws DeploymentEx= ception; +} Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axi= s/builder/TypeDescBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/= java/org/apache/geronimo/axis/builder/TypeDescBuilder.java?view=3Dauto&rev= =3D155737 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/TypeDescBuilder.java (added) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/b= uilder/TypeDescBuilder.java Mon Feb 28 18:36:44 2005 @@ -0,0 +1,101 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.axis.builder; + +import java.beans.PropertyDescriptor; +import java.beans.Introspector; +import java.beans.IntrospectionException; +import java.util.Map; +import java.util.HashMap; +import javax.xml.namespace.QName; + +import org.apache.axis.description.TypeDesc; +import org.apache.axis.description.FieldDesc; +import org.apache.axis.description.AttributeDesc; +import org.apache.axis.description.ElementDesc; +import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType; +import org.apache.geronimo.xbeans.j2ee.VariableMappingType; +import org.apache.geronimo.common.DeploymentException; +import org.apache.xmlbeans.SchemaType; + +public class TypeDescBuilder { + public static TypeDesc getTypeDescriptor(Class javaClass, QName typeQN= ame, JavaXmlTypeMappingType javaXmlTypeMapping, SchemaType schemaType) thro= ws DeploymentException { + boolean isRestriction =3D schemaType.getDerivationType() =3D=3D Sc= hemaType.DT_RESTRICTION; + TypeDesc typeDesc =3D new TypeDesc(javaClass, !isRestriction); + //TODO typeQName may be a 'anonymous" QName like construct. Is th= is what axis expects? + typeDesc.setXmlType(typeQName); + VariableMappingType[] variableMappings =3D javaXmlTypeMapping.getV= ariableMappingArray(); + FieldDesc[] fields =3D new FieldDesc[variableMappings.length]; + + PropertyDescriptor[] propertyDescriptors =3D new PropertyDescripto= r[0]; + try { + propertyDescriptors =3D Introspector.getBeanInfo(javaClass).ge= tPropertyDescriptors(); + } catch (IntrospectionException e) { + throw new DeploymentException("Class " + javaClass + " is not = a valid javabean", e); + } + Map properties =3D new HashMap(); + for (int i =3D 0; i < propertyDescriptors.length; i++) { + PropertyDescriptor propertyDescriptor =3D propertyDescriptors[= i]; + properties.put(propertyDescriptor.getName(), propertyDescripto= r=2EgetPropertyType()); + } + for (int i =3D 0; i < variableMappings.length; i++) { + VariableMappingType variableMapping =3D variableMappings[i]; + String fieldName =3D variableMapping.getJavaVariableName().get= StringValue().trim(); + + if (variableMapping.isSetXmlAttributeName()) { + AttributeDesc attributeDesc =3D new AttributeDesc(); + //setting attribute name sets the xmlName with "" namespac= e, so don't do it +// attributeDesc.setAttributeName(fieldName); + attributeDesc.setFieldName(fieldName); + Class javaType =3D (Class) properties.get(fieldName); + if (javaType =3D=3D null) { + throw new DeploymentException("field name " + fieldNam= e + " not found in " + properties); + } + attributeDesc.setJavaType(javaType); + //TODO correct namespace??? + String namespace =3D ""; + QName xmlName =3D new QName(namespace, variableMapping.get= XmlAttributeName().getStringValue().trim()); + attributeDesc.setXmlName(xmlName); + QName xmlType =3D schemaType.getName(); + attributeDesc.setXmlType(xmlType); + fields[i] =3D attributeDesc; + } else { + ElementDesc elementDesc =3D new ElementDesc(); + elementDesc.setFieldName(fieldName); + Class javaType =3D (Class) properties.get(fieldName); + if (javaType =3D=3D null) { + throw new DeploymentException("field name " + fieldNam= e + " not found in " + properties); + } + elementDesc.setJavaType(javaType); + //TODO correct namespace??? + String namespace =3D ""; + QName xmlName =3D new QName(namespace, variableMapping.get= XmlElementName().getStringValue().trim()); + elementDesc.setXmlName(xmlName); + QName xmlType =3D schemaType.getName(); + elementDesc.setXmlType(xmlType); + //TODO figure out how to find these: +// elementDesc.setArrayType(null); +// elementDesc.setMinOccurs(0); +// elementDesc.setMaxOccurs(0); +// elementDesc.setNillable(false); + fields[i] =3D elementDesc; + } + } + typeDesc.setFields(fields); + return typeDesc; + } +}