AOP proxies: why annotations sometimes vanish
Prerequisites: 01-ecosystem
Which call crosses the proxy boundary?
How can an advised audit boundary become explicit?
Goal & mental model verified
Spring AOP commonly intercepts calls through a proxy before reaching the target. JDK interface proxies and subclass proxies have different constraints. A target calling itself does not re-enter its Spring AOP proxy.
[S19] [S30]Worked example · design exercise synthesis
A controller invokes quoteService.issue(): transaction advice runs. Inside the target, this.audit() bypasses proxy interception, even if audit has an advice-triggering annotation.
[S19] [S30]Engineering decision synthesis
Place independently advised operations on separate collaborators or use an explicit programmatic boundary. This adds a visible interface but avoids magical assumptions about annotation placement.
[S19] [S30]Pitfall & diagnosis synthesis
Subclass proxies cannot advise final/private methods as overridable methods. Calling a manually constructed object also bypasses container advice. AspectJ weaving is a different mechanism.
[S19] [S30]Improve & validate synthesis
Test behavior through the managed bean and deliberately exercise self-invocation. Inspect actual proxy type and advice ordering when multiple concerns wrap one method.
[S19] [S30]Check yourself: Will this.audit() start a proxy-driven new transaction?
Not in default proxy mode. The call stays within the target.