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 | 0 | public class MuleUniversalDestination extends AbstractDestination |
24 | |
{ |
25 | |
public static final String RESPONSE_OBSERVER = "mule.destination.response.observer"; |
26 | |
|
27 | 0 | 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 | 0 | super(ref, ei); |
35 | 0 | this.transport = transport; |
36 | 0 | } |
37 | |
|
38 | |
@Override |
39 | |
protected Conduit getInbuiltBackChannel(Message inMessage) |
40 | |
{ |
41 | 0 | return new ResponseConduit(null); |
42 | |
} |
43 | |
|
44 | |
@Override |
45 | |
protected Logger getLogger() |
46 | |
{ |
47 | 0 | return LOGGER; |
48 | |
} |
49 | |
|
50 | |
@Override |
51 | |
public void shutdown() |
52 | |
{ |
53 | 0 | transport.remove(this); |
54 | |
|
55 | 0 | super.shutdown(); |
56 | 0 | } |
57 | |
|
58 | |
public class ResponseConduit extends AbstractConduit |
59 | |
{ |
60 | |
|
61 | |
public ResponseConduit(EndpointReferenceType arg0) |
62 | 0 | { |
63 | 0 | super(arg0); |
64 | 0 | } |
65 | |
|
66 | |
public void prepare(Message message) throws IOException { |
67 | |
|
68 | |
|
69 | 0 | DelegatingOutputStream stream = new DelegatingOutputStream(new ByteArrayOutputStream()); |
70 | 0 | message.setContent(OutputStream.class, stream); |
71 | 0 | message.setContent(DelegatingOutputStream.class, stream); |
72 | 0 | } |
73 | |
|
74 | |
@Override |
75 | |
public void close(Message message) throws IOException |
76 | |
{ |
77 | 0 | message.getContent(OutputStream.class).close(); |
78 | 0 | } |
79 | |
|
80 | |
@Override |
81 | |
protected Logger getLogger() |
82 | |
{ |
83 | 0 | return LOGGER; |
84 | |
} |
85 | |
|
86 | |
} |
87 | |
} |