1 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 24 public class BaseMessage implements Serializable 25 { 26 29 private static final long serialVersionUID = -6105691921086093748L; 30 31 protected Object message; 32 33 protected Map context; 34 35 public BaseMessage(Object message) 36 { 37 this.message = message; 38 context = new HashMap (); 39 } 40 41 47 public String getPayloadAsString(String encoding) throws Exception 48 { 49 return message.toString(); 50 } 51 52 58 public byte[] getPayloadAsBytes() throws Exception 59 { 60 return getPayloadAsString(message.toString()).getBytes(); 61 } 62 63 66 public Object getPayload() 67 { 68 return message; 69 } 70 71 76 public void addProperties(Map properties) 77 { 78 context.putAll(properties); 79 } 80 81 84 public void clearProperties() 85 { 86 context.clear(); 87 } 88 89 94 public Map getProperties() 95 { 96 return context; 97 } 98 99 public void setProperty(Object key, Object value) 100 { 101 context.put(key, value); 102 } 103 104 public Object getProperty(Object key) 105 { 106 return context.get(key); 107 } 108 109 public String toString() 110 { 111 return "BaseMessage{" + "message=" + message + ", context=" + context + "}"; 112 } 113 } 114 | Popular Tags |