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.lockmanager.api;
05:
06: import com.tc.io.TCByteBufferInput;
07: import com.tc.io.TCByteBufferOutput;
08: import com.tc.net.groups.ClientID;
09: import com.tc.object.tx.WaitInvocation;
10: import com.tc.object.tx.WaitInvocationFactory;
11:
12: import java.io.IOException;
13:
14: /**
15: * Client/Server intermediate format to hold distributed wait(..) invocation information.
16: */
17: public class WaitContext extends LockContext {
18:
19: private static final WaitInvocationFactory waitInvocationFactory = new WaitInvocationFactory();
20:
21: private WaitInvocation waitInvocation;
22:
23: public WaitContext(LockID lockID, ClientID cid, ThreadID threadID,
24: int lockLevel, WaitInvocation waitInvocation) {
25: super (lockID, cid, threadID, lockLevel);
26: this .waitInvocation = waitInvocation;
27: }
28:
29: public WaitContext() {
30: return;
31: }
32:
33: public WaitInvocation getWaitInvocation() {
34: return waitInvocation;
35: }
36:
37: public void serializeTo(TCByteBufferOutput output) {
38: super .serializeTo(output);
39: output.writeByte(waitInvocation.getSignature().getArgCount());
40: output.writeLong(waitInvocation.getMillis());
41: output.writeInt(waitInvocation.getNanos());
42: }
43:
44: public Object deserializeFrom(TCByteBufferInput input)
45: throws IOException {
46: super.deserializeFrom(input);
47: waitInvocation = waitInvocationFactory.newWaitInvocation(input
48: .readByte(), input.readLong(), input.readInt());
49: return this;
50: }
51: }
|