Hi, For various reasons, I have on several occasions wanted to modify the behavior of ADB. Unfortunately, in many cases the only way to do this is to change the ADB source code and recompile, because most of the relevant bits of ADB is composed of static methods that can't be overridden.
Here is a patch to convert some of the static methods to instance methods. The patch removes the static qualifier from all methods in RPCUtil. A protected RPCUtil member is added to the classes that use RPCUtil (RPCMessageReceiver and JavaTransportSender). This makes it possible to customize RPCUtil by extending those classes and setting the RPCUtil member to a subclass of RPCUtil. Because this patch removes static qualifiers from public methods, the change is neither source nor binary compatible. If this is a problem, it is possible instead to move the code to a new class (maybe named RPCInvoker?), and have RPCMessageReceiver and JavaTransportSender use that class. RPCUtil would have a static instance of new new class and forward all calls to that. If keeping compatibility is preferred, I can make a new patch that does this. Regards, Pétur Runólfsson Betware The content of this e-mail, together with any of its attachments, is for the exclusive and confidential use of the named addressee(s) and it may contain legally privileged and confidential information and/or copyrighted material. Any other distribution, use or reproduction without the sender's prior consent is unauthorized and strictly prohibited. If you have by coincidence, mistake or without specific authorization received this e-mail in error, please notify the sender by e-mail immediately, uphold strict confidentiality and neither read, copy, transfer, disseminate, disclose nor otherwise make use of its content in any way and delete the material from your computer. The content of the e-mail and its attachments is the liability of the individual sender, if it does not relate to the affairs of Betware. Betware does not assume any civil or criminal liability should the e-mail or it´s attachments be virus infected.
Index: src/org/apache/axis2/rpc/receivers/RPCUtil.java =================================================================== --- src/org/apache/axis2/rpc/receivers/RPCUtil.java (revision 785989) +++ src/org/apache/axis2/rpc/receivers/RPCUtil.java (working copy) @@ -50,15 +50,15 @@ public class RPCUtil { - private static String RETURN_WRAPPER = "return"; + private static final String RETURN_WRAPPER = "return"; - public static void processResponse(SOAPFactory fac, Object resObject, - OMElement bodyContent, - OMNamespace ns, - SOAPEnvelope envelope, - Method method, - boolean qualified, - TypeTable typeTable) { + public void processResponse(SOAPFactory fac, Object resObject, + OMElement bodyContent, + OMNamespace ns, + SOAPEnvelope envelope, + Method method, + boolean qualified, + TypeTable typeTable) { if (resObject != null) { //simple type if (resObject instanceof OMElement) { @@ -111,14 +111,14 @@ } } - public static void processObjectAsDocLitBare(SOAPFactory fac, - Object resObject, - OMElement bodyContent, - OMNamespace ns, - SOAPEnvelope envelope, - boolean qualified, - TypeTable typeTable, - String partName) { + public void processObjectAsDocLitBare(SOAPFactory fac, + Object resObject, + OMElement bodyContent, + OMNamespace ns, + SOAPEnvelope envelope, + boolean qualified, + TypeTable typeTable, + String partName) { if (resObject instanceof OMElement) { OMElement result = (OMElement) resObject; bodyContent = fac.createOMElement( @@ -146,25 +146,25 @@ } } - public static Object[] processRequest(OMElement methodElement, - Method method, ObjectSupplier objectSupplier, String[] parameterNames) + public Object[] processRequest(OMElement methodElement, + Method method, ObjectSupplier objectSupplier, String[] parameterNames) throws AxisFault { Class[] parameters = method.getParameterTypes(); return BeanUtil.deserialize(methodElement, parameters, objectSupplier, parameterNames); } - public static Object[] processRequest(OMElement methodElement, - Method method, ObjectSupplier objectSupplier) + public Object[] processRequest(OMElement methodElement, + Method method, ObjectSupplier objectSupplier) throws AxisFault { return processRequest(methodElement, method, objectSupplier, null); } - public static Object invokeServiceClass(AxisMessage inAxisMessage, - Method method, - Object implClass, - String messageNameSpace, - OMElement methodElement, - MessageContext inMessage) throws AxisFault, + public Object invokeServiceClass(AxisMessage inAxisMessage, + Method method, + Object implClass, + String messageNameSpace, + OMElement methodElement, + MessageContext inMessage) throws AxisFault, IllegalAccessException, InvocationTargetException { if (inAxisMessage.getElementQName() == null) { // method accept empty SOAPbody @@ -196,10 +196,10 @@ if (namesParameter != null){ parameterNames = (String[]) namesParameter.getValue(); } - objectArray = RPCUtil.processRequest(methodElement, + objectArray = processRequest(methodElement, method, inMessage.getAxisService().getObjectSupplier(), parameterNames); } else { - objectArray = RPCUtil.processRequest((OMElement) methodElement.getParent(), + objectArray = processRequest((OMElement) methodElement.getParent(), method, inMessage.getAxisService().getObjectSupplier()); } return method.invoke(implClass, objectArray); @@ -207,10 +207,10 @@ } } - public static OMElement getResponseElement(QName resname, - Object[] objs, - boolean qualified, - TypeTable typeTable) { + public OMElement getResponseElement(QName resname, + Object[] objs, + boolean qualified, + TypeTable typeTable) { if (qualified) { return BeanUtil.getOMElement(resname, objs, new QName(resname.getNamespaceURI(), @@ -225,13 +225,13 @@ } } - public static void processResonseAsDocLitBare(Object resObject, - AxisService service, - SOAPEnvelope envelope, - SOAPFactory fac, - OMNamespace ns, - OMElement bodyContent, - MessageContext outMessage + public void processResonseAsDocLitBare(Object resObject, + AxisService service, + SOAPEnvelope envelope, + SOAPFactory fac, + OMNamespace ns, + OMElement bodyContent, + MessageContext outMessage ) throws Exception { QName elementQName = outMessage.getAxisMessage().getElementQName(); String partName = outMessage.getAxisMessage().getPartName(); @@ -242,7 +242,7 @@ QName resName = new QName(elementQName.getNamespaceURI(), partName, elementQName.getPrefix()); - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = getResponseElement(resName, (Object[]) resObject, service.isElementFormDefault(), service.getTypeTable()); @@ -264,7 +264,7 @@ QName resName = new QName(elementQName.getNamespaceURI(), partName, elementQName.getPrefix()); - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = getResponseElement(resName, objArray, service.isElementFormDefault(), service.getTypeTable()); @@ -283,7 +283,7 @@ QName resName = new QName(elementQName.getNamespaceURI(), partName, elementQName.getPrefix()); - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = getResponseElement(resName, values, service.isElementFormDefault(), service.getTypeTable()); @@ -300,7 +300,7 @@ envelope.getBody().addChild(resElemt); } else { if (service.isElementFormDefault()) { - RPCUtil.processObjectAsDocLitBare(fac, + processObjectAsDocLitBare(fac, resObject, bodyContent, ns, @@ -309,7 +309,7 @@ service.getTypeTable(), partName); } else { - RPCUtil.processObjectAsDocLitBare(fac, + processObjectAsDocLitBare(fac, resObject, bodyContent, ns, @@ -331,8 +331,8 @@ * @param service Current AxisService * @param envelope response enevelop */ - private static void processNullReturns(AxisService service, - SOAPEnvelope envelope, String partName) { + private void processNullReturns(AxisService service, + SOAPEnvelope envelope, String partName) { QName resName; if (service.isElementFormDefault()) { resName = new QName(service.getSchemaTargetNamespace(), @@ -350,14 +350,14 @@ } - public static void processResponseAsDocLitWrapped(Object resObject, - AxisService service, - Method method, - SOAPEnvelope envelope, - SOAPFactory fac, - OMNamespace ns, - OMElement bodyContent, - MessageContext outMessage + public void processResponseAsDocLitWrapped(Object resObject, + AxisService service, + Method method, + SOAPEnvelope envelope, + SOAPFactory fac, + OMNamespace ns, + OMElement bodyContent, + MessageContext outMessage ) throws Exception { QName elementQName = outMessage.getAxisMessage().getElementQName(); if (resObject == null) { @@ -385,7 +385,7 @@ QName resName = new QName(elementQName.getNamespaceURI(), method.getName() + "Response", elementQName.getPrefix()); - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = getResponseElement(resName, (Object[]) resObject, service.isElementFormDefault(), service.getTypeTable()); @@ -407,7 +407,7 @@ QName resName = new QName(elementQName.getNamespaceURI(), method.getName() + "Response", elementQName.getPrefix()); - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = getResponseElement(resName, objArray, service.isElementFormDefault(), service.getTypeTable()); @@ -426,7 +426,7 @@ QName resName = new QName(elementQName.getNamespaceURI(), method.getName() + "Response", elementQName.getPrefix()); - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = getResponseElement(resName, values, service.isElementFormDefault(), service.getTypeTable()); @@ -445,12 +445,12 @@ envelope.getBody().addChild(resElemt); } else { if (service.isElementFormDefault()) { - RPCUtil.processResponse(fac, resObject, bodyContent, ns, + processResponse(fac, resObject, bodyContent, ns, envelope, method, service.isElementFormDefault(), service.getTypeTable()); } else { - RPCUtil.processResponse(fac, resObject, bodyContent, ns, + processResponse(fac, resObject, bodyContent, ns, envelope, method, service.isElementFormDefault(), service.getTypeTable()); Index: src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java =================================================================== --- src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java (revision 785989) +++ src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java (working copy) @@ -36,6 +36,8 @@ private static Log log = LogFactory.getLog(RPCInOnlyMessageReceiver.class); + protected RPCUtil rpcUtil = new RPCUtil(); + public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault { Method method = null; try { @@ -60,7 +62,7 @@ } } if (inAxisMessage != null) { - RPCUtil.invokeServiceClass(inAxisMessage, + rpcUtil.invokeServiceClass(inAxisMessage, method, obj, messageNameSpace, Index: src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java =================================================================== --- src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java (revision 785989) +++ src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java (working copy) @@ -43,6 +43,8 @@ private static Log log = LogFactory.getLog(RPCInOnlyMessageReceiver.class); + protected RPCUtil rpcUtil = new RPCUtil(); + /** * reflect and get the Java method - for each i'th param in the java method - get the first * child's i'th child -if the elem has an xsi:type attr then find the deserializer for it - if @@ -86,7 +88,7 @@ } Object resObject = null; if (inaxisMessage != null) { - resObject = RPCUtil.invokeServiceClass(inaxisMessage, + resObject = rpcUtil.invokeServiceClass(inaxisMessage, method, obj, messageNameSpace, @@ -119,11 +121,11 @@ } Parameter generateBare = service.getParameter(Java2WSDLConstants.DOC_LIT_BARE_PARAMETER); if (generateBare!=null && "true".equals(generateBare.getValue())) { - RPCUtil.processResonseAsDocLitBare(resObject, service, + rpcUtil.processResonseAsDocLitBare(resObject, service, envelope, fac, ns, bodyContent, outMessage); } else { - RPCUtil.processResponseAsDocLitWrapped(resObject, service, + rpcUtil.processResponseAsDocLitWrapped(resObject, service, method, envelope, fac, ns, bodyContent, outMessage); } Index: src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java =================================================================== --- src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java (revision 785989) +++ src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java (working copy) @@ -46,6 +46,8 @@ public class RPCMessageReceiver extends AbstractInOutMessageReceiver { private static Log log = LogFactory.getLog(RPCMessageReceiver.class); + protected RPCUtil rpcUtil = new RPCUtil(); + /** * reflect and get the Java method - for each i'th param in the java method - get the first * child's i'th child -if the elem has an xsi:type attr then find the deserializer for it - if @@ -99,7 +101,7 @@ } Object resObject = null; if (inAxisMessage != null) { - resObject = RPCUtil.invokeServiceClass(inAxisMessage, + resObject = rpcUtil.invokeServiceClass(inAxisMessage, method, obj, messageNameSpace, @@ -131,11 +133,11 @@ } Parameter generateBare = service.getParameter(Java2WSDLConstants.DOC_LIT_BARE_PARAMETER); if (generateBare!=null && "true".equals(generateBare.getValue())) { - RPCUtil.processResonseAsDocLitBare(resObject, service, + rpcUtil.processResonseAsDocLitBare(resObject, service, envelope, fac, ns, bodyContent, outMessage); } else { - RPCUtil.processResponseAsDocLitWrapped(resObject, service, + rpcUtil.processResponseAsDocLitWrapped(resObject, service, method, envelope, fac, ns, bodyContent, outMessage); } Index: src/org/apache/axis2/transport/java/JavaTransportSender.java =================================================================== --- src/org/apache/axis2/transport/java/JavaTransportSender.java (revision 785989) +++ src/org/apache/axis2/transport/java/JavaTransportSender.java (working copy) @@ -45,6 +45,8 @@ public class JavaTransportSender extends AbstractHandler implements TransportSender { + protected RPCUtil rpcUtil = new RPCUtil(); + public void cleanup(MessageContext msgContext) throws AxisFault { } public void init(ConfigurationContext confContext, TransportOutDescription transportOut) @@ -100,7 +102,7 @@ } //gets the object array from the request OMElement ObjectSupplier obj1 = new DefaultObjectSupplier(); - Object[] objectArray = RPCUtil.processRequest(methodElement, method, obj1); + Object[] objectArray = rpcUtil.processRequest(methodElement, method, obj1); //reflective invocation Object resObject ; try { @@ -121,7 +123,7 @@ method.getName() + "Response", service.getSchemaTargetNamespacePrefix()); //create the omelement from the response array - OMElement bodyChild = RPCUtil.getResponseElement(resName, + OMElement bodyChild = rpcUtil.getResponseElement(resName, (Object[]) resObject, false, null); //return type is sent with array size bodyChild.addAttribute("returnType", @@ -129,7 +131,7 @@ envelope.getBody().getDefaultNamespace()); envelope.getBody().addChild(bodyChild); } else { - RPCUtil.processResponse(fac, resObject, bodyContent, ns, envelope, method, false, null); + rpcUtil.processResponse(fac, resObject, bodyContent, ns, envelope, method, false, null); envelope.getBody().getFirstElement().addAttribute("returnType", method.getReturnType().getClass().getName(), envelope.getBody().getDefaultNamespace()); }