Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Dynamic crosscutting weaving rules consist of two parts: advice (what to do) and pointcuts (when to apply the advice). AspectJ supports dynamic crosscutting through advice—a method-like construct that defines crosscutting action at the join points selected by a pointcut. We'll begin with discussing three kinds of advice followed by the general anatomy of advice.
If you're implementing a security check, you want that check to take place before executing the join point. On the other hand, if you're implementing exception logging, you want to log after executing the join point and only if it threw an exception. If you're implementing caching, you want to surround the original code with the caching logic: obtain a value from the cache, execute the original code if the cache doesn't contain a value, and add the value to the cache after executing the original code. To take care of all these scenarios, AspectJ offers three kinds of advice: