KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > clustering > WaitNode


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.clustering;
11
12 import org.mmbase.module.core.MMObjectNode;
13 import org.mmbase.util.logging.Logger;
14 import org.mmbase.util.logging.Logging;
15
16 /**
17  * WaitNode is a wrapper class for MMObjectNode we want to
18  * put into a 'waiting for a change' mode we don't block on the object
19  * itself because we need to check its number before we nofity it again.
20  *
21  * TODO: Missing javadoc on methods, odd methods name ('do-..'), used nowhere. Where it this class
22  * good for? Should it perhaps simply be dropped?
23  * @version $Id: WaitNode.java,v 1.4 2006/04/02 11:49:07 michiel Exp $
24  */

25 public class WaitNode {
26
27     private static final Logger log = Logging.getLoggerInstance(WaitNode.class);
28
29     /**
30      * @javadoc
31      */

32     private int number;
33
34     /**
35      * @javadoc
36      */

37     public WaitNode(MMObjectNode node) {
38         this.number = node.getNumber();
39     }
40
41     /**
42      * @javadoc
43      */

44     public synchronized void doWait(int time) {
45         try {
46             wait(time);
47         } catch(Exception JavaDoc e) {
48             log.error(Logging.stackTrace(e));
49         }
50     }
51
52     /**
53      * @javadoc
54      */

55     public boolean doNotifyCheck(int wantednumber) {
56         if (number == wantednumber) {
57             doNotify();
58             return true;
59         } else {
60             return false;
61         }
62     }
63
64     /**
65      * @javadoc
66      */

67     public synchronized void doNotify() {
68         notify();
69     }
70
71 }
72
73
Popular Tags