Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 68626 invoked by uid 500); 1 Jan 2003 17:45:53 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 68617 invoked by uid 500); 1 Jan 2003 17:45:53 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 1 Jan 2003 17:45:52 -0000 Message-ID: <20030101174552.52891.qmail@icarus.apache.org> From: gdaniels@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/src/org/apache/axis/description ServiceDesc.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N gdaniels 2003/01/01 09:45:52 Modified: java/src/org/apache/axis/description ServiceDesc.java Log: Fix bugs: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13146 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11766 Be more careful about matching overloaded methods with operations. Now if we find a method which works, but only by using conversion, we continue scanning to try and find a better match. This seems to clear up the overloaded WSDL generation problems that James Black was seeing, and since we only need to do it once, the performance hit won't be very noticeable. Revision Changes Path 1.70 +40 -17 xml-axis/java/src/org/apache/axis/description/ServiceDesc.java Index: ServiceDesc.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- ServiceDesc.java 11 Dec 2002 22:38:13 -0000 1.69 +++ ServiceDesc.java 1 Jan 2003 17:45:52 -0000 1.70 @@ -597,11 +597,16 @@ return; // Find the method. We do this once for each Operation. + Method [] methods = implClass.getDeclaredMethods(); + // A place to keep track of possible matches + Method possibleMatch = null; + for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (Modifier.isPublic(method.getModifiers()) && - method.getName().equals(oper.getName())) { + method.getName().equals(oper.getName()) && + method2OperationMap.get(method) == null) { if (style == Style.MESSAGE) { int messageOperType = checkMessageMethod(method); @@ -618,23 +623,24 @@ continue; int j; + boolean conversionNecessary = false; for (j = 0; j < paramTypes.length; j++) { Class type = paramTypes[j]; - Class heldType = type; + Class actualType = type; if (Holder.class.isAssignableFrom(type)) { - heldType = JavaUtils.getHolderValueType(type); + actualType = JavaUtils.getHolderValueType(type); } ParameterDesc param = oper.getParameter(j); QName typeQName = param.getTypeQName(); if (typeQName == null) { // No typeQName is available. Set it using - // information from the held type. + // information from the actual type. // (Scenarios B and D) // There is no need to try and match with // the Method parameter javaType because // the ParameterDesc is being constructed // by introspecting the Method. - typeQName = tm.getTypeQName(heldType); + typeQName = tm.getTypeQName(actualType); param.setTypeQName(typeQName); } else { // A type qname is available. @@ -655,9 +661,14 @@ // This is a match if the paramClass is somehow // convertable to the "real" parameter type. If not, // break out of this loop. - if (!JavaUtils.isConvertable(paramClass, heldType)) { + if (!JavaUtils.isConvertable(paramClass, actualType)) { break; } + + if (!actualType.isAssignableFrom(paramClass)) { + // This doesn't fit without conversion + conversionNecessary = true; + } } // In all scenarios the ParameterDesc javaType is set to // match the javaType in the corresponding parameter. @@ -669,20 +680,32 @@ // failed. continue; } + + // This is our latest possibility + possibleMatch = method; - oper.setReturnClass(method.getReturnType()); + // If this is exactly it, stop now. Otherwise keep looking + // just in case we find a better match. + if (!conversionNecessary) { + break; + } - // Do the faults - createFaultMetadata(method, oper); - - // At some point we might want to check here to see if this - // Method is already associated with another Operation, but - // this doesn't seem critital. - - oper.setMethod(method); - method2OperationMap.put(method, oper); - return; } + } + + // At this point, we may or may not have a possible match. + // FIXME : Should we prefer an exact match from a base class over + // a with-conversion match from the target class? If so, + // we'll need to change the logic below. + if (possibleMatch != null) { + oper.setReturnClass(possibleMatch.getReturnType()); + + // Do the faults + createFaultMetadata(possibleMatch, oper); + + oper.setMethod(possibleMatch); + method2OperationMap.put(possibleMatch, oper); + return; } // Didn't find a match. Try the superclass, if appropriate