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 wh...@apache.org on 2002/10/15 15:15:26 UTC

cvs commit: xml-axis-wsif/java/src/org/apache/wsif/base WSIFClientProxy.java

whitlock    2002/10/15 06:15:26

  Modified:    java/src/org/apache/wsif/base WSIFClientProxy.java
  Log:
  Fix OperationKey's
  
  Revision  Changes    Path
  1.9       +115 -64   xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java
  
  Index: WSIFClientProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- WSIFClientProxy.java	15 Oct 2002 05:13:55 -0000	1.8
  +++ WSIFClientProxy.java	15 Oct 2002 13:15:26 -0000	1.9
  @@ -114,7 +114,6 @@
       protected WSIFPort wsifport = null;
       protected Object proxy = null;
       private Map wsdlOperationTable = null;
  -    private StringBuffer sb = null;
   
       /**
        * Factory method to create a new dynamic proxy.
  @@ -205,8 +204,7 @@
           this.portType = WSIFUtils.selectPortType(def, portTypeNS, portTypeName);
   
           simpleTypeReg = WSIFUtils.getSimpleTypesMap();
  -	wsdlOperationTable = new HashMap();
  -	sb = new StringBuffer();
  +        wsdlOperationTable = new HashMap();
           Trc.exit();
       }
   
  @@ -240,7 +238,7 @@
           throws WSIFException {
           Trc.entry(this, method, args); // Tracing proxy cause a hang
   
  -        Operation operation = findMatchingOperation(method,args);
  +        Operation operation = findMatchingOperation(method, args);
   
           // Now set up the input and output messages.      
           Input input = operation.getInput();
  @@ -250,8 +248,8 @@
           Message inputMessage = (input == null) ? null : input.getMessage();
           Message outputMessage = (output == null) ? null : output.getMessage();
   
  -	String wsifOpKey = createWSIFOperationKey(method.getName(),inputName,outputName);
  -	WSIFOperation wsifOperation = wsifport.createOperation(method.getName(), inputName, outputName);
  +        WSIFOperation wsifOperation =
  +            wsifport.createOperation(method.getName(), inputName, outputName);
   
           // make the msg names for compiled msgs xxxAnt ask Mark why diff from inputName 
           String inputMsgName = "";
  @@ -273,14 +271,15 @@
           }
   
           // There must be an inputMessage.
  -	WSIFMessage wsifInputMessage = wsifOperation.createInputMessage(inputMsgName);
  +        WSIFMessage wsifInputMessage =
  +            wsifOperation.createInputMessage(inputMsgName);
   
           // There may not be an output message.
           WSIFMessage wsifOutputMessage = null;
           WSIFMessage wsifFaultMessage = null;
           if (output != null) {
  -	    wsifOutputMessage = wsifOperation.createOutputMessage(inputMsgName);
  -	    wsifFaultMessage = wsifOperation.createFaultMessage(inputMsgName);
  +            wsifOutputMessage = wsifOperation.createOutputMessage(inputMsgName);
  +            wsifFaultMessage = wsifOperation.createFaultMessage(inputMsgName);
           }
   
           Iterator partIt = inputMessage.getOrderedParts(null).iterator();
  @@ -300,14 +299,13 @@
                       wsifOutputMessage,
                       wsifFaultMessage);
               if (!success) {
  -		sb.delete(0,sb.length());
  -		Iterator it = wsifFaultMessage.getPartNames();
  -		while (it.hasNext()) {
  +                StringBuffer sb = new StringBuffer();
  +                Iterator it = wsifFaultMessage.getPartNames();
  +                while (it.hasNext()) {
                       String name = (String) it.next();
  -		    //String buf = "";
  -		    sb.append(name).append(":").
  -			append(wsifFaultMessage.getObjectPart(name)).append(" ");
  -                    //buff += buff + name + ": " +  + " ";
  +                    sb.append(name).append(":").append(
  +                        wsifFaultMessage.getObjectPart(name)).append(
  +                        " ");
                   }
                   throw new WSIFException(sb.toString());
               }
  @@ -326,12 +324,17 @@
                   // Are there any inout parts? Multiple output-only parts
                   // are not allowed in java. Skip over input-only parts in the message.
                   if (outPartIt.hasNext()) {
  -                    Object[] inPartArr = inputMessage.getOrderedParts(null).toArray();
  +                    Object[] inPartArr =
  +                        inputMessage.getOrderedParts(null).toArray();
                       Part nextOutPart = (Part) outPartIt.next();
   
                       for (argIndex = 0; argIndex < args.length; argIndex++) {
  -                        if (((Part) (inPartArr[argIndex])).getName().equals(nextOutPart.getName())) {
  -                            args[argIndex] = wsifOutputMessage.getObjectPart(nextOutPart.getName());
  +                        if (((Part) (inPartArr[argIndex]))
  +                            .getName()
  +                            .equals(nextOutPart.getName())) {
  +                            args[argIndex] =
  +                                wsifOutputMessage.getObjectPart(
  +                                    nextOutPart.getName());
                               if (outPartIt.hasNext())
                                   nextOutPart = (Part) outPartIt.next();
                               else
  @@ -386,15 +389,19 @@
        * If the WSDL is correct, we do not expect that there will be multiple 
        * exact matches, so we do not test for this.
        */
  -    private Operation findMatchingOperation(Method method, Object[] args) throws WSIFException {
  -	// create a key consisting of the method and these args
  -	String key = createWSDLOperationKey(method,args);
  -	// check if we have found an operation matching the signature of this 
  -	// invocation before
  -	Operation previousOp = (Operation) wsdlOperationTable.get(key);
  -	if (previousOp!=null) {
  -	    return previousOp;
  -	}
  +    private Operation findMatchingOperation(Method method, Object[] args)
  +        throws WSIFException {
  +        	
  +        // create a key consisting of the method and these args
  +        String key = createWSDLOperationKey(method, args);
  +        
  +        // check if we have found an operation matching the signature of this 
  +        // invocation before
  +        Operation previousOp = (Operation) wsdlOperationTable.get(key);
  +        if (previousOp != null) {
  +            return previousOp;
  +        }
  +        
           // Check here that the method is in the interface iface
           Method[] allMethods = iface.getMethods();
           int i;
  @@ -403,7 +410,10 @@
                   break;
           if (i >= allMethods.length || !method.equals(allMethods[i]))
               throw new WSIFException(
  -                "Method " + method.getName() + " is not in interface " + iface.getName());
  +                "Method "
  +                    + method.getName()
  +                    + " is not in interface "
  +                    + iface.getName());
   
           String methodName = method.getName();
           Class[] types = method.getParameterTypes();
  @@ -421,13 +431,14 @@
   
               Input input = operation.getInput();
               Message inputMessage = (input == null) ? null : input.getMessage();
  -            int numInputParts = inputMessage == null ? 0 : inputMessage.getParts().size();
  +            int numInputParts =
  +                inputMessage == null ? 0 : inputMessage.getParts().size();
   
               // Check for a match if neither args nor the operation has any parameters
               if (numInputParts == 0 && types.length == 0) {
  -		wsdlOperationTable.put(key,operation);
  +                wsdlOperationTable.put(key, operation);
                   return operation;
  -	    }
  +            }
   
               // No match if there are different numbers of parameters
               if (numInputParts != types.length)
  @@ -437,23 +448,33 @@
               Iterator partIt = inputMessage.getOrderedParts(null).iterator();
               boolean foundAllArgs = true;
               boolean exactMatchAllArgs = true;
  -            for (int argIndex = 0; partIt.hasNext() && foundAllArgs; argIndex++) {
  +            for (int argIndex = 0;
  +                partIt.hasNext() && foundAllArgs;
  +                argIndex++) {
  +                	
                   Part part = (Part) partIt.next();
                   QName partTypeName = part.getTypeName();
                   boolean foundThisArg = false;
                   boolean exactMatchThisArg = false;
   
                   // Look this parameter up in the typeMap.
  -                for (Iterator mapIt = typeMap.iterator(); mapIt.hasNext() && !foundThisArg;) {
  -                    WSIFDynamicTypeMapping mapping = (WSIFDynamicTypeMapping) mapIt.next();
  +                for (Iterator mapIt = typeMap.iterator();
  +                    mapIt.hasNext() && !foundThisArg;
  +                    ) {
  +                    WSIFDynamicTypeMapping mapping =
  +                        (WSIFDynamicTypeMapping) mapIt.next();
                       if (mapping.getXmlType().equals(partTypeName)) {
  -                        if (mapping.getJavaType().isAssignableFrom(types[argIndex])         ||
  -                           (args[argIndex]!=null &&
  -                            mapping.getJavaType().isAssignableFrom(args[argIndex].getClass()))) {
  +                        if (mapping
  +                            .getJavaType()
  +                            .isAssignableFrom(types[argIndex])
  +                            || (args[argIndex] != null
  +                                && mapping.getJavaType().isAssignableFrom(
  +                                    args[argIndex].getClass()))) {
                               foundThisArg = true;
  -                            if (mapping.getJavaType().equals(types[argIndex]) ||
  -                               (args[argIndex]!=null &&
  -                                mapping.getJavaType().equals(args[argIndex].getClass())))
  +                            if (mapping.getJavaType().equals(types[argIndex])
  +                                || (args[argIndex] != null
  +                                    && mapping.getJavaType().equals(
  +                                        args[argIndex].getClass())))
                                   exactMatchThisArg = true;
                           } else
                               break;
  @@ -461,7 +482,8 @@
                   }
   
                   // Look for a simple type that matches
  -                TypeMapping tm = (TypeMapping) (simpleTypeReg.get(partTypeName));
  +                TypeMapping tm =
  +                    (TypeMapping) (simpleTypeReg.get(partTypeName));
                   if (!foundThisArg && tm != null) {
                       String simpleType = tm.javaType;
                       if (types[argIndex].toString().equals(simpleType)) {
  @@ -472,14 +494,20 @@
                           try // this works for String, Date
                               {
                               Class simpleClass =
  -                                Class.forName(simpleType, true, Thread.currentThread().getContextClassLoader());
  -                            if (simpleClass.isAssignableFrom(types[argIndex])) {
  +                                Class.forName(
  +                                    simpleType,
  +                                    true,
  +                                    Thread
  +                                        .currentThread()
  +                                        .getContextClassLoader());
  +                            if (simpleClass
  +                                .isAssignableFrom(types[argIndex])) {
                                   foundThisArg = true;
                                   if (simpleClass.equals(types[argIndex]))
                                       exactMatchThisArg = true;
                               }
                           } catch (ClassNotFoundException ignored) {
  -                        	Trc.ignoredException(ignored);
  +                            Trc.ignoredException(ignored);
                           }
                   }
   
  @@ -491,9 +519,9 @@
   
               if (foundAllArgs) {
                   if (exactMatchAllArgs) {
  -		    wsdlOperationTable.put(key,operation);
  +                    wsdlOperationTable.put(key, operation);
                       return operation;
  -		}
  +                }
   
                   // if matchingOperation!=null then write trace statement.
                   matchingOperation = operation;
  @@ -501,9 +529,9 @@
           } // end while
   
           if (matchingOperation != null) {
  -	    wsdlOperationTable.put(key,matchingOperation);
  +            wsdlOperationTable.put(key, matchingOperation);
               return matchingOperation;
  -	}
  +        }
   
           // if we get here then we haven't found a matching operation       
           String argString = new String();
  @@ -523,23 +551,46 @@
                   + portType.getQName());
       }
   
  -    public String createWSDLOperationKey(Method method,Object [] args) {
  -	// create a key consisting of the method name and the types of all the args
  -	sb.delete(0,sb.length());
  -	sb.append(method.getName());
  -	if (args!=null) {
  -	    for (int i=0; i<args.length; i++) {
  -		sb.append(args[i].getClass().getName());
  -	    }
  -	}
  -	return sb.toString();
  +    /**
  +     * Create a key consisting of the method name and the types of all the args
  +     */
  +    private String createWSDLOperationKey(Method method, Object[] args) {
  +        Trc.entry(this, method, args);
  +
  +        StringBuffer sb = new StringBuffer();
  +        sb.append(method.getName()).append(":");
  +
  +        Class[] types = method.getParameterTypes();
  +        for (int i = 0; i < types.length; i++)
  +            sb.append(types[i].getName()).append(":");
  +
  +        if (args != null)
  +            for (int i = 0; i < args.length; i++) {
  +                if (args[i] == null)
  +                    sb.append("null");
  +                else
  +                    sb.append(args[i].getClass().getName());
  +                sb.append(":");
  +            }
  +
  +        Trc.exit(sb.toString());
  +        return sb.toString();
       }
   
  -    public String createWSIFOperationKey(String operationName,String inputName,String outputName) {
  -	// create a key consisting of all names concatenated
  -	sb.delete(0,sb.length());
  -	sb.append(operationName).append(inputName).append(outputName);
  -	return sb.toString();
  +    /**
  +     * Create a key consisting of all names concatenated
  +     */
  +    private String createWSIFOperationKey(
  +        String operationName,
  +        String inputName,
  +        String outputName) {
  +        Trc.entry(this,operationName,inputName,outputName);
  +        
  +        StringBuffer sb = new StringBuffer();
  +        sb.append(operationName).append(inputName).append(outputName);
  +        
  +        Trc.exit(sb.toString());
  +        return sb.toString();
       }
   
       public String deep() {