axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava Emitter.java JavaDeployWriter.java JavaSkelWriter.java
Date Sat, 12 Jan 2002 16:31:37 GMT
scheu       02/01/12 08:31:37

  Modified:    java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/utils JavaUtils.java
                        resources.properties
               java/src/org/apache/axis/wsdl WSDL2Java.java
               java/src/org/apache/axis/wsdl/fromJava ClassRep.java
               java/src/org/apache/axis/wsdl/toJava Emitter.java
                        JavaDeployWriter.java JavaSkelWriter.java
  Log:
  The following changes are made to support "lightweight" skeletons and "no skeletons":
  
  1) The runtime automatically does the conversion between Holders <-> Held values.
  
  2) The java RPCProvider runtime automatically constructs Holders for methods that specify
     Holder parameter types prior to invoking the web service method
  
  3) The java RPCProvider runtime automatically constructs response messages by querying
     the Holder arguments after invoking the web service method.
  
  4) The skeleton generated by WSDL2Java is much less complex:
      i) It implements the port type interface.  Thus the port type interface, stub, skeleton,
and
         implementation all have the same operation signatures.
      ii) The skeleton operations simply invoke the implementation and return.
      iii) The skeletons also implement the new org.apache.axis.wsdl.Skeleton interface, which
          provides the skeleton with the parameter part name mappings.  The RPCProvider invokes
          the skeleton to get these names.
  
  5) The new WSDL2Java option -S <true-or-false> indicates whether to deploy the skeleton
or impl.
  
  Revision  Changes    Path
  1.32      +90 -55    xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- RPCProvider.java	20 Dec 2001 14:56:47 -0000	1.31
  +++ RPCProvider.java	12 Jan 2002 16:31:37 -0000	1.32
  @@ -127,8 +127,7 @@
                   }
               }
   
  -			// stays this way if allowedMethods is only one name, not a list
  -			String methodNameMatch = allowedMethods; 
  +            String methodNameMatch = allowedMethods; 
   
               // allowedMethods may be a comma-delimited string of method names.
               // If so, look for the one matching mname.
  @@ -163,13 +162,19 @@
                   category.debug( "MethodName List: " + allowedMethods );
               }
   
  -			///////////////////////////////////////////////////////////////
  -			// If allowedMethods (i.e. methodNameMatch) is null, 
  -			//  then treat it as a wildcard automatically matching mName
  -			///////////////////////////////////////////////////////////////
  -
  -			int			numberOfBodyArgs = args.size();
  -            Method      method = getMethod(jc, mName, args);
  +            ///////////////////////////////////////////////////////////////
  +            // If allowedMethods (i.e. methodNameMatch) is null, 
  +            //  then treat it as a wildcard automatically matching mName
  +            ///////////////////////////////////////////////////////////////
  +
  +            // Get the actual method to invoke.
  +            // Since the method signature may contain output parameters
  +            // (Holders) there is no easy way to match the number of arguments
  +            // to a Method.  Furthermore method overloading does not work in 
  +            // wsdl.  Thus the following code only works if there is no 
  +            // overloading.  
  +            int	numberOfBodyArgs = args.size();
  +            Method method = getMethod(jc, mName, args);
   
               // If the method wasn't found, maybe it needs some Java mangling (ie., it's
