XFireHome M5M6-SNAPSHOTDevelopersDeveloper Space |
Transports and ChannelsChannels and Transports provide the basic unit of communication in XFire. A Channel simply sends messages (via send()) and listens for messages (via receive()). If you want to send a message to a particular URL you do: TransportManager tm = ...; Transport t = tm.getTransportForUri("http://foo"); OutMessage msg = ...; // create an outmessage yourself Channel c = t.createChannel(); // create an anonymous endpoint MessageContext context = new MessageContext(); c.send(msg, context); Each transport is responsible for creating its own protocol specific listener, for example a servlet in the case of HTTP. This listener then passes whatever messages it receives to the channel via Channel.receive(MessageContext,InMessage). Channels simply delegate their receive() to a ChannelEndpoint which application specific handling of what to do with the message. The default endpoint is aptly named DefaultEndpoint and will be covered in the next section. MessageSerializerEach OutMessage has a MessageSerializer. A message serializer takes the message body (message.getBody()) and writes it to an XMLStreamWriter that the Channel provides. The semantics of MessageSerializers should be such that they can be invoked multiple times. Channels/Transports without ServicesIts important to note that Channels and transports are completely independent of XFire's Services. So I can use a channel to send a receive messages and never even create a service. So for testing, lets not even create a service. We'll want to just use the Channel to send and receive messages. DefaultEndpoint and the processing flowDefaultEndpoint takes a message, creates a default message exchange called InMessageExchange and creates a message pipeline. The message pipeline at first consists of the global in handlers from XFire.getInHandlers() and the transport handlers from Transport.getInHandlers. Later on when the service is resolved, the service's handlers get added into the pipeline. Once the operation is resolved, if there is an out message to be set an Out pipeline is created and added to the MessageContext. Phases and HandlersSee Processing Pipeline for now. SOAP ProcessingSOAPTransport.createTransport() adds SOAP support to a particular transport. It does so by adding three additional handlers:
MessageExchangesWS-RM Architecture PlanThere will be two transports involved in this. First, the low-level transport like HTTP, UDP or TCP. We'll use UdpTransport for the examples below. Second, there is the WS-RM Transport - WSRMTransport. The high-level ws-rm document outlines the basic sequence which I'll refer to:
The server side correlate:
Transport/Channel layerIdeally I'd like to be able to do: WSRMTransport transport = new WSRMTransport(new UdpTransport()); When an application does WSRMChannel.send() it will handle the sequence processing and ultimately use UdpChannel to send its messages. When UdpTransport receives its messages, we'll need them to delegate on up to the WSRMTransport. To do this we'll need to create a new ChannelEndpoint which does this. // Simply pass messages up to the WSRM channel public class WSRMDelegateEndpoint { WSRMChannel channel; public WSRMDelegateEndpoint(WSRMChannel channel) { this.channel = channel; } public void onReceive(MessageContext context, InMessage msg) { channel.receive(context, msg); } } Dan's TODO
|