Matthew Groves

Greenhorn
+ Follow
since Jul 21, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matthew Groves

I'm not a Java developer, but I know something about AOP in .NET, and it's probably very similar, so I chime in hesitantly:

The design patterns that are used internally vary among implementations. If you're using a runtime interception framework (maybe Spring in Java?), then types are generated at runtime with reflection. These types are decorator classes that follow the decorator pattern. You could consider AOP to basically be dynamic decorators (a bit over-simplified, but it's a good place to start).

The other main type of AOP implementation is compile-time, which manipulates byte code during/after you've compiled your program (I think AspectJ does this in Java). I can't tell you offhand exactly what AspectJ changes, but if you use a decompiler, you might be able to get an idea (again, I'm a .NET guy, so this may or may not exactly translate to Java). In the .NET world, these compile-time tools don't necessarily use a pattern like decorator--they just manipulate/enhance the code using the aspects. But as you're writing code, it definitely appears very much like the decorator pattern.

I'm sure there are other patterns used internally that aren't strictly relevant to AOP (e.g. maybe an AOP tool uses singletons, an abstract factory, etc, but that will be true of many libraries, not just AOP libraries).