Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Is there a direct way to get the variable name of a pointcut matched

Hi,

I'm trying to catch methods of a certain Class type to mock them later on. I
achieved nicely to catch all method calls of a certain Type like eg User
with all the static information looking with 
<code>
		pointcut methodWithReturnValue() : (execution(!void
*.*(..))&&(!within(org.automock.tools.*)) &&(!within(junit.*))); 

			     after() returning(Object returnedObject) : methodWithReturnValue() { 
</code>

 

But I would also need to know the variable name. Eg if there were two User
objects like User admin and User guest, there should be two mocks dedicated
to the  these to control their exact behaviour. 

I found the Interface SourceLocation offering getLine and getFileName that
can be reached with thisJoinPointStaticPart.getSourceLocation(). So I could
open the file, read the line and parse the variable name out of it.

However, there are so many nice nested goodies and tricks in AspectJ that I,
being a newbie, dare to ask if there is a method or construction for this
already available before I make the detour and write it on my own.

Thanks for help
-- 
View this message in context: http://www.nabble.com/Is-there-a-direct-way-to-get-the-variable-name-of-a-pointcut-matched-tp22138618p22138618.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top