concept join point in category aspectj

This is an excerpt from Manning's book AspectJ in Action, Second Edition.
Identifiable points in the execution of the system— The system exposes points during the execution of the system. These may include execution of methods, creation of objects, or throwing of exceptions. Such identifiable points in the system are called join points. Note that join points are present in all systems—even those that don’t use AOP—because they’re points during execution of a system. AOP merely identifies and categorizes these points. A construct for selecting join points— Implementing a crosscutting concern requires selecting a specific set of join points. For example, the tracing aspect discussed earlier needs to select only the public methods in the system. The pointcut construct selects any join point that satisfies the criteria. This is similar to an SQL query selecting rows in database (we’ll compare AOP with databases in section 1.5.2). A pointcut may use another pointcut to form a complex selection. Pointcuts also collect context at the selected points. For example, a pointcut may collect method arguments as context. The concept of join points and the pointcut construct together form an AOP system’s join point model. We’ll study AspectJ’s join point model in chapter 3. A construct to alter program behavior— After a pointcut selects join points, you must augment those join points with additional or alternative behavior. The advice construct in AOP provides a facility to do so. An advice adds behavior before, after, or around the selected join points. Before advice executes before the join point, whereas after advice executes after it. Around advice surrounds the join point execution and may execute it zero or more times. Advice is a form of dynamic crosscutting because it affects the execution of the system. We’ll study AspectJ’s dynamic crosscutting implementation in chapter 4.
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:
Before advice executes prior to the join point’s execution. After advice executes following the join point’s execution. After advice has three variations based on the outcome of the join point execution:
- After (finally) executes after execution of the join point, regardless of the outcome.
- After returning executes after successful execution of the join point—that is, without throwing an exception.
- After throwing executes after failed execution of the join point—that is, throwing an exception.
Around advice surrounds the join point’s execution. This advice is special in that it has the ability to continue the original execution with the same or altered context, zero or more times. Join points exposed by AspectJ are the only points where you can apply advice. Figure 4.1 shows various join points in an execution sequence at which you can introduce a new behavior via advice.
Listing 12.4. Aspect to route join points asynchronously
package ajia.example; import ... public aspect AsynchronousExecutionAspect { private Executor executor = Executors.newCachedThreadPool(); public pointcut asyncOperation() : execution(* CachePreFetcher.fetch()) || execution(* ProjectSaver.backupSave()) /* || ... */; void around() : asyncOperation() { Runnable worker = new Runnable() { public void run() { proceed(); } }; executor.execute(worker); } }