1 10 11 package org.mule.providers.soap.axis; 12 13 import java.lang.reflect.InvocationHandler ; 14 import java.lang.reflect.Method ; 15 import java.lang.reflect.Proxy ; 16 import org.mule.config.ExceptionHelper; 17 import org.mule.config.MuleProperties; 18 import org.mule.impl.MuleMessage; 19 import org.mule.impl.RequestContext; 20 import org.mule.providers.AbstractMessageReceiver; 21 import org.mule.providers.soap.ServiceProxy; 22 import org.mule.umo.UMOException; 23 import org.mule.umo.UMOExceptionPayload; 24 import org.mule.umo.UMOMessage; 25 import org.mule.umo.provider.UMOMessageAdapter; 26 import org.mule.providers.soap.axis.extras.AxisCleanAndAddProperties; 27 28 36 37 public class AxisServiceProxy extends ServiceProxy 38 { 39 40 public static Object createProxy(AbstractMessageReceiver receiver, boolean synchronous, Class [] classes) 41 { 42 final ClassLoader cl = Thread.currentThread().getContextClassLoader(); 43 return Proxy.newProxyInstance(cl, classes, createServiceHandler(receiver, synchronous)); 44 } 45 46 public static InvocationHandler createServiceHandler(AbstractMessageReceiver receiver, boolean synchronous) 47 { 48 return new AxisServiceHandler(receiver, synchronous); 49 } 50 51 private static class AxisServiceHandler implements InvocationHandler 52 { 53 private AbstractMessageReceiver receiver; 54 private boolean synchronous = true; 55 56 public AxisServiceHandler(AbstractMessageReceiver receiver, boolean synchronous) 57 { 58 this.receiver = receiver; 59 this.synchronous = synchronous; 60 } 61 62 public Object invoke(Object proxy, Method method, Object [] args) throws Throwable 63 { 64 UMOMessageAdapter messageAdapter = receiver.getConnector().getMessageAdapter(args); 65 messageAdapter.setProperty(MuleProperties.MULE_METHOD_PROPERTY, method); 66 67 messageAdapter.addProperties(AxisCleanAndAddProperties.cleanAndAdd(RequestContext.getEventContext())); 73 74 UMOMessage message = receiver.routeMessage(new MuleMessage(messageAdapter), synchronous); 75 76 if (message != null) 77 { 78 UMOExceptionPayload wsException = message.getExceptionPayload(); 79 80 if (wsException != null) 81 { 82 UMOException umoException = ExceptionHelper.getRootMuleException(wsException.getException()); 83 if (umoException.getCause() != null) 85 { 86 throw umoException.getCause(); 87 } 88 else 89 { 90 throw umoException; 91 } 92 } 93 94 return message.getPayload(); 95 } 96 else 97 { 98 return null; 99 } 100 } 101 } 102 } 103 | Popular Tags |