1 10 11 package org.mule.providers.soap.xfire; 12 13 import java.lang.reflect.Method ; 14 15 import javax.xml.namespace.QName ; 16 17 import org.codehaus.xfire.MessageContext; 18 import org.codehaus.xfire.fault.XFireFault; 19 import org.codehaus.xfire.service.invoker.Invoker; 20 import org.mule.config.MuleProperties; 21 import org.mule.impl.MuleMessage; 22 import org.mule.providers.AbstractMessageReceiver; 23 import org.mule.providers.NullPayload; 24 import org.mule.umo.UMOException; 25 import org.mule.umo.UMOMessage; 26 import org.mule.umo.endpoint.UMOImmutableEndpoint; 27 28 31 public class MuleInvoker implements Invoker 32 { 33 private final AbstractMessageReceiver receiver; 34 private final boolean synchronous; 35 36 public MuleInvoker(AbstractMessageReceiver receiver, boolean synchronous) 37 { 38 this.receiver = receiver; 39 this.synchronous = synchronous; 40 } 41 42 public Object invoke(Method method, Object [] objects, MessageContext messageContext) throws XFireFault 43 { 44 UMOMessage message = null; 45 try 46 { 47 XFireMessageAdapter messageAdapter = (XFireMessageAdapter)receiver.getConnector() 48 .getMessageAdapter(objects); 49 messageAdapter.setMessageContext(messageContext); 50 messageAdapter.setProperty(MuleProperties.MULE_METHOD_PROPERTY, method); 51 52 message = receiver.routeMessage(new MuleMessage(messageAdapter), synchronous); 53 } 54 catch (UMOException e) 55 { 56 throw new XFireFault(e); 57 } 58 59 if (message != null) 60 { 61 if (message.getExceptionPayload() != null) 62 { 63 QName code = new QName (String.valueOf(message.getExceptionPayload().getCode())); 64 throw new XFireFault(message.getExceptionPayload().getMessage(), 65 message.getExceptionPayload().getException(), code); 66 } 67 else if (message.getPayload() instanceof NullPayload) 68 { 69 return null; 70 } 71 else 72 { 73 return message.getPayload(); 74 } 75 } 76 else 77 { 78 return null; 79 } 80 } 81 82 public UMOImmutableEndpoint getEndpoint() 83 { 84 return receiver.getEndpoint(); 85 } 86 } 87 | Popular Tags |