01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.msg;
05:
06: import com.tc.async.api.EventContext;
07: import com.tc.bytes.TCByteBuffer;
08: import com.tc.io.TCByteBufferOutput;
09: import com.tc.net.protocol.tcm.MessageChannel;
10: import com.tc.net.protocol.tcm.MessageMonitor;
11: import com.tc.net.protocol.tcm.TCMessageHeader;
12: import com.tc.net.protocol.tcm.TCMessageType;
13: import com.tc.object.ObjectID;
14: import com.tc.object.session.SessionID;
15:
16: import java.io.IOException;
17:
18: /**
19: * @author steve
20: */
21: public class RequestRootResponseMessage extends DSOMessageBase
22: implements EventContext {
23: private final static byte ROOT_NAME = 1;
24: private final static byte ROOT_ID = 2;
25:
26: private String rootName;
27: private ObjectID rootID;
28:
29: public RequestRootResponseMessage(SessionID sessionID,
30: MessageMonitor monitor, TCByteBufferOutput out,
31: MessageChannel channel, TCMessageType type) {
32: super (sessionID, monitor, out, channel, type);
33: }
34:
35: public RequestRootResponseMessage(SessionID sessionID,
36: MessageMonitor monitor, MessageChannel channel,
37: TCMessageHeader header, TCByteBuffer[] data) {
38: super (sessionID, monitor, channel, header, data);
39: }
40:
41: protected void dehydrateValues() {
42: putNVPair(ROOT_ID, rootID.toLong());
43: putNVPair(ROOT_NAME, rootName);
44: }
45:
46: protected boolean hydrateValue(byte name) throws IOException {
47: switch (name) {
48: case ROOT_ID:
49: this .rootID = new ObjectID(getLongValue());
50: return true;
51: case ROOT_NAME:
52: this .rootName = getStringValue();
53: return true;
54: default:
55: return false;
56: }
57: }
58:
59: public String getRootName() {
60: return rootName;
61: }
62:
63: public ObjectID getRootID() {
64: return rootID;
65: }
66:
67: public void initialize(String name, ObjectID id) {
68: this.rootID = id;
69: this.rootName = name;
70: }
71: }
|