Revision 682
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/observer/impl/ComplexNotification.java | ||
---|---|---|
27 | 27 |
package org.gvsig.tools.observer.impl; |
28 | 28 |
|
29 | 29 |
import java.util.ArrayList; |
30 |
import java.util.ConcurrentModificationException; |
|
31 | 30 |
import java.util.List; |
32 | 31 |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
33 | 35 |
import org.gvsig.tools.exception.BaseException; |
34 | 36 |
import org.gvsig.tools.lang.Cloneable; |
35 | 37 |
import org.gvsig.tools.visitor.Visitable; |
36 | 38 |
import org.gvsig.tools.visitor.Visitor; |
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 | 39 |
|
40 | 40 |
public class ComplexNotification implements Cloneable, Visitable { |
41 |
private static Logger log=LoggerFactory.getLogger(ComplexNotification.class);
|
|
42 |
private List list=new ArrayList();
|
|
43 |
static boolean visiting=false;
|
|
41 |
private static Logger log =
|
|
42 |
LoggerFactory.getLogger(ComplexNotification.class);
|
|
43 |
private List list = new ArrayList();
|
|
44 | 44 |
|
45 |
public synchronized void addNotification(Object arg) throws ConcurrentModificationException { |
|
46 |
if (visiting) { |
|
47 |
throw new ConcurrentModificationException(); |
|
48 |
} |
|
45 |
public synchronized void addNotification(Object arg) { |
|
49 | 46 |
list.add(arg); |
50 | 47 |
} |
51 | 48 |
|
... | ... | |
53 | 50 |
|
54 | 51 |
} |
55 | 52 |
|
56 |
/** |
|
57 |
* |
|
58 |
*/ |
|
59 | 53 |
public void clear() { |
60 |
// TODO Auto-generated method stub |
|
61 | 54 |
|
62 | 55 |
} |
63 | 56 |
|
... | ... | |
66 | 59 |
} |
67 | 60 |
|
68 | 61 |
public synchronized void accept(Visitor visitor) throws BaseException { |
69 |
visiting = true; |
|
70 | 62 |
for (int i = 0; i < this.list.size(); i++) { |
71 | 63 |
try { |
72 | 64 |
Object notification = this.list.get(i); |
... | ... | |
75 | 67 |
log.warn("Error sending notification.", t); |
76 | 68 |
} |
77 | 69 |
} |
78 |
visiting = false; |
|
79 | 70 |
} |
80 | 71 |
} |
Also available in: Unified diff