1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl.message;
12
13 import java.io.Serializable;
14 import java.util.HashMap;
15 import java.util.Map;
16
17
18
19
20
21 public class BaseMessage implements Serializable
22 {
23
24
25
26 private static final long serialVersionUID = -6105691921086093748L;
27
28 protected Object message;
29
30 protected Map context;
31
32 public BaseMessage(Object message)
33 {
34 this.message = message;
35 context = new HashMap();
36 }
37
38
39
40
41
42
43
44 public String getPayloadAsString(String encoding) throws Exception
45 {
46 return message.toString();
47 }
48
49
50
51
52
53
54
55 public byte[] getPayloadAsBytes() throws Exception
56 {
57 return getPayloadAsString(message.toString()).getBytes();
58 }
59
60
61
62
63 public Object getPayload()
64 {
65 return message;
66 }
67
68
69
70
71
72
73 public void addProperties(Map properties)
74 {
75 context.putAll(properties);
76 }
77
78
79
80
81 public void clearProperties()
82 {
83 context.clear();
84 }
85
86
87
88
89
90
91 public Map getProperties()
92 {
93 return context;
94 }
95
96 public void setProperty(Object key, Object value)
97 {
98 context.put(key, value);
99 }
100
101 public Object getProperty(Object key)
102 {
103 return context.get(key);
104 }
105
106 public String toString()
107 {
108 return "BaseMessage{" + "message=" + message + ", context=" + context + "}";
109 }
110 }