Part 10 · Fundamentals

AOP proxies: why annotations sometimes vanish

Prerequisites: 01-ecosystem

Which call crosses the proxy boundary?

Caller: managed reference; Proxy: transaction / other advice; Target issue(): business operation; Target audit(): self-invocation. Connections: Caller to Proxy (external call); Proxy to Target issue() (intercepted); Target issue() to Target audit() (this.audit() bypasses proxy)
Default Spring AOP proxy mode. A self-call does not return to the proxy; weaving can behave differently. [S19] [S30]

How can an advised audit boundary become explicit?

QuoteService: issues policy; AuditService proxy: independent advice; Audit target: audit operation. Connections: QuoteService to AuditService proxy (injected collaborator); AuditService proxy to Audit target (proxy interception)
Proposed refactoring: call another managed collaborator. Select transaction propagation intentionally; separate beans alone do not select it. [S19] [S30]

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]
Keep this: An annotation is metadata; the invocation path makes it operational.
Check yourself: Will this.audit() start a proxy-driven new transaction?

Not in default proxy mode. The call stays within the target.

Sources & further reading

  1. [S19] Spring AOP proxies

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Proxy interception; Self-invocation bypass; Subclass limitations

    Read the linked section to validate the mechanism and its version-specific constraints.

  2. [S30] Declarative transactions

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Proxy entry required; Rollback defaults; Global rollback customization

    Read the linked section to validate the mechanism and its version-specific constraints.