concept functionality in category aspectj

appears as: functionality, functionality, functionalities
AspectJ in Action, Second Edition

This is an excerpt from Manning's book AspectJ in Action, Second Edition.

AOP works in harmony with one of the most popular trends of agile programming by supporting the practice of “You aren’t gonna need it” (YAGNI). Implementing a feature just because you may need it in the future often results in wasted effort because you won’t actually need it. With AOP, you can practice YAGNI; and if you do need a particular kind of functionality later, you can implement it without having to make system-wide modifications. Even for the feature that you need, agile programming promotes developing them progressively. AOP helps you add features incrementally through the introduction of aspects, often without modifying the rest of the code.

The wormhole pattern removes the need to modify multiple modules for passing the caller’s context. With the caller context available at the callee’s join point execution, you can easily implement functionalities that require both contexts.

The core concept in the participant pattern is explicit participation by the participants (classes, typically). With the growing popularity of language support for metadata, there is a variation of the classical participant pattern: the annotation-driven participant pattern (ADPP). The key to annotation-driven participation is changing how the participants show interest in the functionality offered by an aspect. Whereas the classical version of the pattern uses a pointcut, the ADPP uses one or more annotation types and expects the participants to attach the annotations to appropriate elements. Figure 12.3 shows the general arrangement implemented in ADPP.

Figure 12.3. The annotation-driven participant pattern uses an aspect that expects program elements to carry certain annotations. The classes participate in the functionality offered by marking program elements with the expected annotation.

In listing 12.15, the nested subaspect declares that the Analytics.monteCarloSimulation() and Analytics.updateDatabase() methods have the desired characteristics to participate in the functionality offered by the base aspect. The effect of this aspect is that the advice to slowOperation() in the base aspect is applied to the specified methods. Document in listing 12.15 participates in the collaboration in the same way.

Listing 12.15. Document.java: participating in the collaboration
package ajia.example; import ... public class Document { // Document's implementation private static aspect WaitCursorManagementParticipant extends AbstractWaitCursorManagementAspect { public pointcut slowOperation() : execution(* Document.save()) || execution(* Document.backupSave()); } }

There can be many more participants in addition to Analytics and Document. Each of the participating nested subaspects provide a definition to select the join points in their enclosing class, thus applying the functionality of the base aspect to those join points. Note that it’s perfectly legitimate for a subaspect to use a naming pattern or other signature components to define the pointcut instead of enumerating the methods. Figure 12.2 depicts the structure.