KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tcclient > object > Client


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.tcclient.object;
5
6 import java.util.LinkedList JavaDoc;
7 import java.util.List JavaDoc;
8
9 /**
10  * Representation of a client
11  */

12 public class Client {
13   private final List JavaDoc myEvents = new LinkedList JavaDoc();
14   private long lastChecked = System.currentTimeMillis();
15
16   public void add(DistributedMethodCall dmc) {
17     myEvents.add(dmc);
18   }
19
20   public DistributedMethodCall next() {
21     return (DistributedMethodCall) myEvents.remove(0);
22   }
23
24   public boolean isEmpty() {
25     lastChecked = System.currentTimeMillis();
26     return myEvents.isEmpty();
27   }
28
29   public boolean isTimedOut() {
30     return System.currentTimeMillis() - lastChecked > 60 * 1000 * 10;
31   }
32   
33   public String JavaDoc toString() {
34     return super.toString() + "[" + myEvents + "]";
35   }
36 }
Popular Tags