|
Mon
28
Nov '05
|
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.
- Help->Software Updates->Find and Install…
- “Search for new features to install” and “Next”
- “New Remote Site…”
- “New Update Site” with any name (e.g. “AJDT Update Site”) and “http://download.eclipse.org/technology/ajdt/30/update”
- select AspectJ and later Eclipse AspectJ Development Tools
- accept License Agreement
Step 2: create Test files
This example was taken from “AspectJ in Practice: Reap the Benefits of Modularity”.
- New Project
- AspectJ Projekt
- Finish
- “New->Class”
create a new class called TestClass - “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