Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke proxy AOP by calling method within the bean

lets say the I have got a bean called with two methods 'foo' and 'goo' and 'goo' is marked with AOP interception call.
is it possible to write any piece of code inside 'foo' in order to invoke 'goo' method not directly but through the proxy wrapper of the bean in order to activate the AOP part of it?

public Class Pojo{

  public void foo(){
    //what should I write here in order to activate 'goo' in transactional mode??
  }

  @Transactional
  public void goo(){
  }
}
like image 847
Spiderman Avatar asked Mar 21 '26 10:03

Spiderman


1 Answers

Yes, but you need to access it through the spring proxy:

public Class Pojo{

  @Autowired
  private Pojo springProxy;

  public void foo(){
    springProxy.goo();
  }

  @Transactional
  public void goo(){
  }
}
like image 166
Thierry-Dimitri Roy Avatar answered Mar 22 '26 23:03

Thierry-Dimitri Roy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!