1 17 package org.apache.servicemix.components.xfire; 18 19 import org.apache.servicemix.components.util.OutBinding; 20 import org.codehaus.xfire.MessageContext; 21 import org.codehaus.xfire.XFire; 22 import org.codehaus.xfire.exchange.InMessage; 23 import org.codehaus.xfire.transport.Channel; 24 import org.codehaus.xfire.transport.Transport; 25 import org.codehaus.xfire.transport.local.LocalTransport; 26 27 import javax.jbi.JBIException; 28 import javax.jbi.messaging.MessageExchange; 29 import javax.jbi.messaging.NormalizedMessage; 30 import javax.xml.stream.XMLStreamReader; 31 32 public class XFireOutBinding extends OutBinding { 33 private XMarshaler marshaler; 34 35 private XFire xfire; 36 37 public XFireOutBinding() 38 { 39 super(); 40 41 this.marshaler = new XMarshaler(); 42 } 43 44 protected void process(MessageExchange messageExchange, NormalizedMessage nm) throws Exception { 45 46 XMLStreamReader reader = marshaler.createStreamReader(nm); 47 if (reader == null) { 48 throw new JBIException("Could not get source as XMLStreamReader."); 49 } 50 51 InMessage in = new InMessage(reader, ""); 52 MessageContext context = new MessageContext(); 53 context.setXFire(xfire); 54 context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart())); 55 56 Transport transport = xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID); 57 Channel channel = transport.createChannel(); 58 channel.receive(context, in); 59 60 done(messageExchange); 61 } 62 63 public XFire getXfire() { 64 return xfire; 65 } 66 67 public void setXfire(XFire xfire) { 68 this.xfire = xfire; 69 } 70 } 71 | Popular Tags |