Search code examples
javaspringconstructorpointcut

Spring AspectJ point cuts


I am in need of writing a Single pointcut to intercept the constructor of all the classes. The actual need is to intercept all the beans where in no other methods apart from the init() and the constructor are invoked. For the init it is straight forward. But since the constructor name changes with the class name writing a single point cut is getting tough.

Any help would be appreciated...


Solution

  • A constructor in AspectJ syntax is represented by the "method name" new, i.e. if you want to capture all constructor executions the pointcut is

    execution(* *.new(..))