Spring AOP won't help, as it only understands the execution() pointcut.
AspectJ includes a lot more pointcuts, including the withincode() construct, which sounds like what you want:
withincode(* YourClass.methodX(. .))
this lets you advise all join points inside a given method exection
Read AspectJ in Action for more info, it's a very good book about both AspectJ and Spring AOP.
EDIT:
here is some sample code:
package com.dummy.aspectj;
import java.util.Arrays;
import java.util.Collections;
public class DummyClass{
public static void main(final String[] args){
System.out.println(Arrays.asList("One", Collections.singleton("Two")));
System.out.println("Enough?");
}
}
package com.dummy.aspectj;
import java.util.Arrays;
public aspect DummyAspect{
pointcut callWithinMain() :
withincode(* com.dummy.aspectj.DummyClass.main(..)) // anything inside DummyClass.main
&& call(* *.*(..)); // but only method calls
before() : callWithinMain() {
System.out.println("\n***************************************************");
System.out.println("** Calling:\n**\t"
+ thisJoinPointStaticPart.getSignature()
+ "\n** with arguments:\n**\t "
+ Arrays.deepToString(thisJoinPoint.getArgs()) );
System.out.println("***************************************************\n");
}
}
running the DummyClass from Eclipse / AJDT generates this output:
***************************************************
** Calling:
** Set java.util.Collections.singleton(Object)
** with arguments:
** [Two]
***************************************************
***************************************************
** Calling:
** List java.util.Arrays.asList(Object[])
** with arguments:
** [[One, [Two]]]
***************************************************
***************************************************
** Calling:
** void java.io.PrintStream.println(Object)
** with arguments:
** [[One, [Two]]]
***************************************************
[One, [Two]]
***************************************************
** Calling:
** void java.io.PrintStream.println(String)
** with arguments:
** [Enough?]
***************************************************
Enough?