KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > module > gui > html > MultilevelSubscribeNode


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.module.gui.html;
11
12 import java.util.*;
13 import org.mmbase.module.core.*;
14
15 /**
16  * This object subscribes itself to builder changes
17  *
18  * @application SCAN
19  * @author Daniel Ockeloen
20  * @deprecated-now This is an _excact copy_ of org.mmbase.cache.MultilevelSubscribeNode
21  */

22 public class MultilevelSubscribeNode implements MMBaseObserver {
23
24     private MMBase mmb;
25     String JavaDoc type;
26     Vector queue=new Vector(50);
27
28     public MultilevelSubscribeNode(MMBase mmb,String JavaDoc type) {
29         this.mmb=mmb;
30         this.type=type;
31         mmb.addLocalObserver(type,this);
32         mmb.addRemoteObserver(type,this);
33     }
34
35     public boolean nodeChanged(String JavaDoc machine,String JavaDoc number,String JavaDoc builder,String JavaDoc ctype) {
36         clearEntrys();
37         return(true);
38     }
39
40     public synchronized void clearEntrys() {
41         Enumeration e=queue.elements();
42         while (e.hasMoreElements()) {
43             MultilevelCacheEntry n=(MultilevelCacheEntry)e.nextElement();
44             // call the entry's clear that will remove all observers
45
// too including myself !
46
n.clear();
47         }
48     }
49
50     public boolean nodeRemoteChanged(String JavaDoc machine, String JavaDoc number,String JavaDoc builder,String JavaDoc ctype) {
51         return(nodeChanged(machine,number,builder,ctype));
52     }
53
54     public boolean nodeLocalChanged(String JavaDoc machine,String JavaDoc number,String JavaDoc builder,String JavaDoc ctype) {
55         return(nodeChanged(machine,number,builder,ctype));
56     }
57
58     public boolean removeCacheEntry(MultilevelCacheEntry entry) {
59         if (queue.contains(entry)) {
60             queue.remove(entry);
61             return(true);
62         } else {
63             return(false);
64         }
65     }
66
67     public boolean addCacheEntry(MultilevelCacheEntry entry) {
68         // add myself to the entry so he can find me for remove
69
entry.addListener(this);
70
71         // add the entry to my queue
72
if (!queue.contains(entry)) {
73             queue.addElement(entry);
74         }
75         return(true);
76     }
77 }
78
Popular Tags