|
Re: Applying Aspects in Practice
|
Posted: Mar 24, 2006 11:02 AM
|
|
I started learning aspectJ in order to make a nearly fully transparent dependency-injection tool (http://coinjema.sourceforge.net). By using aspects, my java objects are given configuration dependencies automatically when I call "new Object()". It also wires objects together and allows for shared dependencies (ie singletons that aren't actually singletons).
My experience with aspectJ indicates to me that aspects can be tricky and hard to get just right. Exactly how you implement your pointcuts can also have a large performance impact and there are many many ways to arrange your pointcuts to achieve the same effect. Also, although the documentation for aspectj is generally good, the nitpicky details of the differing semantics of the various pointcuts can cause confusion.
In creating a distribution of a jar file that offers very generic aspects intended to weave other's code, I've become aware of some potentially sticky issues with the potential proliferation of aspects in the world. Using one third-party library that uses aspects to weave your code is one thing. Using 10 such libraries, plus a few that already have weaved classes plus the possibility that you need to further weave them - well, I see the potential for nightmare city.
Also, the aspectj compiler has a few minor issues with java 5 generics. That said, I use it on a live webapp system and it has worked like a champ so far.
|
|