whitlock    2003/03/18 05:52:14

  Modified:    java/test/mime MimeTest.java MimeImpl.java
               java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFOperation_ApacheAxis.java
               java/src/org/apache/wsif WSIFAttachmentPart.java
               java/src/org/apache/wsif/providers/java
                        WSIFOperation_Java.java
  Log:
  16993: rework unreferenced attachments
  
  Revision  Changes    Path
  1.22      +6 -2      xml-axis-wsif/java/test/mime/MimeTest.java
  
  Index: MimeTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/mime/MimeTest.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- MimeTest.java     17 Mar 2003 16:02:31 -0000      1.21
  +++ MimeTest.java     18 Mar 2003 13:52:14 -0000      1.22
  @@ -995,9 +995,11 @@
           WSIFMessage in = op.createInputMessage();
           WSIFMessage out = op.createOutputMessage();
           WSIFMessage fault = op.createFaultMessage();
  -        in.setObjectPart(
  +        WSIFMessage context = op.getContext();
  +        context.setObjectPart(
               WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME,
               apList);
  +        op.setContext(context);
   
           boolean success = op.executeRequestResponseOperation(in, out, fault);
           assertTrue(success);
  @@ -1035,9 +1037,11 @@
           WSIFMessage in = op.createInputMessage();
           WSIFMessage out = op.createOutputMessage();
           WSIFMessage fault = op.createFaultMessage();
  -        in.setObjectPart(
  +        WSIFMessage context = op.getContext();
  +        context.setObjectPart(
               WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME,
               apList);
  +        op.setContext(context);
   
           boolean success = op.executeRequestResponseOperation(in, out, fault);
           assertTrue(success);
  
  
  
  1.15      +43 -34    xml-axis-wsif/java/test/mime/MimeImpl.java
  
  Index: MimeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/mime/MimeImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MimeImpl.java     14 Mar 2003 16:22:17 -0000      1.14
  +++ MimeImpl.java     18 Mar 2003 13:52:14 -0000      1.15
  @@ -63,12 +63,14 @@
   import java.lang.reflect.Method;
   import java.util.Iterator;
   import java.util.List;
  -import java.util.Map;
   
   import javax.activation.DataHandler;
   import javax.activation.FileDataSource;
   
   import org.apache.wsif.WSIFAttachmentPart;
  +import org.apache.wsif.WSIFConstants;
  +import org.apache.wsif.WSIFMessage;
  +import org.apache.wsif.providers.java.WSIFOperation_Java;
   
   /**
    * Mime service used by MimeTest 
  @@ -249,51 +251,58 @@
       }
       
       public String unref() {
  -        String s = new String();
  +        String errText = null;
  +        List l = null;
           try {
  -             Class c = Class.forName("mime.MimeImplAxisHelper");
  -             Method m = c.getMethod("getUnreferencedAttachments",null);
  -            Object o = m.invoke(null,null);
  -            List ua = (List)o;
  -            s = unref(ua);
  +            WSIFMessage context = WSIFOperation_Java.getMessageContext();
  +            l =
  +                (List) context.getObjectPart(
  +                    WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME);
           } catch (Exception e) {
  -            System.err.println("MimeImpl.unref==>" + e);
  -            e.printStackTrace();
  +            errText += e.toString() + "\n";
           }
   
  -        return s;
  -    }
  -    
  -    public String unref(List l) {
  -        if (l == null || l.isEmpty())
  -            return null;
  +        if (l == null) {
  +            try {
  +                Class c = Class.forName("mime.MimeImplAxisHelper");
  +                Method m = c.getMethod("getUnreferencedAttachments", null);
  +                Object o = m.invoke(null, null);
  +                l = (List) o;
  +            } catch (Exception e) {
  +                errText += e.toString() + "\n";
  +            }
  +        }
   
           String s = new String();
  -        Iterator it = l.iterator();
  -        while (it.hasNext()) {
  -            Object next = it.next();
  -            if (next instanceof WSIFAttachmentPart) {
  -
  -                WSIFAttachmentPart wap = (WSIFAttachmentPart) next;
  -                Iterator itProp = wap.getPropertyIterator();
  -                while (itProp.hasNext()) {
  -
  -                    String prop = (String) itProp.next();
  -                    if ("Content-Location".equals(prop)
  -                        || !prop.startsWith("Content-")) {
  -                        s = s + prop
  -                              + "="
  -                              + wap.getProperty(prop)
  -                              + ":";
  +        try {
  +            Iterator it = l.iterator();
  +            while (it.hasNext()) {
  +                Object next = it.next();
  +                if (next instanceof WSIFAttachmentPart) {
  +
  +                    WSIFAttachmentPart wap = (WSIFAttachmentPart) next;
  +                    Iterator itProp = wap.getPropertyIterator();
  +                    while (itProp.hasNext()) {
  +
  +                        String prop = (String) itProp.next();
  +                        if ("Content-Location".equals(prop)
  +                            || !prop.startsWith("Content-")) {
  +                            s = s + prop + "=" + wap.getProperty(prop) + ":";
  +                        }
                       }
  +                    DataHandler dh = wap.getDataHandler();
  +                    s = s + dataHandlerToString(dh) + ":";
                   }
  -                DataHandler dh = wap.getDataHandler();
  -                s = s + dataHandlerToString(dh) + ":";
               }
  +        } catch (Exception e) {
  +            errText += e.toString();
  +            System.err.println("MimeImpl.unref==>" + errText);
  +            e.printStackTrace();
  +            return errText;
           }
           return s;
       }
  -
  +    
       /* ******************* ERRORS *********************** */
       
       public String badNoPart(DataHandler dh) {
  
  
  
  1.79      +45 -34    
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
  
  Index: WSIFOperation_ApacheAxis.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- WSIFOperation_ApacheAxis.java     14 Mar 2003 16:22:17 -0000      1.78
  +++ WSIFOperation_ApacheAxis.java     18 Mar 2003 13:52:14 -0000      1.79
  @@ -1533,7 +1533,7 @@
                setCallParameterNames(call);
   
           Object[] inputValues = getInputMessageValues(inMsg, dest);
  -        addAttachments(inMsg, call, false);
  +        addUnreferencedAttachments(inMsg, call);
   
                Object response = null;
                boolean respOK = true;
  @@ -1697,7 +1697,7 @@
           setCallParameterNames(call);
   
                Object[] inputValues = getInputMessageValues(inMsg, null);
  -        addAttachments(inMsg, call, false);
  +        addUnreferencedAttachments(inMsg, call);
   
                // invoke the AXIS call
                Trc.event(this, "Invoking AXIS call", call, inputValues);
  @@ -1756,7 +1756,8 @@
   
                boolean workedOK = false;
   
  -        List attachments = addAttachments(inMsg, call, true);
  +        List attachments = addReferencedAttachments(inMsg, call);
  +        addUnreferencedAttachments(inMsg, call);
   
                Object[] inputValues = getInputMessageValues(inMsg, null);
                ArrayList soapBodies = new ArrayList();
  @@ -2207,56 +2208,66 @@
        }
   
        /**
  -      * adds all the attachments to the AXIS call
  +      * adds all the referenced attachments to the AXIS call
         * returns a List of all the AttachmentPart so that href parts
         * can be made for each attachment later if required.
         */
  -    private List addAttachments(WSIFMessage inMsg, Call call, boolean doRef)
  +    private List addReferencedAttachments(WSIFMessage inMsg, Call call)
           throws WSIFException {
  -        Trc.entry(this,inMsg,call,new Boolean(doRef));
  -        
  -        ArrayList attachments = null;
  -        if (doRef) {
  -            attachments = new ArrayList();
  -            for (int i = 0; i < inputMIMEParts.size(); i++) {
  -                Part p = (Part) inputMIMEParts.get(i);
  -                try {
  -                    String partName = p.getName();
  -                    Object value = inMsg.getObjectPart(partName);
  -                    AttachmentPart ap = MIMEHelper.getAttachementPart(value);
  -                    call.addAttachmentPart(ap);
  -                    attachments.add(ap);
  -                } catch (WSIFException e) {
  -                    throw new WSIFException(
  -                        "attachment part '"
  -                            + p.getName()
  -                            + "' not in input WSIFMessage");
  -                }
  +        Trc.entry(this, inMsg, call);
  +
  +        ArrayList attachments = new ArrayList();
  +        for (int i = 0; i < inputMIMEParts.size(); i++) {
  +            Part p = (Part) inputMIMEParts.get(i);
  +            try {
  +                String partName = p.getName();
  +                Object value = inMsg.getObjectPart(partName);
  +                AttachmentPart ap = MIMEHelper.getAttachementPart(value);
  +                call.addAttachmentPart(ap);
  +                attachments.add(ap);
  +            } catch (WSIFException e) {
  +                throw new WSIFException(
  +                    "attachment part '"
  +                        + p.getName()
  +                        + "' not in input WSIFMessage");
               }
           }
   
  +        Trc.exit(attachments);
  +        return attachments;
  +    }
  +
  +    /**
  +     * adds all the unreferenced attachments to the AXIS call
  +     */
  +    private void addUnreferencedAttachments(WSIFMessage inMsg, Call call)
  +        throws WSIFException {
  +        Trc.entry(this, inMsg, call);
  +
           if (WSIFProperties.areUnreferencedAttachmentsSupported()) {
               List l = null;
               try {
  -                l =
  -                    (List) inMsg.getObjectPart(
  -                        WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME);
  +                WSIFMessage context = getContext();
  +                if (context != null) {
  +                    l =
  +                        (List) context.getObjectPart(
  +                            WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME);
  +                }
               } catch (Exception e) {
                   Trc.ignoredException(e);
               }
  -            
  +
               if (l != null && !l.isEmpty()) {
  -             Iterator it = l.listIterator();
  -             while (it.hasNext()) {
  -                     Object next = it.next();
  +                Iterator it = l.listIterator();
  +                while (it.hasNext()) {
  +                    Object next = it.next();
                       AttachmentPart ap = MIMEHelper.getAttachementPart(next);
                       call.addAttachmentPart(ap);
  -             }
  +                }
               }
           }
   
  -        Trc.exit(attachments);
  -        return attachments;
  +        Trc.exit();
       }
   
       /**
  
  
  
  1.4       +16 -1     xml-axis-wsif/java/src/org/apache/wsif/WSIFAttachmentPart.java
  
  Index: WSIFAttachmentPart.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFAttachmentPart.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSIFAttachmentPart.java   14 Mar 2003 11:41:41 -0000      1.3
  +++ WSIFAttachmentPart.java   18 Mar 2003 13:52:14 -0000      1.4
  @@ -71,7 +71,7 @@
    * 
    * @author Mark Whitlock
    */
  -public class WSIFAttachmentPart /* implements Serializable */ {
  +public class WSIFAttachmentPart implements Cloneable /*,Serializable */ {
       private static final long serialVersionUID = 1L;
       private transient DataHandler dh;
       private Map properties;
  @@ -163,6 +163,21 @@
           Trc.exit();
       }
   
  +    public Object clone() throws CloneNotSupportedException {
  +        Trc.entry(this);
  +        DataHandler dh1 = new DataHandler(dh.getDataSource());
  +        HashMap properties1 = new HashMap(properties);
  +        WSIFAttachmentPart wap = null;
  +        try {
  +            wap = new WSIFAttachmentPart(dh1, properties1);
  +        } catch (WSIFException we) {
  +            Trc.exception(we);
  +            throw new CloneNotSupportedException(we.toString());
  +        }
  +        Trc.exit(wap);
  +        return wap;
  +    }
  +    
       //    /**
       //     * Override default deserialization
       //     */
  
  
  
  1.34      +53 -129   
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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- WSIFOperation_Java.java   14 Mar 2003 11:48:07 -0000      1.33
  +++ WSIFOperation_Java.java   18 Mar 2003 13:52:14 -0000      1.34
  @@ -118,15 +118,14 @@
       protected String[] fieldOutParameterNames = null;
       protected Map fieldFaultMessageInfos = null;
       transient protected Method[] fieldMethods = null;
  -    transient protected Method[] fieldUnrefAttMethods = null;
       transient protected Constructor[] fieldConstructors = null;
  -    transient protected Constructor[] fieldUnrefAttConstructors = null;
       protected String fieldOutputMessageName = null;
       protected boolean fieldIsStatic = false;
       protected boolean fieldIsConstructor = false;
       protected Map fieldTypeMaps = null;
       protected boolean multiOutParts = false;
       transient private Object returnClass = null;
  +    transient private static ThreadLocal context = new ThreadLocal();
   
       private class FaultMessageInfo {
           String fieldMessageName;
  @@ -173,19 +172,13 @@
           if (methodType != null) {
               if (methodType.equals("static")) {
                   fieldIsStatic = true;
  -                fieldMethods = getMethods(allMethods, false);
  -                if (WSIFProperties.areUnreferencedAttachmentsSupported())
  -                    fieldUnrefAttMethods = getMethods(allMethods, true);
  +                fieldMethods = getMethods(allMethods);
               } else if (methodType.equals("constructor")) {
                   fieldIsConstructor = true;
  -                fieldConstructors = getConstructors(false);
  -                if (WSIFProperties.areUnreferencedAttachmentsSupported())
  -                    fieldUnrefAttConstructors = getConstructors(true);
  +                fieldConstructors = getConstructors();
               } else {
                   // Assume instance method...
  -                fieldMethods = getMethods(allMethods, false);
  -                if (WSIFProperties.areUnreferencedAttachmentsSupported())
  -                    fieldUnrefAttMethods = getMethods(allMethods, true);
  +                fieldMethods = getMethods(allMethods);
               }
           }
   
  @@ -202,9 +195,7 @@
           String[] outPNames,
           Map faultMsgInfos,
           Method[] m,
  -        Method[] uam,
           Constructor[] c,
  -        Constructor[] uac,
           String outMName,
           boolean isSttc,
           boolean isCnstr,
  @@ -221,9 +212,7 @@
               outPNames,
               faultMsgInfos,
               m,
  -            uam,
               c,
  -            uac,
               outMName,
               new Boolean(isSttc),
               new Boolean(isCnstr),
  @@ -238,9 +227,7 @@
           fieldOutParameterNames = outPNames;
           fieldFaultMessageInfos = faultMsgInfos;
           fieldMethods = m;
  -        fieldUnrefAttMethods = uam;
           fieldConstructors = c;
  -        fieldUnrefAttConstructors = uac;
           fieldOutputMessageName = outMName;
           fieldIsStatic = isSttc;
           fieldIsConstructor = isCnstr;
  @@ -268,9 +255,7 @@
                   fieldOutParameterNames,
                   fieldFaultMessageInfos,
                   fieldMethods,
  -                fieldUnrefAttMethods,
                   fieldConstructors,
  -                fieldUnrefAttConstructors,
                   fieldOutputMessageName,
                   fieldIsStatic,
                   fieldIsConstructor,
  @@ -329,19 +314,13 @@
           return cls;
       }
   
  -    protected Constructor[] getConstructors(boolean lookForUnrefAtt)
  +    protected Constructor[] getConstructors()
           throws WSIFException {
  -        Trc.entry(this, lookForUnrefAtt);
  +        Trc.entry(this);
           Constructor[] candidates;
           // Get the possible constructors with the argument classes we've found.
           Constructor[] constructors = fieldPort.getServiceObjectConstructors();
           Object[] args = getMethodArgumentClasses();
  -        if (lookForUnrefAtt) {
  -            ArrayList al = new ArrayList(Arrays.asList(args));
  -            al.add(List.class);
  -            args = al.toArray();
  -        }
  -
           Vector possibles = new Vector();
           for (int i = 0; i < constructors.length; i++) {
               Class[] params = constructors[i].getParameterTypes();
  @@ -455,20 +434,14 @@
        * @param allMethods all the methods on the service's java class
        * @return the subset of allMethods that match this WSDL operation
        */
  -    protected Method[] getMethods(Method[] allMethods, boolean lookForUnrefAtt)
  +    protected Method[] getMethods(Method[] allMethods)
           throws WSIFException {
  -        Trc.entry(this, allMethods, new Boolean(lookForUnrefAtt));
  +        Trc.entry(this, allMethods);
           Method[] candidates;
           try {
               if (!fieldIsConstructor) {
                   // Get the possible methods with the argument classes we've found.
                   Object[] args = getMethodArgumentClasses();
  -                if (lookForUnrefAtt) {
  -                    ArrayList al = new ArrayList(Arrays.asList(args));
  -                    al.add(List.class);
  -                    args = al.toArray();
  -                }
  -
                   Object retClass = getMethodReturnClass();
                   Vector possibles = new Vector();
                   for (int i = 0; i < allMethods.length; i++) {
  @@ -1013,6 +986,7 @@
   
           Trc.entry(this, input, output, fault);
           close();
  +        setUpContext();
   
           boolean operationSucceeded = true;
           boolean usedOutputParam = false;
  @@ -1065,47 +1039,14 @@
                   }
               }
   
  -            Method[] methods = fieldMethods;
  -            Constructor[] constructors = fieldConstructors;
  -            if (WSIFProperties.areUnreferencedAttachmentsSupported()) {
  -                Object unrefAttPart = null;
  -                try {
  -                    unrefAttPart =
  -                        input.getObjectPart(
  -                            WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME);
  -                } catch (WSIFException we) {
  -                    Trc.ignoredException(we);
  -                }
  -
  -                if (unrefAttPart != null) {
  -                    Object[] arguments1 = null;
  -                    if (arguments == null)
  -                        arguments1 = new Object[1];
  -                    else {
  -                        arguments1 = new Object[arguments.length + 1];
  -
  -                        System.arraycopy(
  -                            arguments,
  -                            0,
  -                            arguments1,
  -                            0,
  -                            arguments.length);
  -                    }
  -                    arguments1[arguments1.length - 1] = unrefAttPart;
  -                    arguments = arguments1;
  -                    methods = fieldUnrefAttMethods;
  -                    constructors = fieldUnrefAttConstructors;
  -                }
  -            }
  -
               boolean invokedOK = false;
               if (fieldIsConstructor) {
  -                for (int a = 0; a < constructors.length; a++) {
  +                for (int a = 0; a < fieldConstructors.length; a++) {
                       try {
                           // Get a set of arguments which are compatible with the ctor
                           Object[] compatibleArguments =
                               getCompatibleArguments(
  -                                constructors[a].getParameterTypes(),
  +                                fieldConstructors[a].getParameterTypes(),
                                   arguments);
                           // If we didn't get any arguments then the parts aren't 
compatible with the ctor
                           if (compatibleArguments == null)
  @@ -1115,12 +1056,12 @@
                           Trc.event(
                               this,
                               "Invoking constructor ",
  -                            constructors[a],
  +                            fieldConstructors[a],
                               " with arguments ",
                               compatibleArguments);
   
                           result =
  -                            constructors[a].newInstance(compatibleArguments);
  +                            fieldConstructors[a].newInstance(compatibleArguments);
   
                           Trc.event(
                               this,
  @@ -1140,7 +1081,7 @@
                   // Side effect: Initialize port's object reference
               } else {
                   if (fieldIsStatic) {
  -                    for (int a = 0; a < methods.length; a++) {
  +                    for (int a = 0; a < fieldMethods.length; a++) {
                           if (usedOutputParam) {
                               for (int i = 0;
                                   i < fieldInParameterNames.length;
  @@ -1155,7 +1096,7 @@
                                           && (outParameterName
                                               .equals(fieldInParameterNames[i]))) {
                                           arguments[i] =
  -                                            (methods[a].getParameterTypes()[i])
  +                                            (fieldMethods[a].getParameterTypes()[i])
                                                   .newInstance();
                                       }
                                   }
  @@ -1165,7 +1106,7 @@
                               // Get a set of arguments which are compatible with the 
method
                               Object[] compatibleArguments =
                                   getCompatibleArguments(
  -                                    methods[a].getParameterTypes(),
  +                                    fieldMethods[a].getParameterTypes(),
                                       arguments);
                               // If we didn't get any arguments then the parts aren't 
compatible with the method
                               if (compatibleArguments == null)
  @@ -1175,19 +1116,19 @@
                               Trc.event(
                                   this,
                                   "Invoking method ",
  -                                methods[a],
  +                                fieldMethods[a],
                                   " with arguments ",
                                   compatibleArguments);
   
                               result =
  -                                methods[a].invoke(null, compatibleArguments);
  +                                fieldMethods[a].invoke(null, compatibleArguments);
   
                               Trc.event(
                                   this,
                                   "Returned from method, result is ",
                                   result);
   
  -                            chosenMethod = methods[a];
  +                            chosenMethod = fieldMethods[a];
                               invokedOK = true;
                               break;
                           } catch (IllegalArgumentException ia) {
  @@ -1201,7 +1142,7 @@
                                   + fieldJavaOperationModel.getMethodName()
                                   + "'");
                   } else {
  -                    for (int a = 0; a < methods.length; a++) {
  +                    for (int a = 0; a < fieldMethods.length; a++) {
                           if (usedOutputParam) {
                               for (int i = 0;
                                   i < fieldInParameterNames.length;
  @@ -1216,7 +1157,7 @@
                                           && (outParameterName
                                               .equals(fieldInParameterNames[i]))) {
                                           arguments[i] =
  -                                            (methods[a].getParameterTypes()[i])
  +                                            (fieldMethods[a].getParameterTypes()[i])
                                                   .newInstance();
                                       }
                                   }
  @@ -1226,7 +1167,7 @@
                               // Get a set of arguments which are compatible with the 
method
                               Object[] compatibleArguments =
                                   getCompatibleArguments(
  -                                    methods[a].getParameterTypes(),
  +                                    fieldMethods[a].getParameterTypes(),
                                       arguments);
                               // If we didn't get any arguments then the parts aren't 
compatible with the method
                               if (compatibleArguments == null)
  @@ -1239,19 +1180,19 @@
                                   "Invoking object ",
                                   objRef,
                                   " method ",
  -                                methods[a],
  +                                fieldMethods[a],
                                   " with arguments ",
                                   compatibleArguments);
   
                               result =
  -                                methods[a].invoke(objRef, compatibleArguments);
  +                                fieldMethods[a].invoke(objRef, compatibleArguments);
   
                               Trc.event(
                                   this,
                                   "Returned from method, result is ",
                                   result);
   
  -                            chosenMethod = methods[a];
  +                            chosenMethod = fieldMethods[a];
                               invokedOK = true;
                               break;
                           } catch (IllegalArgumentException ia) {
  @@ -1505,6 +1446,7 @@
   
           Trc.entry(this, input);
           close();
  +        setUpContext();
   
           try {
               Object result = null;
  @@ -1534,41 +1476,14 @@
                   }
               }
   
  -            Method[] methods = fieldMethods;
  -            Constructor[] constructors = fieldConstructors;
  -            if (WSIFProperties.areUnreferencedAttachmentsSupported()) {
  -                Object unrefAttPart = null;
  -                try {
  -                    unrefAttPart =
  -                        input.getObjectPart(
  -                            WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME);
  -                } catch (WSIFException we) {
  -                    Trc.ignoredException(we);
  -                }
  -
  -                if (unrefAttPart != null) {
  -                    Object[] arguments1 = new Object[arguments.length + 1];
  -                    System.arraycopy(
  -                        arguments,
  -                        0,
  -                        arguments1,
  -                        0,
  -                        arguments.length);
  -                    arguments1[arguments.length] = unrefAttPart;
  -                    arguments = arguments1;
  -                    methods = fieldUnrefAttMethods;
  -                    constructors = fieldUnrefAttConstructors;
  -                }
  -            }
  -
               boolean invokedOK = false;
   
               if (fieldIsConstructor) {
  -                for (int a = 0; a < constructors.length; a++) {
  +                for (int a = 0; a < fieldConstructors.length; a++) {
                       try {
                           // Get a set of arguments which are compatible with the ctor
                           Object[] compatibleArguments =
  -                            
getCompatibleArguments(constructors[a].getParameterTypes(), arguments);
  +                            
getCompatibleArguments(fieldConstructors[a].getParameterTypes(), arguments);
                           // If we didn't get any arguments then the parts aren't 
compatible with the ctor
                           if (compatibleArguments == null)
                               break;
  @@ -1577,12 +1492,12 @@
                           Trc.event(
                               this,
                               "Invoking constructor ",
  -                            constructors[a],
  +                            fieldConstructors[a],
                               " with arguments ",
                               compatibleArguments);
   
                           result =
  -                            constructors[a].newInstance(
  +                            fieldConstructors[a].newInstance(
                                   compatibleArguments);
   
                           Trc.event(
  @@ -1602,11 +1517,11 @@
                       throw new WSIFException("Failed to call constructor for object 
in Java operation");
               } else {
                   if (fieldIsStatic) {
  -                    for (int a = 0; a < methods.length; a++) {
  +                    for (int a = 0; a < fieldMethods.length; a++) {
                           try {
                               // Get a set of arguments which are compatible with the 
method
                               Object[] compatibleArguments =
  -                                
getCompatibleArguments(methods[a].getParameterTypes(), arguments);
  +                                
getCompatibleArguments(fieldMethods[a].getParameterTypes(), arguments);
                               // If we didn't get any arguments then the parts aren't 
compatible with the method
                               if (compatibleArguments == null)
                                   break;
  @@ -1615,12 +1530,12 @@
                               Trc.event(
                                   this,
                                   "Invoking method ",
  -                                methods[a],
  +                                fieldMethods[a],
                                   " with arguments ",
                                   compatibleArguments);
   
                               result =
  -                                methods[a].invoke(
  +                                fieldMethods[a].invoke(
                                       null,
                                       compatibleArguments);
   
  @@ -1640,11 +1555,11 @@
                           throw new WSIFException(
                               "Failed to invoke method '" + 
fieldJavaOperationModel.getMethodName() + "'");
                   } else {
  -                    for (int a = 0; a < methods.length; a++) {
  +                    for (int a = 0; a < fieldMethods.length; a++) {
                           try {
                               // Get a set of arguments which are compatible with the 
method
                               Object[] compatibleArguments =
  -                                
getCompatibleArguments(methods[a].getParameterTypes(), arguments);
  +                                
getCompatibleArguments(fieldMethods[a].getParameterTypes(), arguments);
                               // If we didn't get any arguments then the parts aren't 
compatible with the method
                               if (compatibleArguments == null)
                                   break;
  @@ -1656,12 +1571,12 @@
                                   "Invoking object ",
                                   objRef,
                                   " method ",
  -                                methods[a],
  +                                fieldMethods[a],
                                   " with arguments ",
                                   compatibleArguments);
   
                               result =
  -                                methods[a].invoke(
  +                                fieldMethods[a].invoke(
                                       objRef,
                                       compatibleArguments);
   
  @@ -1716,6 +1631,19 @@
   
           Trc.exit();
       }
  +    
  +    public static WSIFMessage getMessageContext() {
  +        Trc.entry(null);
  +        WSIFMessage ctxt = (WSIFMessage)context.get();
  +        Trc.exit(ctxt);
  +        return ctxt;
  +    }
  +    
  +    private void setUpContext() throws WSIFException {
  +     Trc.entry(this);
  +     context.set(getContext());
  +     Trc.exit();
  +    }
   
       public String deep() {
           String buff = "";
  @@ -1788,13 +1716,9 @@
           // Re-establish all the Method information
           Method[] allMethods = fieldPort.getServiceObjectMethods();
           if (fieldIsConstructor) {
  -             fieldConstructors = getConstructors(false);
  -            if (WSIFProperties.areUnreferencedAttachmentsSupported())
  -                fieldUnrefAttConstructors = getConstructors(true);
  +             fieldConstructors = getConstructors();
           } else {
  -            fieldMethods = getMethods(allMethods, false);
  -            if (WSIFProperties.areUnreferencedAttachmentsSupported())
  -                fieldUnrefAttMethods = getMethods(allMethods, true);
  +            fieldMethods = getMethods(allMethods);
           }
       }       
   }
  
  
  

Reply via email to