owenb       2002/11/22 07:55:03

  Modified:    java/src/org/apache/wsif/providers/ejb Tag: pre1_2_0-patches
                        WSIFOperation_EJB.java
               java/src/org/apache/wsif/providers/java Tag:
                        pre1_2_0-patches WSIFOperation_Java.java
  Log:
  When parts are null in the input message, and the service object is expecting a 
primitive type, we cannot use null as the argument value.
  Instead we will use a default object based on the pimitive type for example new 
Integer(0) for int. This avoids a NullPointerException being
  thrown by Method.invoke
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.19.2.3  +29 -1     
xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java
  
  Index: WSIFOperation_EJB.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java,v
  retrieving revision 1.19.2.2
  retrieving revision 1.19.2.3
  diff -u -r1.19.2.2 -r1.19.2.3
  --- WSIFOperation_EJB.java    8 Nov 2002 14:16:43 -0000       1.19.2.2
  +++ WSIFOperation_EJB.java    22 Nov 2002 15:55:03 -0000      1.19.2.3
  @@ -777,7 +777,7 @@
           for (int i = 0; i < parmTypes.length; i++) {
               // If the arg is a null then skip it
               if (args[i] == null) {
  -                compatibleArgs[i] = null;
  +                compatibleArgs[i] = getDefaultObject(parmTypes[i]);
                   continue;
               }
               // Consider the special cas, squeezing a String into a Character
  @@ -846,6 +846,34 @@
               return null;
           return new Character(str.charAt(0));
       }
  +
  +     protected Object getDefaultObject(Class cls) {
  +             if (cls == null) {
  +                     return null;
  +             } else if (cls.isPrimitive()) {
  +                     if (cls.getName().equals("int")) {
  +                             return new Integer(0);
  +                     } else if (cls.getName().equals("char")) {
  +                             return new Character('0');
  +                     } else if (cls.getName().equals("long")) {
  +                             return new Long(0);
  +                     } else if (cls.getName().equals("short")) {
  +                             short s = 0;
  +                             return new Short(s);
  +                     } else if (cls.getName().equals("double")) {
  +                             return new Double(0);
  +                     } else if (cls.getName().equals("boolean")) {
  +                             return new Boolean(false);
  +                     } else if (cls.getName().equals("byte")) {
  +                             byte b = 0;
  +                             return new Byte(b);
  +                     } else {
  +                             return new Float(0);
  +                     }
  +             } else {
  +                     return null;
  +             }
  +     }
   
       protected String getOutputMessageName() throws WSIFException {
           Trc.entry(this);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.21.2.3  +29 -53    
xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
  
  Index: WSIFOperation_Java.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java,v
  retrieving revision 1.21.2.2
  retrieving revision 1.21.2.3
  diff -u -r1.21.2.2 -r1.21.2.3
  --- WSIFOperation_Java.java   8 Nov 2002 14:16:43 -0000       1.21.2.2
  +++ WSIFOperation_Java.java   22 Nov 2002 15:55:03 -0000      1.21.2.3
  @@ -751,7 +751,7 @@
           for (int i = 0; i < parmTypes.length; i++) {
               // If the arg is a null then skip it
               if (args[i] == null) {
  -                compatibleArgs[i] = null;
  +                compatibleArgs[i] = getDefaultObject(parmTypes[i]);
                   continue;
               }
               // Consider the special cas, squeezing a String into a Character
  @@ -819,6 +819,34 @@
           return new Character(str.charAt(0));
       }
   
  +     protected Object getDefaultObject(Class cls) {
  +             if (cls == null) {
  +                     return null;
  +             } else if (cls.isPrimitive()) {
  +                     if (cls.getName().equals("int")) {
  +                             return new Integer(0);
  +                     } else if (cls.getName().equals("char")) {
  +                             return new Character('0');
  +                     } else if (cls.getName().equals("long")) {
  +                             return new Long(0);
  +                     } else if (cls.getName().equals("short")) {
  +                             short s = 0;
  +                             return new Short(s);
  +                     } else if (cls.getName().equals("double")) {
  +                             return new Double(0);
  +                     } else if (cls.getName().equals("boolean")) {
  +                             return new Boolean(false);
  +                     } else if (cls.getName().equals("byte")) {
  +                             byte b = 0;
  +                             return new Byte(b);
  +                     } else {
  +                             return new Float(0);
  +                     }
  +             } else {
  +                     return null;
  +             }
  +     }
  +
       protected String getOutputMessageName() throws WSIFException {
        Trc.entry(this);
           if (fieldOutputMessageName == null) {
  @@ -831,58 +859,6 @@
           Trc.exit(fieldOutputMessageName);
           return fieldOutputMessageName;
       }
  -
  -//    /**
  -//     * Emulates asynchronous operation by executing a
  -//     * requestResponseOperation on a seperate thread.
  -//     * ???ant??? Doesn't need to use the CorrelationService
  -//     *           or Listener so is there much point?
  -//     * @param input   input message to send to the operation
  -//     * @param handler   the response handler that will be notified 
  -//     *             when the asynchronous response becomes available.
  -//     *
  -//     * @return the correlation ID or the request. The correlation ID
  -//     *         is used to associate the request with the WSIFOperation.
  -//     *
  -//     * @exception WSIFException if something goes wrong.
  -//     * @see WSIFOperation#executeRequestResponseAsync()
  -//     * ???ant??? need to think about the copy of the WSIFOp
  -//     * @see WSIFOperation#executeRequestResponseAsync()
  -//     */
  -
  -    /* ***************Not supported yet
  -        
  -        public Serializable executeRequestResponseAsync(final WSIFMessage input,
  -                                                      final WSIFResponseHandler 
handler)
  -                                                      throws WSIFException {
  -           // spawn a new thread to process the request  
  -           final WSIFOperation_Java copiedOp = this.copy();
  -           Thread t = new Thread() {
  -              public void run() {
  -                 copiedOp.processAsyncRequest( input, handler );
  -               }
  -        };
  -           t.setName( "WSIFOperation_Java async request processor" );
  -           t.start();
  -           return null; // ???ant??? need a correlation ID?
  -        }
  -    
  -        private void processAsyncRequest(WSIFMessage inMsg, WSIFResponseHandler 
handler) {
  -           WSIFMessage outMsg = createOutputMessage();
  -           WSIFMessage faultMsg = createFaultMessage();
  -           try {
  -              executeRequestResponseOperation( inMsg, outMsg, faultMsg );
  -           } catch (Exception ex) {
  -              //???ant???what to do with this?
  -           }    
  -           handler.executeAsyncResponse(outMsg, faultMsg);
  -        }
  -    
  -        public boolean isAsyncSupported() {
  -           return true;
  -        }
  -    
  -    */
   
       public boolean executeRequestResponseOperation(
           WSIFMessage input,
  
  
  


Reply via email to