Call the AOP proxy by calling the method in the bean

lets say that I have a bean call with two methods: foo and goo, and "goo" is marked with an AOP hook call.
is it possible to write some piece of code inside 'foo' to call the goo method not directly, but through a bean proxy wrapper to activate part of AOP?

public Class Pojo{

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

  @Transactional
  public void goo(){
  }
}
+3
source share
2 answers

autwired. , , goo() ( ) foo().
, , , foo(), Pojo bean. mothd Sun invokation bean .
.

0

, spring:

public Class Pojo{

  @Autowired
  private Pojo springProxy;

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

  @Transactional
  public void goo(){
  }
}
+4

Source: https://habr.com/ru/post/1761585/


All Articles