As a visual person, I like to weigh in with a sequence diagram of the proxy pattern. If you don't know how to read the arrows, I read the first one like this: Client
executes Proxy.method()
.
- The client calls a method on the target from his perspective, and is silently intercepted by the proxy
- If a before aspect is defined, the proxy will execute it
- Then, the actual method (target) is executed
- After-returning and after-throwing are optional aspects that are
executed after the method returns and/or if the method throws an
exception
- After that, the proxy executes the after aspect (if defined)
- Finally the proxy returns to the calling client
(I was allowed to post the photo on condition that I mentioned its origins. Author: Noel Vaes, website: www.noelvaes.eu)