Mon
28
Nov '05
AspectJ in Eclipse in 5 minutes
by Frank Spychalski filed under articles

If you find this useful, you might like my other articles, too.

The idea behind AOP is kinda cool and I wanted to play around with AspectJ for some time but never tried because I didn’t know how to setup AspectJ for eclipse. If you feel the same, here’s a simple tutorial on how to setup AOP for Eclipse in 5 minutes.

Step 1:Install the AspectJ Development Tools in Eclipse

This is explained with more details on this page.

  1. Help->Software Updates->Find and Install…
  2. “Search for new features to install” and “Next”
  3. “New Remote Site…”
  4. “New Update Site” with any name (e.g. “AJDT Update Site”) and “http://download.eclipse.org/technology/ajdt/30/update”
  5. select AspectJ and later Eclipse AspectJ Development Tools
  6. accept License Agreement

Step 2: create Test files

This example was taken from “AspectJ in Practice: Reap the Benefits of Modularity”.

  1. New Project
  2. AspectJ Projekt
  3. Finish
  4. “New->Class”
    create a new class called TestClass

  5. “New->Other” “Aspect”
    create a new Aspect called TestMe

Step 3: Run application

Select TestClass->Run As->Java Application. The output should look like this

to turn this aspect off, open build.ajproperties and deselect TestMe.aj

Now start the application again and the output should look like this


Any comments? Or questions? Just leave a Reply: