@Cacheable self-invocation (in effect, a method within the target object calling another method of the target object).
The cache annotation will be ignored at runtime

μŠ€ν”„λ§ ν”„λ ˆμž„μ›Œν¬μ—μ„œ κ°œλ°œμžκ°€ κ²½ν—˜ν•˜κΈ° μ‰¬μš΄ μ‹€μˆ˜λŠ” λ™μΌν•œ 클래슀 λ‚΄μ—μ„œ 비동기 λ˜λŠ” μΊμ‹œ μ–΄λ…Έν…Œμ΄μ…˜μ΄ μ„ μ–Έλœ ν•¨μˆ˜λ₯Ό λ‚΄λΆ€μ μœΌλ‘œ ν˜ΈμΆœν•˜λ„λ‘ λΉ„μ¦ˆλ‹ˆμŠ€ λ‘œμ§μ„ μž‘μ„±ν•˜λŠ” 것 μž…λ‹ˆλ‹€. μ΄λŸ¬ν•œ λ¬Έμ œκ°€ λ°œμƒν•˜λŠ” κ²½μš°μ—λŠ” Self Invocation이 λ˜μ§€ μ•Šλ„λ‘ λ³„λ„μ˜ 클래슀둜 λΆ„λ¦¬λ˜λ„λ‘ λ¦¬νŒ©ν† λ§μ„ μ§„ν–‰ν•˜κ±°λ‚˜ Self-Injection이 λ˜λ„λ‘ μˆ˜μ •ν•΄μ•Όν•©λ‹ˆλ‹€. 그외에 μ•„λž˜μ™€ 같은 방법듀도 μžˆμ§€λ§Œ μ„ ν˜Έλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

@Service
public class AService extends AbstractService {
    @Cacheable(cacheNames = "a", key = "#root.methodName", unless = "#result == null")
    public String getA() {
        return "A";
    }

    public String getAA() {
        return ((AService) AopContext.currentProxy()).getA();
    }
}
  • AdviceMode.ASPECTJ (AspectJ Weaving)
  • AopContext.currentProxy()
  • ApplicationContext.getBean()

μŠ€ν”„λ§ ν”„λ ˆμž„μ›Œν¬ 기반의 μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ„œλ²„λ₯Ό μž‘μ„±ν•˜λŠ” 개발자라면 ν”„λ‘μ‹œ λ§€μ»€λ‹ˆμ¦˜μ— λŒ€ν•΄μ„œ μ΄ν•΄ν•˜κ³  μžˆμ–΄μ•Ό ν•©λ‹ˆλ‹€. 기본적인 ν”„λ‘μ‹œ(CGLib) λ˜λŠ” JDK ν”„λ‘μ‹œκ°€ 무엇인지 μ•Œκ³ μžˆμ–΄μ•Ό μ™œ public μ ‘κ·Όμ œμ–΄μžκ°€ μ•„λ‹ˆκ±°λ‚˜ λ‚΄λΆ€ 호좜인 경우 AOPλ₯Ό μˆ˜ν–‰ν•  수 μ—†λŠ”μ§€λ₯Ό 이해할 수 μžˆμŠ΅λ‹ˆλ‹€.