1
2
3
4
5
6
7 package org.mule.module.cxf.transport;
8
9 import org.mule.module.cxf.support.DelegatingOutputStream;
10
11 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
13 import java.io.OutputStream;
14 import java.util.logging.Logger;
15
16 import org.apache.cxf.message.Message;
17 import org.apache.cxf.service.model.EndpointInfo;
18 import org.apache.cxf.transport.AbstractConduit;
19 import org.apache.cxf.transport.AbstractDestination;
20 import org.apache.cxf.transport.Conduit;
21 import org.apache.cxf.ws.addressing.EndpointReferenceType;
22
23 public class MuleUniversalDestination extends AbstractDestination
24 {
25 public static final String RESPONSE_OBSERVER = "mule.destination.response.observer";
26
27 private static final Logger LOGGER = Logger.getLogger(MuleUniversalDestination.class.getName());
28 private MuleUniversalTransport transport;
29
30 public MuleUniversalDestination(MuleUniversalTransport transport,
31 EndpointReferenceType ref,
32 EndpointInfo ei)
33 {
34 super(ref, ei);
35 this.transport = transport;
36 }
37
38 @Override
39 protected Conduit getInbuiltBackChannel(Message inMessage)
40 {
41 return new ResponseConduit(null);
42 }
43
44 @Override
45 protected Logger getLogger()
46 {
47 return LOGGER;
48 }
49
50 @Override
51 public void shutdown()
52 {
53 transport.remove(this);
54
55 super.shutdown();
56 }
57
58 public class ResponseConduit extends AbstractConduit
59 {
60
61 public ResponseConduit(EndpointReferenceType arg0)
62 {
63 super(arg0);
64 }
65
66 public void prepare(Message message) throws IOException {
67
68
69 DelegatingOutputStream stream = new DelegatingOutputStream(new ByteArrayOutputStream());
70 message.setContent(OutputStream.class, stream);
71 message.setContent(DelegatingOutputStream.class, stream);
72 }
73
74 @Override
75 public void close(Message message) throws IOException
76 {
77 message.getContent(OutputStream.class).close();
78 }
79
80 @Override
81 protected Logger getLogger()
82 {
83 return LOGGER;
84 }
85
86 }
87 }