title: How exactly does an @Around advice work in Spring AOP?
body: <p>I am studying <strong>Spring AOP</strong> module and I have some doubts about how exactly works the <strong>AROUND</strong> advice.</p>
  
  <p>Reading the official documentation: <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html" rel="noreferrer">http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html</a></p>
  
  <p>I can read this about the <strong>AROUND ADVICE</strong>:</p>
  
  <blockquote>
    <p>Around advice: Advice that surrounds a join point such as a method
    invocation. This is the most powerful kind of advice. Around advice
    can perform custom behavior before and after the method invocation. It
    is also responsible for choosing whether to proceed to the join point
    or to shortcut the advised method execution by returning its own
    return value or throwing an exception.</p>
  </blockquote>
  
  <p>And this is the sequence diagram of the around advice:</p>
  
  <p><img src="https://i.stack.imgur.com/iYcR9.jpg" alt="enter image description here"></p>
  
  <p>So from what I can understand I can define an advice (my custom behavior) that will perform before and after a <strong>joint point</strong> specified by a <strong>pointcut</strong>.</p>
  
  <p>So for example I can define an <strong>AROUND ADVICE</strong> in this way:</p>
  
  <pre><code>@Around(“execution(@example.Cacheable * rewards.service..*.*(..))”)
  public Object cache(ProceedingJoinPoint point) throws Throwable {
      Object value = cacheStore.get(cacheKey(point));
  
      if (value == null) {
          value = point.proceed();
          cacheStore.put(cacheKey(point), value);
      }
      return value;
  }
  </code></pre>
  
  <p>that perform the implemented chaching behavior before and after that a service method is call. Is it right?</p>
  
  <p>The thing that I can't completly understand is how exactly is and how is it used the <strong>ProceedingJoinPoint point</strong> parameter.</p>
  
  <p>From what I understand it is used to choose if perform or not perform a specific operation but how exactly works?</p>
  
  <p>Another doubt related how correctly use AOP advice is how to respond to the following question:</p>
  
  <blockquote>
    <p>Which advice do I have to use if I would like to try and catch
    exceptions?</p>
  </blockquote>
  
  <p>I think that in this case the answer is to use the <strong>After throwing advice</strong> because the advice executes when a matched method execution exits by throwing an exception.</p>
  
  <p>But I am not sure about it because from what I understand the advice is executed <strong>only if a method throws an exception</strong>. Or maybe in this case I have to use the **AROUND ADVICE* ?</p>
  
  <p>Tnx</p>