Zeus
Zeus

Reputation: 6566

Spring AOP Pointcut with method name starting with get

I'm trying to implement a Pointcut for spring AOP. All the methods which are like getXXXX should be logged. I tried the following but either they throw exception or does not trigger:

1st try

@Pointcut("within(net.services.*.get*)")
private void clServiceLayer() {}

@Pointcut("within(net.services.*.get*(..))")
private void clServiceLayer() {}

Need help with the proper expression for point cut.

Upvotes: 5

Views: 8030

Answers (1)

Ali Dehghani
Ali Dehghani

Reputation: 48123

within limits matching to join points within certain types. Instead you should use execution Pointcut Designator for matching method execution join points:

@Pointcut("execution(* net.tds.adm.metasolv.customerlink.services.*.get*(..))")

Checkout the Spring Documentation for more detailed discussion.

Upvotes: 9

Related Questions