blob: 93750cc874fe84e68f9d702007cd6e16cb9dc270 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import java.util.*;
//ObserverProtocol
public abstract aspect ObserverProtocol{
abstract pointcut stateChange(Subject subject);
after(Subject subject):stateChange(subject){
Iterator it=subject.getObservers().iterator();
while(it.hasNext()){
Observer observer=(Observer)it.next();
observer.update();
}
}
private Collection Subject.observers=new ArrayList();
public void Subject.addObserver(Observer observer){
observers.add(observer);
}
public void Subject.removeObserver(Observer observer){
observers.remove(observer);
}
public Collection Subject.getObservers()
{
return observers;
}
public void Subject.setObservers(Collection c) {
observers = c;
}
private Collection myCollection = new ArrayList();
public Collection returnsCollectionMethod() { return myCollection; }
public Collection C1.getCollection() {
return aCollection;
}
public void C1.setCollection(Collection c) {
aCollection = c;
}
}
class C1 {
public Collection aCollection;
}
|