a Java
               // keyword or it's capitalized and the java mapping requires lowercase).
  @@ -183,50 +188,46 @@
                           JavaUtils.getMessage("noMethod00", mName, msgContext.getTargetService()),
                           null, null );
               
  -			Class params[] = method.getParameterTypes();
  -			
  -			// if we got the version of the method that takes msgContext,
  -			//   add msgContext to argValues[] 
  -			if ( params.length == numberOfBodyArgs + 1 ) {
  -				Object[] tmpArgs = new Object[numberOfBodyArgs + 1];
  -				for ( int i = 1 ; i <= args.size() ; i++ )
  -				  tmpArgs[i] = argValues[i-1];
  -				tmpArgs[0] = msgContext ;
  -				argValues = tmpArgs ;
  -			}
  -				  
  +            Class params[] = method.getParameterTypes();
   			
  -            /*
  -            for (int i = 0; i < params.length; i++) {
  -              String argClass = argValues[i].getClass().getName();
  -              String tgtClass = params[i].getName();
  -              System.out.println("arg" + i + ": " + argClass + " -> " +
  -                                 tgtClass);
  +
  +            // The number of method parameters must match the 
  +            // arguments taking into consideration a MessageContext argument
  +            // and output parameters.
  +            Object[] newArgValues = new Object[params.length];
  +            int old = 0;
  +            boolean problem = false;
  +            for (int n = 0; n < newArgValues.length; n++) {
  +                Class heldType = JavaUtils.getHolderValueType(params[n]);
  +                if (params[n] == MessageContext.class) {
  +                    newArgValues[n] = msgContext;
  +                } else if (argValues != null && old < argValues.length) {
  +                    newArgValues[n] = argValues[old++];
  +                } else if (heldType == null) {
  +                    // The parameters that don't match the argValues must
  +                    // be Holders.  Indicate problem occurred.
  +                    problem = true;
  +                } else {
  +                    newArgValues[n] = null;
  +                }
  +                // Create holders for each argument that is null that should be a holder
  +                if (newArgValues[n] == null && heldType != null) {
  +                    newArgValues[n] = JavaUtils.convert(newArgValues[n], params[n]);
  +                }
  +            }
  +            if (!problem) {
  +                argValues = newArgValues;  // Use newArgValues array if no problems
               }
  -            */
   
  +            // Invoke the method and capture the returned object.
  +            // Note that if the method returns a primitive, invoke(...) automatically
  +            // wraps it in a java.lang class representing the primitive.
               Object objRes;
               try {
  -                objRes = method.invoke( obj, argValues );
  +                objRes = method.invoke(obj, argValues);
               } catch (IllegalArgumentException e) {
                   
  -                if (argValues == null || argValues.length != params.length) {
  -                    // Sorry, you are on your own...
  -                    StringBuffer msg= new StringBuffer( e.getMessage());
  -                    msg.append( "On object \"" + (obj == null? 
  -                                                  "null" : obj.getClass().getName()) +
"\" ");
  -                    msg.append( "method name \"" + method.getName() + "\"");
  -                    msg.append(" tried argument types: "); 
  -                    String sep= "";
  -                    for(int i=0; i< argValues.length; ++i){
  -                        msg.append( sep);
  -                        sep=", ";
  -                        msg.append( argValues[i] == null ? "null" : argValues[i].getClass().getName());
  -                    }
  -                    msg.append("\n");
  -                    throw new IllegalArgumentException(msg.toString());
  -                    
  -                } else {
  +                {
                       // Hm - maybe we can help this with a conversion or two...
                       for (int i = 0; i < params.length; i++) {
                           Object thisArg = argValues[i];
  @@ -268,6 +269,8 @@
               resBody.setPrefix( body.getPrefix() );
               resBody.setNamespaceURI( body.getNamespaceURI() );
               if ( objRes != null ) {
  +                // In the old skeleton a param list was returned, which 
  +                // contained the RPC params.  Preserve this for now.
                   if (objRes instanceof ParamList) {
                       ParamList list = (ParamList)objRes;
                       for (int i = 0; i < list.size (); ++i) {
  @@ -275,27 +278,59 @@
                               resBody.addParam ((RPCParam) list.get (i));
                           }
                           else {
  -                            resBody.addParam (new RPCParam (mName + "Result" + i,
  -                                list.get (i)));
  +                            resBody.addParam (new RPCParam (getParameterName(obj, method,i,
mName),
  +                                                            list.get (i)));
                           }
                       }
                   }
                   else {
  -                    RPCParam param = new RPCParam(mName + "Result", objRes);
  +                    RPCParam param = new RPCParam(getParameterName(obj, method,-1, mName),
objRes);
                       resBody.addParam(param);
                   }
               } else if (method.getReturnType() != Void.TYPE) {
  -                RPCParam param = new RPCParam(mName + "Result", objRes);
  +                RPCParam param = new RPCParam(getParameterName(obj, method,-1, mName),
objRes);
                   resBody.addParam(param);
               }
   
  +            // The new skeleton (or no skeleton code) requires the runtime
  +            // to recognize holders and automatically pass back the outputs.
  +            for (int i=0; i < argValues.length; i++) {
  +                Class heldType = JavaUtils.getHolderValueType(params[i]);
  +                if (heldType != null) {
  +                    // Create an RPCParam by converting the Holder back into 
  +                    // the held type.
  +                    resBody.addParam (new RPCParam (getParameterName(obj, method, i, mName),
  +                                                    JavaUtils.convert(argValues[i], heldType)));
  +                }
  +            }
  +            
               resEnv.addBodyElement( resBody );
               resEnv.setEncodingStyleURI(Constants.URI_SOAP_ENC);
           }
       }
  -	
  -	protected Method getMethod(JavaClass jc, String mName, Vector args)
  -	{
  -		return jc.getMethod(mName, args.size());
  -	}
  +    
  +    protected Method getMethod(JavaClass jc, String mName, Vector args)
  +    {
  +        return jc.getMethod(mName, args.size());
  +    }
  +
  +    /**
  +     * Returns or creates the parameter name for the i'th parm of 
  +     * of the method specified. 
  +     * (Use i=-1 to access the return name.)
  +     */
  +    protected String getParameterName(Object obj, Method method, int i, String mName) {
  +        String parmName = null;
  +        // Emitter skeletons keep track of the parameter names
  +        if (obj instanceof org.apache.axis.wsdl.Skeleton) 
  +            parmName = ((org.apache.axis.wsdl.Skeleton)obj).getParameterName(method.getName(),
i);
  +        if (parmName == null) {
  +            if (i >= 0) {
  +                parmName = mName + "Result" + i;
  +            } else {
  +                parmName = mName + "Result";  
  +            }
  +        }
  +        return parmName;
  +    }
   }
  
  
  
  1.20      +108 -6    xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JavaUtils.java	20 Dec 2001 14:56:47 -0000	1.19
  +++ JavaUtils.java	12 Jan 2002 16:31:37 -0000	1.20
  @@ -58,11 +58,13 @@
   import org.apache.log4j.Category;
   
   import java.lang.reflect.Array;
  +import java.lang.reflect.Field;
   
   import java.text.Collator;
   import java.text.MessageFormat;
   
   import java.util.Arrays;
  +import java.util.HashMap;
   import java.util.List;
   import java.util.Locale;
   import java.util.MissingResourceException;
  @@ -94,9 +96,9 @@
   
       /** Utility function to convert an Object to some desired Class.
        * 
  -     * Right now this only works for arrays <-> Lists, but it might be
  -     * expanded into a more general form later.
  -     * 
  +     * Right now this works for:
  +     *     arrays <-> Lists,
  +     *     Holders <-> held values
        * @param arg the array to convert
        * @param destClass the actual class we want
        */
  @@ -107,8 +109,6 @@
                   arg.getClass().getName(), destClass.getName()));
           }
           
  -        if (!(arg instanceof List))
  -            return arg;
   
           // See if a previously converted value is stored in the argument.
           Object destValue = null;
  @@ -117,7 +117,44 @@
               if (destValue != null)
                   return destValue;
           }
  -        
  +
  +        // Get the destination held type or the argument held type if they exist
  +        Class destHeldType = getHolderValueType(destClass);
  +        Class argHeldType = null;
  +        if (arg != null) {
  +            argHeldType = getHolderValueType(arg.getClass());
  +        }
  +
  +        // Return if no conversion is available
  +        if (!(arg instanceof List) && 
  +            ((destHeldType == null && argHeldType == null) ||
  +             (destHeldType != null && argHeldType != null))) {
  +            return arg;
  +        }
  +
  +        // Take care of Holder conversion
  +        if (destHeldType != null) {
  +            // Convert arg into Holder holding arg.
  +            Object newArg = convert(arg, destHeldType);
  +            Object argHolder = null;
  +            try {
  +                argHolder = destClass.newInstance();
  +                setHolderValue(argHolder, newArg);
  +                return argHolder;
  +            } catch (Exception e) {
  +                return arg;
  +            }
  +        } else if (argHeldType != null) {
  +            // Convert arg into the held type
  +            try {
  +                Object newArg = getHolderValue(arg);
  +                return convert(newArg, destClass);
  +            } catch (HolderException e) {
  +                return arg;
  +            }
  +        }
  +            
  +        // Flow to here indicates that neither arg or destClass is a Holder
           List list = (List)arg;
           int length = list.size();
           
  @@ -172,6 +209,7 @@
           return destValue;
       }
   
  +
       /**
        * These are java keywords as specified at the following URL (sorted alphabetically).
        * http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#229308
  @@ -375,4 +413,68 @@
   
           return new String(sb);
       }
  +
  +
  +
  +    /**
  +     * Determines if the Class is a Holder class. If so returns Class of held type
  +     * else returns null
  +     * @param type the suspected Holder Class
  +     * @return class of held type or null
  +     */
  +    public static Class getHolderValueType(Class type) {
  +        if (type.getName() != null &&
  +            type.getName().endsWith("Holder")) {
  +            // Holder is supposed to have a public value field.
  +            java.lang.reflect.Field field;
  +            try {
  +                field = type.getField("value");
  +            } catch (Exception e) {
  +                field = null;
  +            }
  +            if (field != null) {
  +                return field.getType();
  +            }
  +        }
  +        return null;
  +    }
  +
  +    /**
  +     * Gets the Holder value. 
  +     * @param holder Holder object            
  +     * @return value object 
  +     */
  +    public static Object getHolderValue(Object holder) throws HolderException {
  +        try {
  +            Field valueField = holder.getClass().getField("value");
  +            return valueField.get(holder);
  +        } catch (Exception e) {
  +            throw new HolderException();
  +        }
  +    }
  +
  +    /**
  +     * Sets the Holder value. 
  +     * @param holder Holder object            
  +     * @param value is the object value 
  +     */
  +    public static void setHolderValue(Object holder, Object value) throws HolderException
{
  +        try {
  +            Field valueField = holder.getClass().getField("value");
  +            if (valueField.getType().isPrimitive()) {
  +                if (value == null)
  +                    ;  // Don't need to set anything
  +                else
  +                    valueField.set(holder, value);  // Automatically unwraps value to primitive
  +            } else {
  +                valueField.set(holder, value);
  +            }
  +        } catch (Exception e) {
  +            throw new HolderException();
  +        }
  +    }
  +    public static class HolderException extends Exception
  +    {
  +        public HolderException () {}
  +    }; 
   }
  
  
  
  1.38      +5 -5      xml-axis/java/src/org/apache/axis/utils/resources.properties
  
  Index: resources.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- resources.properties	11 Jan 2002 21:28:23 -0000	1.37
  +++ resources.properties	12 Jan 2002 16:31:37 -0000	1.38
  @@ -22,12 +22,10 @@
   
   badBool00=Invalid boolean
   
  -# NOTE:  in badCall00 and badCall01, do not translate "Call"
  +# NOTE:  in badCall00, do not translate "Call"
   badCall00=Cannot update the Call object
  -badCall01=Failure trying to get the Call object
  -
  -#NOTE:  in badCall02, do not translate "Call.getOutputParams"
  -badCall02=Invocation of Call.getOutputParams failed
  +badCall01=Cannot update the Call object
  +badCall02=Cannot update the Call object
   
   badChars00=Unexpected characters
   badChars01=Bad character or insufficient number of characters in hex string
  @@ -613,3 +611,5 @@
   j2woptimplClass00=optional class that contains implementation of methods in class-of-portType.
 The debug information in the class is used to obtain the method parameter names, which are
