[Xotcl] Filter Chaining Question
Sheik Yussuff
sheik at carib-link.net
Sun Jul 15 21:45:40 CEST 2001
Subject: The Adapter pattern inplemented with filters(code from
distribution)
The code below from the XOTcl distribution is given below.
Suppose the class Adapter has another filter "filter2"
registered after the filter "adapterFilter".
My understanding of the code(below) is that only requests that
are not found in specificRequest will be filtered by
filter2.
.........................................................
Question:
If my understanding is correct, how can I have all
messages/requests to Adapter be filtered by both filters.
.........................................................
Code from distribution:
Class Adapter -superclass Class
Adapter metadata add description
Adapter metadata description {
Simple adapter pattern meta-class taken from the paper
'Filters as a Language Support for Design Patterns in
Object-Oriented Scripting Languages'.
}
Adapter instproc adapterFilter args {
# Appears that filter args == args of triggering method
set r [self calledproc]
[self] instvar specificRequest adaptee
#puts [self]
if {[info exists specificRequest($r)]} {
#puts $args
return [eval $adaptee $specificRequest($r) $args]
}
next
}
Adapter instproc init args {
[self] filterappend [self class]::adapterFilter
next
[self] instproc setRequest {r sr} {
[self] set specificRequest($r) $sr
}
[self] instproc setAdaptee {a} {
[self] set adaptee $a
}
}
More information about the Xotcl
mailing list