|
From: Rod J. <rod...@in...> - 2003-11-08 19:16:24
|
It seems to me that the concept of an Advice containing Pointcut and
Interceptor is sound and provides a necessary separation.
I also like the idea of a new "IntroductionAdvice".
The challenge is modelling the pointcut itself. Essentially this is a
challenge of modelling something that's basically an expression through an
object model. For example, the TopLink query object model vs HQL or JDOQL.
I think that pointcuts should be objects. So we need to think about how to
combine pointcuts via an object model.
My present thought is to have:
applies(Class) on all pointcuts
applies(Class, Method) additionally on MethodPointcuts
applies(Class, Method, args) additionally on DynamicMethodPointcuts
An inheritance hierarchy does seem a bit odd here; however, I do think that
a pointcut should be complete in itself, and I don't much like the idea of
separate "partial" class and method pointcuts.
Renaud's suggestion of Class and Method "designators" is more elegant
(especially as it would limit IntroductionAdvice to class designators) but
I'm concerned that involves one too many levels of object and isn't the
simplest thing that could possibly work.
A static facade would allow composition of pointcuts, as in:
class Pointcuts {
static Pointcut and(Pointcut a, Pointcut b);
...
}
This could be used to achieve the composition of class and method pointcuts
Bob suggested. E.g.:
Pointcut foo = new ClassPointcutSupport(Foo.class);
Pointcut setters = new MethodPointcutSupport("set*");
Pointcut somethingElse ...
Pointcut fooAndSetters = Pointcuts.and(foo, setters);
Pointcut allTogether = Pointcuts.and(fooAndSetters, somethingElse);
Regards,
Rod
|