01: /*
02: * TubelineSender.java
03: *
04: * @author Mike Grogan
05: *
06: * Created on August 27, 2007, 10:57 AM
07: *
08: */
09:
10: package com.sun.xml.ws.rm.jaxws.runtime.server;
11:
12: import com.sun.istack.NotNull;
13: import com.sun.xml.ws.api.SOAPVersion;
14: import com.sun.xml.ws.api.pipe.Tube;
15: import com.sun.xml.ws.api.pipe.TubeCloner;
16: import com.sun.xml.ws.api.pipe.Fiber;
17: import com.sun.xml.ws.api.message.Packet;
18: import com.sun.xml.ws.api.addressing.AddressingVersion;
19: import com.sun.xml.ws.rm.MessageSender;
20: import com.sun.xml.ws.rm.Message;
21:
22: public class TubelineSender implements MessageSender,
23: Fiber.CompletionCallback {
24:
25: private Fiber fiber;
26: private Fiber parentFiber;
27: private Packet requestPacket;
28: private SOAPVersion soapVersion;
29: private AddressingVersion addressingVersion;
30: private RMServerTube tube;
31: private Message message;
32:
33: public TubelineSender(RMServerTube tube, Packet packet,
34: SOAPVersion soapVersion, AddressingVersion addressingVersion) {
35:
36: this .requestPacket = packet;
37: this .parentFiber = Fiber.current();
38: this .fiber = parentFiber.owner.createFiber();
39: this .soapVersion = soapVersion;
40: this .addressingVersion = addressingVersion;
41: this .tube = tube;
42:
43: }
44:
45: public void onCompletion(@NotNull
46: Packet packet) {
47: try {
48: tube.postProcess(packet);
49: parentFiber.resume(packet);
50:
51: } catch (Throwable t) {
52: onCompletion(t);
53: }
54: }
55:
56: public void onCompletion(@NotNull
57: Throwable throwable) {
58:
59: try {
60: com.sun.xml.ws.api.message.Message mess = com.sun.xml.ws.api.message.Messages
61: .create(throwable, soapVersion);
62:
63: Packet packet = requestPacket.createServerResponse(mess,
64: addressingVersion, soapVersion, addressingVersion
65: .getDefaultFaultAction());
66: parentFiber.resume(packet);
67: } catch (Throwable t) {
68: //TODO -
69: }
70:
71: }
72:
73: public void send() {
74: fiber.start(TubeCloner.clone(tube.nextTube()), requestPacket,
75: this);
76: };
77:
78: }
|