KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > api > TestSink


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.objectserver.api;
5
6 import com.tc.async.api.AddPredicate;
7 import com.tc.async.api.EventContext;
8 import com.tc.async.api.Sink;
9 import com.tc.exception.ImplementMe;
10 import com.tc.stats.Stats;
11
12 import java.util.Collection JavaDoc;
13 import java.util.LinkedList JavaDoc;
14 import java.util.List JavaDoc;
15
16 /**
17  * @author steve
18  */

19 public class TestSink implements Sink {
20   private final List JavaDoc queue = new LinkedList JavaDoc();
21
22   public boolean addLossy(EventContext context) {
23     return false;
24   }
25
26   public void addMany(Collection JavaDoc contexts) {
27     //
28
}
29
30   public void add(EventContext context) {
31     synchronized (queue) {
32       queue.add(context);
33       queue.notifyAll();
34     }
35   }
36
37   public EventContext waitForAdd(long millis) throws InterruptedException JavaDoc {
38     synchronized (queue) {
39       if (queue.size() < 1) {
40         queue.wait(millis);
41       }
42       return queue.size() < 1 ? null : (EventContext) queue.get(0);
43     }
44   }
45
46   public EventContext take() throws InterruptedException JavaDoc {
47     synchronized (queue) {
48       while (queue.size() < 1) {
49         queue.wait();
50       }
51       return (EventContext) queue.remove(0);
52     }
53   }
54   
55   public void setAddPredicate(AddPredicate predicate) {
56     //
57
}
58
59   public AddPredicate getPredicate() {
60     return null;
61   }
62
63   public int size() {
64     return queue.size();
65   }
66
67   public List JavaDoc getInternalQueue() {
68     return queue;
69   }
70
71   public void clear() {
72     throw new ImplementMe();
73   }
74
75   public void unpause() {
76     throw new ImplementMe();
77   }
78
79   public void pause(List JavaDoc pauseEvents) {
80     throw new ImplementMe();
81   }
82
83   public void enableStatsCollection(boolean enable) {
84     throw new ImplementMe();
85   }
86
87   public Stats getStats(long frequency) {
88     throw new ImplementMe();
89   }
90
91   public Stats getStatsAndReset(long frequency) {
92     throw new ImplementMe();
93   }
94
95   public boolean isStatsCollectionEnabled() {
96     throw new ImplementMe();
97   }
98
99   public void resetStats() {
100     throw new ImplementMe();
101   }
102
103 }
Popular Tags