used to set the WSDL part names.
   j2werror00=Error: {0}
   j2wmodeerror=Error Unrecognized Mode: {0} Use All, Interface or Implementation. Continuing
with All. 
  +
  +optionSkeletonDeploy00=(true or false) Indicate whether to deploy skeleton or implementation
class.
  
  
  
  1.5       +28 -0     xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java
  
  Index: WSDL2Java.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSDL2Java.java	10 Jan 2002 20:08:51 -0000	1.4
  +++ WSDL2Java.java	12 Jan 2002 16:31:37 -0000	1.5
  @@ -85,6 +85,7 @@
       protected static final int HELP_OPT = 'h';
       protected static final int VERBOSE_OPT = 'v';
       protected static final int SKELETON_OPT = 's';
  +    protected static final int SKELETON_DEPLOY_OPT = 'S';
       protected static final int NAMESPACE_OPT = 'N';
       protected static final int OUTPUT_OPT = 'o';
       protected static final int SCOPE_OPT = 'd';
  @@ -124,6 +125,10 @@
                   CLOptionDescriptor.ARGUMENT_DISALLOWED,
                   SKELETON_OPT,
                   JavaUtils.getMessage("optionSkel00")),
  +        new CLOptionDescriptor("skeletonDeploy",
  +                CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                SKELETON_DEPLOY_OPT,
  +                JavaUtils.getMessage("optionSkeletonDeploy00")),
           new CLOptionDescriptor("NStoPkg",
                   CLOptionDescriptor.DUPLICATES_ALLOWED + CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
                   NAMESPACE_OPT,
  @@ -185,6 +190,21 @@
       }
   
       /**
  +     * Turn on/off server skeleton deploy
  +     * @param boolean value
  +     */
  +    public void deploySkeleton(boolean value) {
  +        emitter.deploySkeleton(value);
  +    }
  +
  +    /**
  +     * Indicate if we should be deploying skeleton or implementation
  +     */ 
  +    public boolean getDeploySkeleton() {
  +        return emitter.getDeploySkeleton();
  +    }
  +
  +    /**
        * Turn on/off test case creation
        * @param boolean value
        */
  @@ -392,6 +412,14 @@
                       case SKELETON_OPT:
                           bSkeleton = true;
                           wsdl2java.generateSkeleton(true);
  +                        break;
  +
  +                    case SKELETON_DEPLOY_OPT:
  +                        String value = option.getArgument(0);
  +                        if (value.equalsIgnoreCase("true"))
  +                            wsdl2java.deploySkeleton(true);
  +                        else
  +                            wsdl2java.deploySkeleton(false);
                           break;
   
                       case NAMESPACE_OPT:
  
  
  
  1.7       +4 -26     xml-axis/java/src/org/apache/axis/wsdl/fromJava/ClassRep.java
  
  Index: ClassRep.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/ClassRep.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ClassRep.java	10 Jan 2002 22:28:30 -0000	1.6
  +++ ClassRep.java	12 Jan 2002 16:31:37 -0000	1.7
  @@ -61,6 +61,7 @@
   import java.util.HashMap;
   
   import org.apache.axis.utils.JavapUtils;
  +import org.apache.axis.utils.JavaUtils;
   
   /**
    * ClassRep is the representation of a class used inside the Java2WSDL
  @@ -303,8 +304,8 @@
           Class[] types = new Class[method.getParameterTypes().length];
           for (int i=0; i < method.getParameterTypes().length; i++) {
               Class type = method.getParameterTypes()[i];
  -            if (holderClass(type) != null) {
  -                types[i] = holderClass(type);
  +            if (JavaUtils.getHolderValueType(type) != null) {
  +                types[i] = JavaUtils.getHolderValueType(type);
               } else {
                   types[i] = type;
               }
  @@ -322,7 +323,7 @@
           short[] modes = new short[method.getParameterTypes().length];
           for (int i=0; i < method.getParameterTypes().length; i++) {
               Class type = method.getParameterTypes()[i];
  -            if (holderClass(type) != null) {
  +            if (JavaUtils.getHolderValueType(type) != null) {
                   modes[i] = ParamRep.INOUT;
               } else {
                   modes[i] = ParamRep.IN;
  @@ -460,27 +461,4 @@
           return true;
       }
   
  -
  -    /**
  -     * Determines if the Class is a Holder class. If so returns Class of held type
  -     * else returns null
  -     * @param type the Class
  -     * @return class of held type or null
  -     */
  -    protected Class holderClass(Class type) {
  -        if (type.getName() != null &&
  -            type.getName().endsWith("Holder")) {
  -            // Holder is supposed to have a public value field.
  -            java.lang.reflect.Field field;
  -            try {
  -                field = type.getField("value");
  -            } catch (Exception e) {
  -                field = null;
  -            }
  -            if (field != null) {
  -                return field.getType();
  -            }
  -        }
  -        return null;
  -    }
   };
  
  
  
  1.6       +16 -0     xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Emitter.java	10 Jan 2002 20:08:51 -0000	1.5
  +++ Emitter.java	12 Jan 2002 16:31:37 -0000	1.6
  @@ -104,6 +104,7 @@
       protected Definition def = null;
       protected boolean bDebug = false;
       protected boolean bEmitSkeleton = false;
  +    protected boolean bDeploySkeleton = true;  
       protected boolean bEmitTestCase = false;
       protected boolean bVerbose = false;
       protected boolean bGenerateImports = true;
  @@ -262,6 +263,21 @@
        */ 
       public boolean getGenerateSkeleton() {
           return bEmitSkeleton;
  +    }
  +
  +    /**
  +     * Turn on/off server skeleton deploy
  +     * @param boolean value
  +     */
  +    public void deploySkeleton(boolean value) {
  +        bDeploySkeleton = value;
  +    }
  +
  +    /**
  +     * Indicate if we should be deploying skeleton or implementation
  +     */ 
  +    public boolean getDeploySkeleton() {
  +        return bDeploySkeleton;
       }
   
       /**
  
  
  
  1.7       +7 -1      xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JavaDeployWriter.java	10 Jan 2002 20:08:51 -0000	1.6
  +++ JavaDeployWriter.java	12 Jan 2002 16:31:37 -0000	1.7
  @@ -174,8 +174,14 @@
        */
       private void writeDeployBinding(Binding binding) throws IOException {
           BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
  +        String className = bEntry.getName();
  +        if (emitter.getDeploySkeleton())
  +            className += "Skeleton";
  +        else
  +            className += "Impl";
  +
           pw.println("      <parameter name=\"className\" value=\""
  -                         + bEntry.getName() + "Skeleton" + "\"/>");
  +                         + className + "\"/>");
   
           String methodList = "";
           Iterator operationsIterator = binding.getBindingOperations().iterator();
  
  
  
  1.6       +55 -49    xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
  
  Index: JavaSkelWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JavaSkelWriter.java	10 Jan 2002 20:08:51 -0000	1.5
  +++ JavaSkelWriter.java	12 Jan 2002 16:31:37 -0000	1.6
  @@ -106,26 +106,68 @@
               isRPC = false;
           }
   
  +        // The skeleton implements the portType and the WSDL2Java emitter skeleton
           String implType = portTypeName + " impl";
  -        pw.println("public class " + className + " {");
  +        pw.println("public class " + className + " implements " + portTypeName + ",");
  +        pw.println("    org.apache.axis.wsdl.Skeleton {"); 
  +
  +        // Declare private impl and skeleton base delegates
           pw.println("    private " + implType + ";");
  +        pw.println("    private static org.apache.axis.wsdl.SkeletonImpl skel = null;");
           pw.println();
  -            // RJB WARNING! - is this OK?
  +
  +        // Skeleton constructors
           pw.println("    public " + className + "() {");
           pw.println("        this.impl = new " + bEntry.getName() + "Impl();");
  +        pw.println("        init();");
           pw.println("    }");
           pw.println();
           pw.println("    public " + className + "(" + implType + ") {");
           pw.println("        this.impl = impl;");
  +        pw.println("        init();");
           pw.println("    }");
  -        pw.println();
   
  +        // Initialize operation parameter names
  +        pw.println("    public String getParameterName(String opName, int i) {");
  +        pw.println("        return skel.getParameterName(opName, i);");
  +        pw.println("    }");
  +        // Initialize operation parameter names
  +        pw.println("    protected void init() {");
  +        pw.println("        if (skel != null) ");
  +        pw.println("            return;");
  +        pw.println("        skel = new org.apache.axis.wsdl.SkeletonImpl();");
           List operations = binding.getBindingOperations();
           for (int i = 0; i < operations.size(); ++i) {
               BindingOperation operation = (BindingOperation) operations.get(i);
               Parameters parameters =
                       ptEntry.getParameters(operation.getOperation().getName());
   
  +            if (parameters != null) {
  +                // The invoked java name of the operation is stored.
  +                String opName = Utils.xmlNameToJava(operation.getOperation().getName());
  +                pw.println("        skel.add(\"" + opName + "\",");
  +                pw.println("                 new String[] {");
  +                if (parameters.returnType != null) {
  +                    pw.println("                 \"" + parameters.returnName + "\",");
  +                } else {
  +                    pw.println("                 null,");
  +                }
  +                for (int j=0; j < parameters.list.size(); j++) {
  +                    Parameter p = (Parameter) parameters.list.get(j);
  +                    pw.println("                 \"" + p.name + "\",");
  +                }
  +                pw.println("                 });");                
  +            }       
  +        }
  +        pw.println("    }");
  +        pw.println();
  +
  +        // Now write each of the operation methods
  +        for (int i = 0; i < operations.size(); ++i) {
  +            BindingOperation operation = (BindingOperation) operations.get(i);
  +            Parameters parameters =
  +                    ptEntry.getParameters(operation.getOperation().getName());
  +
               // Get the soapAction from the <soap:operation>
               String soapAction = "";
               Iterator operationExtensibilityIterator = operation.getExtensibilityElements().iterator();
  @@ -166,31 +208,19 @@
               boolean isRPC) throws IOException {
           writeComment(pw, operation.getDocumentationElement());
   
  -        pw.println(parms.skelSignature);
  +        // The skeleton used to have specialized operation signatures.
  +        // now the same signature is used as the portType
  +        pw.println(parms.signature);
           pw.println("    {");
   
  -        // Instantiate the holders
  -        for (int i = 0; i < parms.list.size(); ++i) {
  -            Parameter p = (Parameter) parms.list.get(i);
  -
  -            String holder = Utils.holder(p.type, symbolTable);
  -            String holderVar = Utils.xmlNameToJava(p.name);
  -            if (p.mode == Parameter.INOUT) {
  -                pw.println("        " + holder + " " + holderVar
  -                        + "Holder = new " + holder + "(" + holderVar + ");");
  -            }
  -            else if (p.mode == Parameter.OUT) {
  -                pw.println("        " + holder + " " + holderVar
  -                        + "Holder = new " + holder + "();");
  -            }
  -        }
  +        // Note: The holders are now instantiated by the runtime and passed 
  +        // in as parameters.
   
           // Call the real implementation
           if (parms.returnType == null) {
               pw.print("        ");
  -        }
  -        else {
  -            pw.print("        Object ret = ");
  +        } else {
  +            pw.print("        " + parms.returnType.getName() + " ret = ");
           }
           String call = "impl." + Utils.xmlNameToJava(operation.getName()) + "(";
           boolean needComma = false;
  @@ -202,37 +232,13 @@
               Parameter p = (Parameter) parms.list.get(i);
   
               call = call + Utils.xmlNameToJava(p.name);
  -            if (p.mode != Parameter.IN)
  -                call = call + "Holder";
           }
           call = call + ")";
  -        if (parms.returnType == null) {
  -            pw.println(call + ";");
  -        }
  -        else {
  -            pw.println(wrapPrimitiveType(parms.returnType, call) + ";");
  -        }
  +        pw.println(call + ";");
   
  -        // Handle the outputs, if there are any.
  -        if (parms.inouts + parms.outputs > 0) {
  -            pw.println("        org.apache.axis.server.ParamList list = new org.apache.axis.server.ParamList();");
  -            if (parms.returnType != null)
  -                pw.println("        list.add(new org.apache.axis.message.RPCParam(\""
  -                        + parms.returnName + "\", ret));");
  -            for (int i = 0; i < parms.list.size(); ++i) {
  -                Parameter p = (Parameter) parms.list.get(i);
  -
  -                if (p.mode != Parameter.IN) {
  -                    String pName = Utils.xmlNameToJava(p.name);
  -                    pw.println("        list.add(new org.apache.axis.message.RPCParam(\""
  -                            + p.name + "\", "
  -                            + wrapPrimitiveType(p.type, pName + "Holder.value")
  -                            + "));");
  -                }
  -            }
  -            pw.println("        return list;");
  +        if (parms.returnType != null) {
  +            pw.print("        return ret;");
           }
  -
           pw.println("    }");
           pw.println();
       } // writeSkeletonOperation
  
  
  

Mime
View raw message