2 import org.opensrf.util.*;
5 public class Message implements OSRFSerializable {
8 public static final String REQUEST = "REQUEST";
9 public static final String STATUS = "STATUS";
10 public static final String RESULT = "RESULT";
11 public static final String CONNECT = "CONNECT";
12 public static final String DISCONNECT = "DISCONNECT";
14 /** Message ID. This number is used to relate requests to responses */
16 /** type of message. */
18 /** message payload */
19 private Object payload;
21 /** Create a registry for the osrfMessage object */
22 private static OSRFRegistry registry =
23 OSRFRegistry.registerObject(
25 OSRFRegistry.WireProtocol.HASH,
26 new String[] {"threadTrace", "type", "payload"});
29 * @param id This message's ID
30 * @param type The type of message
32 public Message(int id, String type) {
38 * @param id This message's ID
39 * @param type The type of message
40 * @param payload The message payload
42 public Message(int id, String type, Object payload) {
51 public String getType() {
54 public Object getPayload() {
57 public void setId(int id) {
60 public void setString(String type) {
63 public void setPayload(Object p) {
68 * Implements the generic get() API required by OSRFSerializable
70 public Object get(String field) {
71 if("threadTrace".equals(field))
73 if("type".equals(field))
74 return getType().toString();
75 if("payload".equals(field))
81 * @return The osrfMessage registry.
83 public OSRFRegistry getRegistry() {