KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > lockmanager > api > WaitContext


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.lockmanager.api;
5
6 import com.tc.io.TCByteBufferInputStream;
7 import com.tc.io.TCByteBufferOutput;
8 import com.tc.net.protocol.tcm.ChannelID;
9 import com.tc.object.tx.WaitInvocation;
10 import com.tc.object.tx.WaitInvocationFactory;
11
12 import java.io.IOException JavaDoc;
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, ChannelID channelID, ThreadID threadID, int lockLevel, WaitInvocation waitInvocation) {
24     super(lockID, channelID, threadID, lockLevel);
25     this.waitInvocation = waitInvocation;
26   }
27
28   public WaitContext() {
29     return;
30   }
31
32   public WaitInvocation getWaitInvocation() {
33     return waitInvocation;
34   }
35
36   public void serializeTo(TCByteBufferOutput output) {
37     super.serializeTo(output);
38     output.writeByte(waitInvocation.getSignature().getArgCount());
39     output.writeLong(waitInvocation.getMillis());
40     output.writeInt(waitInvocation.getNanos());
41   }
42
43   public Object JavaDoc deserializeFrom(TCByteBufferInputStream input) throws IOException JavaDoc {
44     super.deserializeFrom(input);
45     waitInvocation = waitInvocationFactory.newWaitInvocation(input.readByte(), input.readLong(), input.readInt());
46     return this;
47   }
48 }
49
Popular Tags