whitlock 2002/07/04 02:25:03 Modified: java/src/org/apache/wsif/providers/java WSIFPort_Java.java WSIFOperation_Java.java java/src/org/apache/wsif/logging Tr.java Log: Improve trace and performance Revision Changes Path 1.4 +66 -11 xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java Index: WSIFPort_Java.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- WSIFPort_Java.java 19 Jun 2002 15:33:40 -0000 1.3 +++ WSIFPort_Java.java 4 Jul 2002 09:25:03 -0000 1.4 @@ -61,11 +61,13 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Vector; import javax.wsdl.BindingOperation; import javax.wsdl.Definition; import javax.wsdl.Port; import javax.wsdl.extensions.ExtensibilityElement; +import javax.xml.namespace.QName; import org.apache.wsif.WSIFException; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; @@ -73,6 +75,8 @@ import org.apache.wsif.logging.Tr; import org.apache.wsif.providers.WSIFDynamicTypeMap; import org.apache.wsif.wsdl.extensions.java.JavaAddress; +import org.apache.wsif.wsdl.extensions.format.TypeMap; +import org.apache.wsif.wsdl.extensions.format.TypeMapping; /** * Java WSIF Port. @@ -86,13 +90,16 @@ private javax.wsdl.Definition fieldDefinition = null; private javax.wsdl.Port fieldPortModel = null; private java.lang.Object fieldObjectReference = null; // 'physical connection' + private Map fieldTypeMaps = new HashMap(); protected Map operationInstances = new HashMap(); - public WSIFPort_Java(Definition def, Port port, WSIFDynamicTypeMap typeMap) { + public WSIFPort_Java(Definition def, Port port, WSIFDynamicTypeMap typeMap) + throws WSIFException { Tr.entry(this, def, port, typeMap); fieldDefinition = def; fieldPortModel = port; + buildTypeMap(); if (Tr.ON) Tr.exit(deep()); } @@ -134,32 +141,34 @@ return wo; } - public WSIFOperation_Java getDynamicWSIFOperation( + protected WSIFOperation_Java getDynamicWSIFOperation( String name, String inputName, String outputName) throws WSIFException { Tr.entry(this, name, inputName, outputName); - WSIFOperation_Java tempOp = + WSIFOperation_Java operation = (WSIFOperation_Java) operationInstances.get( getKey(name, inputName, outputName)); - WSIFOperation_Java operation = null; - if (tempOp != null) { - operation = tempOp.copy(); - } - if (operation == null) { BindingOperation bindingOperationModel = - fieldPortModel.getBinding().getBindingOperation(name, inputName, outputName); + fieldPortModel.getBinding().getBindingOperation( + name, + inputName, + outputName); if (bindingOperationModel != null) { - operation = new WSIFOperation_Java(fieldPortModel, bindingOperationModel, this); + operation = + new WSIFOperation_Java( + fieldPortModel, + bindingOperationModel, + this, + fieldTypeMaps); setDynamicWSIFOperation(name, inputName, outputName, operation); } } - Tr.exit(operation); return operation; } @@ -187,6 +196,7 @@ Thread.currentThread().getContextClassLoader()) .newInstance(); } catch (Exception ex) { + Tr.exception(ex); throw new WSIFException( "Could not create object of class '" + address.getClassName() + "'", ex); @@ -228,6 +238,51 @@ public void setPortModel(Port value) { Tr.entry(this, value); fieldPortModel = value; + Tr.exit(); + } + + private void buildTypeMap() throws WSIFException { + Tr.entry(this); + TypeMapping typeMapping = null; + + // Get the TypeMappings from the binding + Iterator bindingIterator = + this.fieldPortModel.getBinding().getExtensibilityElements().iterator(); + while (bindingIterator.hasNext()) { + try { + typeMapping = (TypeMapping) bindingIterator.next(); + if (typeMapping.getEncoding().equals("Java")) + break; + } catch (ClassCastException exn) { + Tr.exception(exn); + } + } + + if (typeMapping == null) { + throw new WSIFException("Definition does not contain TypeMapping"); + } + + // Build the hashmap + bindingIterator = typeMapping.getMaps().iterator(); + while (bindingIterator.hasNext()) { + TypeMap typeMap = (TypeMap) bindingIterator.next(); + /////////////////////////////////// + QName typeName = typeMap.getTypeName(); + String type = typeMap.getFormatType(); + if (typeName != null && type != null) { + if (fieldTypeMaps.containsKey(typeName)) { + Vector v = new Vector(); + v.addElement(fieldTypeMaps.get(typeName)); + v.addElement(type); + this.fieldTypeMaps.put(typeName, v); + + } else { + this.fieldTypeMaps.put(typeName, type); + } + } else { + throw new WSIFException("Error in binding TypeMap. Key or Value is null"); + } + } Tr.exit(); } 1.8 +221 -192 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WSIFOperation_Java.java 1 Jul 2002 12:31:36 -0000 1.7 +++ WSIFOperation_Java.java 4 Jul 2002 09:25:03 -0000 1.8 @@ -88,8 +88,6 @@ import org.apache.wsif.base.WSIFServiceImpl; import org.apache.wsif.logging.MessageLogger; import org.apache.wsif.logging.Tr; -import org.apache.wsif.wsdl.extensions.format.TypeMap; -import org.apache.wsif.wsdl.extensions.format.TypeMapping; import org.apache.wsif.wsdl.extensions.java.JavaOperation; /** @@ -106,21 +104,16 @@ protected WSIFPort_Java fieldPort; protected javax.wsdl.BindingOperation fieldBindingOperationModel; protected JavaOperation fieldJavaOperationModel; - protected Method fieldMethod = null; - protected Method[] fieldAllMethods = null; - protected Constructor fieldConstructor = null; - protected String[] fieldInParameterNames = null; - protected Map fieldFaultMessageInfos = null; - // key: class name, value: FaultMessageInfo instance + protected String[] fieldInParameterNames = null; protected String[] fieldOutParameterNames = null; - + protected Map fieldFaultMessageInfos = null; + protected Method[] fieldMethods = null; + protected Constructor[] fieldConstructors = null; protected String fieldOutputMessageName = null; - protected String fieldInputMessageName = null; protected boolean fieldIsStatic = false; protected boolean fieldIsConstructor = false; - protected boolean fieldTypeMapBuilt = false; - protected Map fieldTypeMaps = new HashMap(); + protected Map fieldTypeMaps = null; private class FaultMessageInfo { String fieldMessageName; @@ -138,20 +131,23 @@ public WSIFOperation_Java( javax.wsdl.Port portModel, BindingOperation bindingOperationModel, - WSIFPort_Java port) + WSIFPort_Java port, + Map typeMaps) throws WSIFException { - Tr.entry(this, portModel, bindingOperationModel, port); + Tr.entry(this, portModel, bindingOperationModel, port, typeMaps); fieldPortModel = portModel; fieldBindingOperationModel = bindingOperationModel; fieldPort = port; - fieldAllMethods = fieldPort.getObjectReference().getClass().getMethods(); + fieldTypeMaps = typeMaps; + Method[] allMethods = fieldPort.getObjectReference().getClass().getMethods(); try { fieldJavaOperationModel = (JavaOperation) fieldBindingOperationModel.getExtensibilityElements().get(0); } catch (Exception e) { + Tr.exception(e); throw new WSIFException( "Unable to resolve Java binding for operation '" + bindingOperationModel.getName() @@ -170,10 +166,61 @@ } } + fieldConstructors = getConstructors(); + fieldMethods = getMethods(allMethods); + if (Tr.ON) Tr.exit(deep()); } + private WSIFOperation_Java( + Port p, + WSIFPort_Java pj, + BindingOperation bo, + JavaOperation jo, + String[] inPNames, + String[] outPNames, + Map faultMsgInfos, + Method[] m, + Constructor[] c, + String outMName, + boolean isSttc, + boolean isCnstr, + Map tMap) { + Tr.entry( + this, + p, + pj, + bo, + jo, + inPNames, + outPNames, + faultMsgInfos, + m, + c, + outMName, + new Boolean(isSttc), + new Boolean(isCnstr), + tMap); + + fieldPortModel = p; + fieldPort = pj; + fieldBindingOperationModel = bo; + fieldJavaOperationModel = jo; + fieldInParameterNames = inPNames; + fieldOutParameterNames = outPNames; + fieldFaultMessageInfos = faultMsgInfos; + fieldMethods = m; + fieldConstructors = c; + fieldOutputMessageName = outMName; + fieldIsStatic = isSttc; + fieldIsConstructor = isCnstr; + fieldTypeMaps = tMap; + + if (Tr.ON) + Tr.exit(deep()); + } + /** * Create a new copy of this object. This is not a clone, since * it does not copy the referenced objects as well. @@ -181,12 +228,27 @@ public WSIFOperation_Java copy() throws WSIFException { Tr.entry(this); WSIFOperation_Java woj = - new WSIFOperation_Java(fieldPortModel, fieldBindingOperationModel, fieldPort); + new WSIFOperation_Java( + fieldPortModel, + fieldPort, + fieldBindingOperationModel, + fieldJavaOperationModel, + fieldInParameterNames, + fieldOutParameterNames, + fieldFaultMessageInfos, + fieldMethods, + fieldConstructors, + fieldOutputMessageName, + fieldIsStatic, + fieldIsConstructor, + fieldTypeMaps); Tr.exit(woj); return woj; } protected static Class getClassForName(String classname) throws WSIFException { + Tr.entry(null,classname); + Class cls = null; if (classname == null) { @@ -222,68 +284,70 @@ Class.forName(classname, true, Thread.currentThread().getContextClassLoader()); } } catch (ClassNotFoundException ex) { + Tr.exception(ex); throw new WSIFException("Could not instantiate class '" + classname + "'", ex); } - + Tr.exit(cls); return cls; } protected Constructor[] getConstructors() throws WSIFException { + Tr.entry(this); Constructor[] candidates; - if (fieldConstructor == null) { - // Get the possible constructors with the argument classes we've found. - Constructor[] constructors = - fieldPort.getObjectReference().getClass().getConstructors(); - Object[] args = getMethodArgumentClasses(); - Vector possibles = new Vector(); - for (int i = 0; i < constructors.length; i++) { - Class[] params = constructors[i].getParameterTypes(); - if (params.length != args.length) - continue; - - boolean match = true; - for (int j = 0; j < params.length; j++) { - Object obj = args[j]; - if (obj instanceof Vector) { - Vector vec = (Vector) obj; - boolean found = false; - for (int p = 0; p < vec.size(); p++) { - Class cl = (Class) vec.get(p); - if (cl.getName().equals(params[j].getName())) { - found = true; - break; - } - } - if (!found) { - match = false; - break; - } - } else { - if (!((Class) obj).getName().equals(params[j].getName())) { - match = false; + // Get the possible constructors with the argument classes we've found. + Constructor[] constructors = + fieldPort.getObjectReference().getClass().getConstructors(); + Object[] args = getMethodArgumentClasses(); + Vector possibles = new Vector(); + for (int i = 0; i < constructors.length; i++) { + Class[] params = constructors[i].getParameterTypes(); + if (params.length != args.length) + continue; + + boolean match = true; + for (int j = 0; j < params.length; j++) { + Object obj = args[j]; + if (obj instanceof Vector) { + Vector vec = (Vector) obj; + boolean found = false; + for (int p = 0; p < vec.size(); p++) { + Class cl = (Class) vec.get(p); + if (cl.getName().equals(params[j].getName())) { + found = true; break; } } - } - if (match) { - possibles.addElement(constructors[i]); + if (!found) { + match = false; + break; + } + } else { + if (!((Class) obj).getName().equals(params[j].getName())) { + match = false; + break; + } } } - candidates = new Constructor[possibles.size()]; - for (int k = 0; k < candidates.length; k++) { - candidates[k] = (Constructor) possibles.get(k); + if (match) { + possibles.addElement(constructors[i]); } - return candidates; } - return new Constructor[0]; + candidates = new Constructor[possibles.size()]; + for (int k = 0; k < candidates.length; k++) { + candidates[k] = (Constructor) possibles.get(k); + } + Tr.exit(candidates); + return candidates; } protected Map getFaultMessageInfos() throws WSIFException { + Tr.entry(this); // Get the current operation Operation operation = null; try { operation = getOperation(); } catch (Exception e) { + Tr.exception(e); throw new WSIFException("Failed to get Operation", e); } @@ -294,7 +358,6 @@ BindingFault bindingFaultModel = null; Map bindingFaultModels = fieldBindingOperationModel.getBindingFaults(); List parts = null; - TypeMap typeMap = null; Iterator modelsIterator = bindingFaultModels.values().iterator(); while (modelsIterator.hasNext()) { @@ -332,21 +395,12 @@ } } } - + Tr.exit(fieldFaultMessageInfos); return fieldFaultMessageInfos; } - protected String getInputMessageName() throws WSIFException { - if (fieldInputMessageName == null) { - BindingInput bindingInputModel = fieldBindingOperationModel.getBindingInput(); - if (bindingInputModel != null) { - fieldInputMessageName = bindingInputModel.getName(); - } - } - return fieldInputMessageName; - } - - protected Method[] getMethods() throws WSIFException { + protected Method[] getMethods(Method[] allMethods) throws WSIFException { + Tr.entry(this,allMethods); Method[] candidates; try { if (!fieldIsConstructor) { @@ -354,15 +408,15 @@ Object[] args = getMethodArgumentClasses(); Object retClass = getMethodReturnClass(); Vector possibles = new Vector(); - for (int i = 0; i < fieldAllMethods.length; i++) { - if (!fieldAllMethods[i] + for (int i = 0; i < allMethods.length; i++) { + if (!allMethods[i] .getName() .equals(fieldJavaOperationModel.getMethodName())) continue; - Class[] params = fieldAllMethods[i].getParameterTypes(); + Class[] params = allMethods[i].getParameterTypes(); if (params.length != args.length) continue; - Class retType = fieldAllMethods[i].getReturnType(); + Class retType = allMethods[i].getReturnType(); if (retClass != null && retClass instanceof Vector) { Vector vec = (Vector) retClass; boolean found = false; @@ -407,19 +461,24 @@ } } if (match) { - possibles.addElement(fieldAllMethods[i]); + possibles.addElement(allMethods[i]); } } candidates = new Method[possibles.size()]; for (int k = 0; k < candidates.length; k++) { candidates[k] = (Method) possibles.get(k); } + Tr.exit(candidates); return candidates; } - return new Method[0]; + Method[] m = new Method[0]; + Tr.exit(m); + return m; } catch (WSIFException ex) { + Tr.exception(ex); throw ex; } catch (Exception ex) { + Tr.exception(ex); throw new WSIFException( "Error while resolving meta information of method " + fieldJavaOperationModel.getMethodName() @@ -428,64 +487,17 @@ } } - private void buildTypeMap() throws WSIFException { - // Only build once! - if (fieldTypeMapBuilt) - return; - - TypeMapping typeMapping = null; - - // Get the TypeMappings from the binding - Iterator bindingIterator = - this.fieldPortModel.getBinding().getExtensibilityElements().iterator(); - while (bindingIterator.hasNext()) { - try { - typeMapping = (TypeMapping) bindingIterator.next(); - if (typeMapping.getEncoding().equals("Java")) - break; - } catch (ClassCastException exn) { - } - } - - if (typeMapping == null) { - throw new WSIFException("Definition does not contain TypeMapping"); - } - - // Build the hashmap - bindingIterator = typeMapping.getMaps().iterator(); - while (bindingIterator.hasNext()) { - TypeMap typeMap = (TypeMap) bindingIterator.next(); - /////////////////////////////////// - QName typeName = typeMap.getTypeName(); - String type = typeMap.getFormatType(); - if (typeName != null && type != null) { - if (fieldTypeMaps.containsKey(typeName)) { - Vector v = new Vector(); - v.addElement(fieldTypeMaps.get(typeName)); - v.addElement(type); - this.fieldTypeMaps.put(typeName, v); - - } else { - this.fieldTypeMaps.put(typeName, type); - } - } else { - throw new WSIFException("Error in binding TypeMap. Key or Value is null"); - } - } - fieldTypeMapBuilt = true; - } - private Operation getOperation() throws Exception { + Tr.entry(this); Operation operation = null; - buildTypeMap(); - // <input> and <output> tags in binding operations are not mandatory // so deal with null BindingInputs or BindingOutputs String inputName = null; try { inputName = this.fieldBindingOperationModel.getBindingInput().getName(); } catch (NullPointerException e) { + Tr.exception(e); inputName = null; } @@ -493,22 +505,23 @@ try { outputName = this.fieldBindingOperationModel.getBindingOutput().getName(); } catch (NullPointerException e) { + Tr.exception(e); outputName = null; } // Build the parts list + //this.fieldBindingOperationModel.getBindingInput().getName(), operation = - this - .fieldPortModel - .getBinding() - .getPortType() - .getOperation(this.fieldBindingOperationModel.getName(), - //this.fieldBindingOperationModel.getBindingInput().getName(), - inputName, outputName); + this.fieldPortModel.getBinding().getPortType().getOperation( + this.fieldBindingOperationModel.getName(), + inputName, + outputName); + Tr.exit(operation); return operation; } protected Object getMethodReturnClass() throws WSIFException { + Tr.entry(this); Object methodReturnClass = null; try { String returnPartString = fieldJavaOperationModel.getReturnPart(); @@ -543,17 +556,19 @@ } // returnPart attribute was not present so return methodReturnClass as default null } catch (Exception ex) { + Tr.exception(ex); throw new WSIFException( "Error while determining return class of method " + fieldJavaOperationModel.getMethodName() + " : The meta information is not consistent.", ex); } - + Tr.exit(methodReturnClass); return methodReturnClass; } protected Object[] getMethodArgumentClasses() throws WSIFException { + Tr.entry(this); Object[] methodArgClasses = null; try { @@ -684,15 +699,15 @@ } else { fieldOutParameterNames = new String[0]; } - } catch (Exception ex) { + Tr.exception(ex); throw new WSIFException( "Error while determining signature of method " + fieldJavaOperationModel.getMethodName() + " : The meta information is not consistent.", ex); } - + Tr.exit(methodArgClasses); return methodArgClasses; } @@ -700,6 +715,7 @@ // If they are compatible, the object array is populated // otherwise returns null protected Object[] getCompatibleArguments(Class[] parmTypes, Object[] args) { + Tr.entry(this,parmTypes,args); // Go through each argument checking it's compatability with the method arg // creating a compatible set along the way. // In essence this just converts from String to Character when necessary @@ -727,15 +743,20 @@ } } + Tr.exit(compatibleArgs); return compatibleArgs; } protected Object getCompatibleReturn(Method method, Object returnObj) { + Tr.entry(this,method,returnObj); + Object o = null; if (method.getReturnType().equals(java.lang.Character.class)) { - return getCompatibleObject(java.lang.String.class, returnObj); + o = getCompatibleObject(java.lang.String.class, returnObj); } else { - return returnObj; + o = returnObj; } + Tr.exit(o); + return o; } // Usually cls1.isAssignableFrom(cls2) returning false means you can't cast @@ -748,22 +769,26 @@ // Note: if you are adding other cases ensure you add both directions since the // this conversion may be needed on method args AND returns protected Object getCompatibleObject(Class cls, Object obj) { + Tr.entry(this,cls,obj); // String -> Character if (cls.equals(java.lang.Character.class) && obj.getClass().equals(java.lang.String.class)) { Character charArg = stringToCharacter((String) obj); if (charArg == null) { // Can't convert this string to character so return null + Tr.exit(null); return null; } + Tr.exit(charArg); return charArg; } if (cls.equals(java.lang.String.class) && obj.getClass().equals(java.lang.Character.class)) { + Tr.exit(obj.toString()); return (obj.toString()); } - + Tr.exit(obj); return obj; } @@ -774,6 +799,7 @@ } protected String getOutputMessageName() throws WSIFException { + Tr.entry(this); if (fieldOutputMessageName == null) { BindingOutput bindingOutputModel = fieldBindingOperationModel.getBindingOutput(); @@ -781,6 +807,7 @@ fieldOutputMessageName = bindingOutputModel.getName(); } } + Tr.exit(fieldOutputMessageName); return fieldOutputMessageName; } @@ -847,23 +874,20 @@ boolean operationSucceeded = true; boolean foundInputParameter = false; boolean usedOutputParam = false; + Method chosenMethod = null; try { Object result = null; - Method[] methods = null; - Constructor[] constructors = null; // Need to get the stuff here because this also initializes fieldInParameterNames if (fieldIsConstructor) { - constructors = getConstructors(); - if (constructors.length <= 0) - throw new WSIFException("No constructor found that match the parts specified"); - } else { - methods = getMethods(); - if (methods.length <= 0) + if (fieldConstructors.length <= 0) throw new WSIFException( - "No method named '" - + fieldJavaOperationModel.getMethodName() - + "' found that match the parts specified"); + "No constructor found that match the parts specified"); + } else { + if (fieldMethods.length <= 0) + throw new WSIFException("No method named '" + + fieldJavaOperationModel.getMethodName() + + "' found that match the parts specified"); } Object[] arguments = null; @@ -876,6 +900,7 @@ arguments[i] = part; foundInputParameter = true; } catch (WSIFException e) { + Tr.exception(e); if (fieldOutParameterNames.length > 0) { String outParameterName = null; for (int j = 0; j < fieldOutParameterNames.length; j++) { @@ -885,7 +910,7 @@ && (outParameterName .equals(fieldInParameterNames[i]))) { arguments[i] = - (methods[0].getParameterTypes()[i]) + (fieldMethods[0].getParameterTypes()[i]) .newInstance(); foundInputParameter = true; usedOutputParam = true; @@ -902,21 +927,22 @@ 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; // Parts are compatible so invoke the ctor with the compatible set - result = constructors[a].newInstance(compatibleArguments); + result = fieldConstructors[a].newInstance(compatibleArguments); fieldPort.setObjectReference(result); invokedOK = true; break; } catch (IllegalArgumentException ia) { - // Ingore and try next constructor + Tr.exception(ia); + // Ignore and try next constructor } } if (!invokedOK) @@ -924,7 +950,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; i++) { String outParameterName = null; @@ -932,7 +958,7 @@ outParameterName = fieldOutParameterNames[j]; if ((outParameterName != null) && (outParameterName.equals(fieldInParameterNames[i]))) { - arguments[i] = (methods[a].getParameterTypes()[i]).newInstance(); + arguments[i] = (fieldMethods[a].getParameterTypes()[i]).newInstance(); } } } @@ -940,24 +966,25 @@ 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; // Parts are compatible so invoke the method with the compatible set - result = methods[a].invoke(null, compatibleArguments); - fieldMethod = methods[a]; + result = fieldMethods[a].invoke(null, compatibleArguments); + chosenMethod = fieldMethods[a]; invokedOK = true; break; } catch (IllegalArgumentException ia) { - // Ingore and try next method + Tr.exception(ia); + // Ignore and try next method } } if (!invokedOK) 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++) { if (usedOutputParam) { for (int i = 0; i < fieldInParameterNames.length; i++) { String outParameterName = null; @@ -965,7 +992,7 @@ outParameterName = fieldOutParameterNames[j]; if ((outParameterName != null) && (outParameterName.equals(fieldInParameterNames[i]))) { - arguments[i] = (methods[a].getParameterTypes()[i]).newInstance(); + arguments[i] = (fieldMethods[a].getParameterTypes()[i]).newInstance(); } } } @@ -973,17 +1000,18 @@ 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; // Parts are compatible so invoke the method with the compatible set - result = methods[a].invoke(fieldPort.getObjectReference(), compatibleArguments); - fieldMethod = methods[a]; + result = fieldMethods[a].invoke(fieldPort.getObjectReference(), compatibleArguments); + chosenMethod = fieldMethods[a]; invokedOK = true; break; } catch (IllegalArgumentException ia) { - // Ingore and try next method + Tr.exception(ia); + // Ignore and try next method } } if (!invokedOK) @@ -998,7 +1026,7 @@ if (outParameterName != null) { output.setObjectPart( outParameterName, - getCompatibleReturn(fieldMethod, result)); + getCompatibleReturn(chosenMethod, result)); // Should we use the class of the method signature instead here ? } @@ -1014,6 +1042,7 @@ } } } catch (WSIFException e) { + Tr.exception(e); //ignore } } @@ -1022,6 +1051,7 @@ } } } catch (InvocationTargetException ex) { + Tr.exception(ex); Throwable invocationFault = ex.getTargetException(); String className = invocationFault.getClass().getName(); Map faultMessageInfos = getFaultMessageInfos(); @@ -1057,6 +1087,7 @@ operationSucceeded = false; } } catch (Exception exc) { // Nothing to do - just try the next one... + Tr.exception(exc); } } if (!found) { @@ -1064,6 +1095,7 @@ } } } catch (Exception ex) { + Tr.exception(ex); // Log message MessageLogger messageLog = MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages"); @@ -1090,20 +1122,15 @@ boolean foundInputParameter = false; try { Object result = null; - Method[] methods = null; - Constructor[] constructors = null; // Need to get the stuff here because this also initializes fieldInParameterNames if (fieldIsConstructor) { - constructors = getConstructors(); - if (constructors.length <= 0) + if (fieldConstructors.length <= 0) throw new WSIFException("No constructors found that match the parts specified"); } else { - methods = getMethods(); - if (methods.length <= 0) - throw new WSIFException( - "No methods named '" - + fieldJavaOperationModel.getMethodName() - + "' found that match the parts specified"); + if (fieldMethods.length <= 0) + throw new WSIFException("No methods named '" + + fieldJavaOperationModel.getMethodName() + + "' found that match the parts specified"); } Object[] arguments = null; @@ -1116,6 +1143,7 @@ arguments[i] = part; foundInputParameter = true; } catch (WSIFException e) { + Tr.exception(e); } if (!foundInputParameter) { @@ -1128,20 +1156,21 @@ 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; // Parts are compatible so invoke the ctor with the compatible set - result = constructors[a].newInstance(compatibleArguments); + result = fieldConstructors[a].newInstance(compatibleArguments); fieldPort.setObjectReference(result); invokedOK = true; break; } catch (IllegalArgumentException ia) { + Tr.exception(ia); // Ignore and try next constructor } } @@ -1149,20 +1178,20 @@ 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; // Parts are compatible so invoke the method with the compatible set - result = methods[a].invoke(null, compatibleArguments); - fieldMethod = methods[a]; + result = fieldMethods[a].invoke(null, compatibleArguments); invokedOK = true; break; } catch (IllegalArgumentException ia) { + Tr.exception(ia); // Ignore and try next method } } @@ -1170,20 +1199,20 @@ 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; // Parts are compatible so invoke the method with the compatible set - result = methods[a].invoke(fieldPort.getObjectReference(), compatibleArguments); - fieldMethod = methods[a]; + result = fieldMethods[a].invoke(fieldPort.getObjectReference(), compatibleArguments); invokedOK = true; break; } catch (IllegalArgumentException ia) { + Tr.exception(ia); // Ignore and try next method } } @@ -1193,6 +1222,7 @@ } } } catch (InvocationTargetException ex) { + Tr.exception(ex); // Log message MessageLogger messageLog = MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages"); @@ -1210,6 +1240,7 @@ + "' failed.", ex); } catch (Exception ex) { + Tr.exception(ex); // Log message MessageLogger messageLog = MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages"); @@ -1284,10 +1315,7 @@ buff += "portModel:" + Tr.brief(fieldPortModel); buff += " wsifPort_Java:" + fieldPort; buff += " bindingOperationModel:" + Tr.brief(fieldBindingOperationModel); - buff += " JavaOperation:" + fieldJavaOperationModel; - buff += " method:" + fieldMethod; - buff += " constructor:" + fieldConstructor; buff += Tr.brief("inParameterNames", fieldInParameterNames); buff += Tr.brief("outParameterNames", fieldOutParameterNames); @@ -1309,11 +1337,12 @@ } } + buff += Tr.brief("methods", fieldMethods); + buff += Tr.brief("constructors", fieldConstructors); + buff += " outputMessageName:" + fieldOutputMessageName; - buff += " inputMessageName:" + fieldInputMessageName; buff += " isStatic:" + fieldIsStatic; buff += " isConstructor:" + fieldIsConstructor; - buff += " typeMapBuilt:" + fieldTypeMapBuilt; if (fieldTypeMaps == null) { buff += " faultTypeMaps:null"; 1.4 +90 -0 xml-axis-wsif/java/src/org/apache/wsif/logging/Tr.java Index: Tr.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/logging/Tr.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Tr.java 27 Jun 2002 10:44:49 -0000 1.3 +++ Tr.java 4 Jul 2002 09:25:03 -0000 1.4 @@ -260,6 +260,96 @@ } } + public static void entry( + Object that, + Object p1, + Object p2, + Object p3, + Object p4, + Object p5, + Object p6, + Object p7, + Object p8, + Object p9, + Object p10, + Object p11, + Object p12, + Object p13, + Object p14) { + try { + if (!ON) + return; + String hc = "static"; + if (that != null) + hc = Integer.toHexString(that.hashCode()); + Object[] parms = + new Object[] { + hc, + p1, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14 }; + checkWsdl(parms); + TraceLogger.getGeneralTraceLogger().entry(parms); + } catch (Exception e) { + exceptionInTrace(e); + } + } + + public static void entry( + Object that, + Object p1, + Object p2, + Object p3, + Object p4, + Object p5, + Object p6, + Object p7, + Object p8, + Object p9, + Object p10, + Object p11, + Object p12, + Object p13) { + try { + if (!ON) + return; + String hc = "static"; + if (that != null) + hc = Integer.toHexString(that.hashCode()); + Object[] parms = + new Object[] { + hc, + p1, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13 }; + checkWsdl(parms); + TraceLogger.getGeneralTraceLogger().entry(parms); + } catch (Exception e) { + exceptionInTrace(e); + } + } + public static void entryExpandWsdl(Object that, Object[] parms) { try { if (!ON)