The first proxy will just advise the target by using the advice directly; thus, all methods will be advised. For the second proxy, we will configure AspectJExpressionPointcut and DefaultPointcutAdvisor so that only the foo() method of the MyDependency class is advised. To test the advice, we will create two bean definitions of type MyBean, each of which will be injected with a different proxy. Then we will invoke the execute() method on each of these beans and observe what happens when the advised methods on the dependency are invoked.

Listing 5-57 shows the configuration for this example (app-context-xml.xml).

Listing 5-57. Declarative AOP Configuration

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans ...

Get Pro Spring,Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.