Women in Technology

Hear us Roar



Article:
  Peeking Inside the Box: Attribute-Oriented Programming with Java 1.5, Part 1
Subject:   How about AOP
Date:   2004-07-29 18:43:38
From:   schwardo
Response to: How about AOP

Absolutely. Aspect-Oriented Programming and Attribute-Oriented Programming are certainly closely related, and often complimentary, technologies. The fundamental difference is that Aspects focus on relocating code that cuts across multiple classes into a single location. That's certainly what I've done in this article.


If your question was why did I use bytecode instrumentation versus a framework like AspectJ, then the answer is simple. Under the covers, almost all AOP frameworks use either source-code or bytecode instrumentation to "weave" the aspects through the code. In this article I wanted to dig a bit deeper and expose how some of that works, and demonstrate that although slightly complex, it's definitely an approachable subject.


As mentioned in another comment, using CGLIB instead of BCEL would've simplified my examples considerably, because of CGLIB's built-in support for wrapping methods (like AspectJ's "around advice"). But again, I wanted to focus on the lowest level of details so you can see how something like this would work without direct JVM support for AOP.