Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Regular expressions in pointcut expressions



Wes Isberg wrote:
Hi -


@Pre ("n != null")
public void setName (String n) { this.name = n; }

...

So, I would like to write aspects that find these occurrances of DbC tests and their corresponding methods or fields and only advise the


Would using the AspectJ 5 support for annotations in pointcuts work for you?

Wes

Wes,

Support for annotations does help. In fact, the best solution, given the current features in AJ5, is to use annotations like the original "@Pre", etc. to scope the PCDs down to those classes, methods and fields for which tests are defined, thereby reducing overhead.

Note that even if I tried something like this:

@Pre
public void setName(String n) { this.name = n; }
@PreImpl
public boolean preSetName(String n) { return n != null; }

@Pre
public String doSomething() { ... }
@PreImpl
public boolean preDoSomething() { ... }

and wrote pointcuts to match, it would further reduce the scope to only the full set of fields and methods that are involved, but still not achieve the 1-1 matching between a method/field and its corresponding tests. (I could use reflection to finish the job, however...)

Also, I'm trying to minimize the coding effort for users of C4J. If I can minimize the use of avoidable annotations, etc., that's a plus.

Anyway, it was during various experiments that I realized how the regular-expression and "exists" ideas would be beneficial.

dean

--
Dean Wampler, Ph.D.
dean at aspectprogramming.com
http://www.aspectprogramming.com
http://www.contract4j.org
I want my tombstone to say:
   Unknown Application Error in Dean Wampler.exe.
   Application Terminated.
   [Okay]    [Cancel]


Back to the top