Monday, March 30, 2009

AspectJ Development Tools - Inline aspect visualization inside Eclipse

As I wrote about using AspectJ for serviceability instrumentation, I thought I would also spend some time publishing a couple of screenshots of a great addition to your Eclipse environment.

It is called AspectJ Development Tools, or AJDT, for short. AJDT adds a perspective and a handful of views that make it easy to visualize how the aspects are cross-cutting your code base.


Your first step is to visit the AJDT web site, go to the "Downloads" page and determine the right level of AJDT for your Eclipse environment. For those using any of the Rational Software Development v7.0 siblings, such as Rational Software Architect, you are looking into the 3.2 version.

The installation of the plugin follows the standard Eclipse "Help->Software Updates->Find and Install..." sequence, where you will be able to register the Eclipse update side for AJDT.

Converting a Java project into an AspectJ project

You will need to convert Java projects into AspectJ projects before you can use Eclipse to apply aspects to your Java code. The "conversion" is fairly benign and reversible, adding a couple of facets to the ".project" file.

An "AspectJ" sub-menu will be displayed whenever you right-click any Java project, with a single and unmistakable option named "Convert to AspectJ Project". After the conversion, other options become available, including the action to undo the conversion.

Aspect visualization embedded into Java code

The AJDT extensions will show markers to the left of Java source code,with the icons indicating the type of join point, such as "around", "before" and "after". Note that you can also display the "Cross References" view of the advices being applied to a particular point in the code.

Click on the thumbnail to see a larger image

Simultaneous Aspect visualization for multiple files

Using the Aspect Visualization perspective, you can have a broader view into how the aspects are crosscutting your projects.
Note how the screen is logically divided in three parts, with the package selection on the left, a graphical representation of the advices for each class in the middle section, and a selector for the aspects you want to browse.

What I like the best is that all screen elements are fully navigable, with double-clicks to the classes or advices in the graphical display taking you to their respective location in the Java source code.

Click on the thumbnail to see a larger image

No comments:

Post a Comment