1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.util.ajax;
17
18 import java.util.HashSet;
19 import java.util.Iterator;
20 import java.util.Set;
21
22 public class SharedObjects {
23
24 private Set objects = new HashSet();
25
26 public int size(){
27 synchronized (objects) {
28 return objects.size();
29 }
30 }
31
32 public void addObject(Ajaxlizable obj) {
33 synchronized (objects) {
34 objects.add(obj);
35 obj.setSharedObject(this);
36 }
37 }
38
39 public void removeObject(Ajaxlizable obj) {
40 synchronized (objects) {
41 objects.remove(obj);
42 }
43 }
44
45 public void addEvent(AjaxEvent event, Object fromObj) {
46 synchronized (objects) {
47 Iterator itr = objects.iterator();
48 while (itr.hasNext()) {
49 Ajaxlizable obj = (Ajaxlizable) itr.next();
50 if (!obj.equals(fromObj)) {
51 obj.addEvent(event);
52 }
53 }
54 }
55 }
56 }