I want my AOP!, Part 2

Learn AspectJ to better understand aspect-oriented programming

1 2 3 Page 3
Page 3 of 3
  • You can declare one aspect as dominant over others to control precedence when multiple aspects affect a certain pointcut.
  • By default, Aspect J associates aspects with other classes and aspects, and therefore all aspectee instances share the aspect's state. Beyond the default association type, AspectJ offers additional types: perthis, pertarget, percflow, and percflowbelow. Each associates a separate aspect instance with a self object, target object, control flow, and control flow excluding the pointcut, respectively.
  • You can mark an aspect privileged, which gives it access to the private members of aspected classes.
  • AspectJ also lets you introduce compile-time crosscutting behavior by allowing compile-time warnings and errors (similar to, but more powerful than, #error and #warning preprocessor directives supported by some C/C++ compilers).

AspectJ in all its glory

AspectJ provides a powerful and useful AOP implementation for Java. AspectJ offers modularizing crosscutting concerns by adding new joinpoint, pointcut, and advice concepts. Since AspectJ extends Java, Java programmers will find it an easy language to learn. The byte code produced by the AspectJ compiler is standard Java byte code, therefore it keeps Java's advantages.

AspectJ could evolve into a far more powerful language and implementation. As more people use it, the experience gained should guide changes to the language specification and implementation.

In Part 3, I will demonstrate AspectJ's power via several examples. Those examples, taken from various domains, will also show how AspectJ/AOP offers an elegant solution to otherwise complex problems.

Ramnivas Laddad is a Sun Certified Architect of Java Technology. He holds a master's degree in electrical engineering with a specialization in communication engineering. He has been architecting, designing, and developing software projects involving GUIs, networking, distributed systems, realtime systems, and modeling for more than eight years. Ramnivas began working with object-oriented Java systems five years ago. As a principal software engineer at Real-Time Innovations, Inc., Ramnivas leads the development of the next generation of ControlShell, a component-based programming framework for building complex real-time systems.

Learn more about this topic

Related:
1 2 3 Page 3
Page 3 of 3