Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] A Pattern Implementation

Hi,
 
I am reading this paper
 
"Implementing Design Patterns Using Advanced Separation of Concerns"
 
written by Noda and Kishi, published in a workshop on ASOC in OOS - OOPSLA 01.
 
It implements GoF Observer pattern using AspectJ. For each of the two pattern roles i.e. Subject and Observer, authors define two aspects - one reusable and other for binding this reusable part to classes in a particular context. Part of their implementation is shown below:
 
public abstract aspect Subject {
    protected Vector observers = new Vector();
    public void attach( Observer obs ) {
    ...
    }
}
 
public aspect CounterAsSubject extends Subject of eachobject( instanceof(Counter) ) {
...
}
 
Usually we need to inherit context classes from pattern roles to implement design patterns. Here, I cannot understand how the context or application classes can use the abstractions of pattern roles i.e. how class Counter implementing Subject role can register an observer object? Perhaps I need an explanation of the phrase "of eachobject( instanceof(Counter) )".
 
A lot of thanks in advance.
 
Regards,
Aamir Raheem,
NUCES,
Pakistan.


Express yourself instantly with MSN Messenger! MSN Messenger Download today it's FREE!

Back to the top