O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

ProxyFactoryBean in action

We will define a regular Spring bean as target bean, say TransferService, and then, using ProxyFactoryBean, we will create a proxy that will be accessed by our application. To advice the transfer method of TransferService, we will set the point expression using AspectJExpressionPointcut and we will create the interceptor, which we will set into DefaultPointcutAdvisor to create the advisor. 

The target object or bean is as follows:

public class TransferServiceImpl implements TransferService {  private static final Logger LOGGER =       Logger.getLogger(TransferServiceImpl.class);  @Override  public boolean transfer(Account source, Account dest, Double amount) {    // transfer amount from source account to dest account LOGGER.info("Transferring ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required