1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.module.ibeans.spi; |
8 | |
|
9 | |
import org.mule.api.MuleMessage; |
10 | |
import org.mule.api.MuleRuntimeException; |
11 | |
import org.mule.api.transport.PropertyScope; |
12 | |
|
13 | |
import java.util.Set; |
14 | |
|
15 | |
import javax.activation.DataHandler; |
16 | |
|
17 | |
import org.ibeans.api.IBeanInvocationData; |
18 | |
import org.ibeans.api.Request; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class MuleRequestMessage implements Request |
24 | |
{ |
25 | |
private MuleMessage message; |
26 | 0 | private int timeout = 0; |
27 | |
private IBeanInvocationData data; |
28 | |
|
29 | |
public MuleRequestMessage(IBeanInvocationData data, MuleMessage message) |
30 | 0 | { |
31 | 0 | this.message = message; |
32 | 0 | this.data = data; |
33 | 0 | } |
34 | |
|
35 | |
public Object getPayload() |
36 | |
{ |
37 | 0 | return message.getPayload(); |
38 | |
} |
39 | |
|
40 | |
public void setPayload(Object payload) |
41 | |
{ |
42 | 0 | message.setPayload(payload); |
43 | 0 | } |
44 | |
|
45 | |
public void addHeader(String name, Object value) |
46 | |
{ |
47 | 0 | message.setOutboundProperty(name, value); |
48 | 0 | } |
49 | |
|
50 | |
public Object removeHeader(String name) |
51 | |
{ |
52 | 0 | return message.removeProperty(name, PropertyScope.OUTBOUND); |
53 | |
} |
54 | |
|
55 | |
public Object getHeader(String name) |
56 | |
{ |
57 | 0 | return message.getOutboundProperty(name); |
58 | |
} |
59 | |
|
60 | |
public Set<String> getHeaderNames() |
61 | |
{ |
62 | 0 | return message.getOutboundPropertyNames(); |
63 | |
} |
64 | |
|
65 | |
public void addAttachment(String name, DataHandler handler) |
66 | |
{ |
67 | |
try |
68 | |
{ |
69 | 0 | message.addOutboundAttachment(name, handler); |
70 | |
} |
71 | 0 | catch (Exception e) |
72 | |
{ |
73 | 0 | throw new MuleRuntimeException(e); |
74 | 0 | } |
75 | 0 | } |
76 | |
|
77 | |
public DataHandler removeAttachment(String name) |
78 | |
{ |
79 | 0 | DataHandler dh = message.getOutboundAttachment(name); |
80 | |
try |
81 | |
{ |
82 | 0 | if(dh!=null) |
83 | 0 | message.removeOutboundAttachment(name); |
84 | |
} |
85 | 0 | catch (Exception e) |
86 | |
{ |
87 | 0 | throw new MuleRuntimeException(e); |
88 | 0 | } |
89 | 0 | return dh; |
90 | |
} |
91 | |
|
92 | |
public DataHandler getAttachment(String name) |
93 | |
{ |
94 | 0 | return message.getOutboundAttachment(name); |
95 | |
} |
96 | |
|
97 | |
public Set<String> getAttachmentNames() |
98 | |
{ |
99 | 0 | return message.getOutboundAttachmentNames(); |
100 | |
} |
101 | |
|
102 | |
public int getTimeout() |
103 | |
{ |
104 | 0 | return timeout; |
105 | |
} |
106 | |
|
107 | |
public void setTimeout(int timeout) |
108 | |
{ |
109 | 0 | this.timeout = timeout; |
110 | 0 | } |
111 | |
|
112 | |
public IBeanInvocationData getIBeanInvocationData() |
113 | |
{ |
114 | 0 | return data; |
115 | |
} |
116 | |
|
117 | |
public MuleMessage getMessage() |
118 | |
{ |
119 | 0 | return message; |
120 | |
} |
121 | |
} |