// test is modified implementation
System.out.println("Has been modified?: " + mod.isModified());
bean.setName("Clarence Ho");
System.out.println("Has been modified?: " + mod.isModified());
bean.setName("Rob Harrop");
System.out.println("Has been modified?: " + mod.isModified());
}
}
Running this example yields exactly the same output as the previous introduction example, but this
time the proxy is obtained from the ApplicationContext and no configuration is present in the
application code.
ProxyFactoryBean Summary
When you use ProxyFactoryBean, you can configure AOP proxies that provide all the flexibility of the
programmatic method without needing to couple your application to the AOP configuration. Unless you
need to perform decisions at runtime as to how your proxies should be created, it is best to use the
declarative method of proxy configuration over the programmatic method. Let's move on to see the
other two options for declarative Spring AOP, which are both preferred options for applications based on
Spring 2.0 or newer with JDK 5 or newer.
Using the aop Namespace
The aop namespace provides a greatly simplified syntax for declarative Spring AOP configurations. To
show you how it works, let's reuse the previous example on using ProxyFactoryBean, with a slightly
modified version in order to demonstrate its usage.
Listings 7-18 and 7-19 show the MyDependency and MyBean class, with some modifications.
Listing 7-18. The MyDependency Class
package com.apress.prospring3.ch7.aopns;
public class MyDependency {
public void foo(int intValue) {
System.out.println("foo(int): " + intValue);
}
public void bar() {
System.out.println("bar()");
}
}
Listing 7-19. The MyBean Class
package com.apress.prospring3.ch7.aopns;
public class MyBean {
private MyDependency dep;
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home