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