2 kinds of PointcutExpressions

What would be the right way to convert a org.aspectj.lang.reflect.PointcutExpression to a org.aspectj.weaver.tools.PointcutExpression for checking, if a method is matching?

Setting: I got reflect.Advice methods and extract the corresponding PointcutExpressions out of them. Then I want to check, if a specific method (reflect.Method) matches that call.

My first idea was to use a PointcutExpressionParser like this:

pointcutExpressionParser.parsePointcutExpression(reflectPointcutExpression.asString());

But this doesn’t work well, because the asString() method only gives the method declaration that should be matched, but not the aspectj patterns (call, execution, set etc.)..

Has anyone a good idea how to do it?

Answer

I found the cause for the Problem.

Advice.getPointcutExpression() outputs either the real Pointcut as String (if it is written into the Advice directly) or the Signature of the Pointcut declared in the Aspect. The declared pointcuts can be accessed with AJType.getDeclaredPointcuts()

Leave a Reply

Your email address will not be published. Required fields are marked *