AspectJ Development Environment support for NetBeans
This documents the AspectJ Development Environment
(AJDE) module extension to the
NetBeans and
Forte for Java /SunOne
integrated development environments (IDE's) to support aspect-oriented programming
using AspectJ.
A great article on
Aspect-Oriented
Programming with Sun(tm)ONE Studio by Vaughn Spurlin is also available.
Overview
AJDE for NetBeans enables you to:
- compile AspectJ and Java files within the IDE
- browse the structure of your AspectJ program
- set up a compile configuration that determine
which files will be passed to the compiler
Installation
-
Unzip the distribution zip file into a temporary directory,
and copy the jars from the modules and lib directories into your
NetBeans installation (i.e., the module jar into the modules directory
and the AspectJ jars into the lib/ext directory).
- The distribution will also contain
the two html files "LICENCE-AspectJForNetBeans.html" and
"README-AspectJForNetBeans.html",
along with this file in the docs directory.
- Start up NetBeans, and in the "Tools" menu select
"Global Options"
- If necessary,
right-click the "Modules" item and select "New
Module from File...". Find the module jar file in the directory that
you installed into (e.g. c:/NetBeans4j/modules) and select it.
To uninstall follow NetBeans's documentation on un-installing modules, or
simply remove the file modules/aspectjForNetbeans.jar from NetBeans's
install directory.
Running AJDE for NetBeans
3.1 Setting up the AspectJ Examples
- You will need to download the AspectJ distribution (which contains the
examples in the docs directory) from
http://eclipse.org/aspectj
(or use your current version of the examples).
- In the "Project" menu select "Project Manager"
- Click "New..." and enter "AspectJ Examples" as
the projects' name and click "OK".
- In the "Filesystems" Explorer tab right click
"Filesystems", then select "Mount -> Local Directory".
- Browse into the AspectJ install directory (e.g.
"C:/apps/aspectj1.0")
- Select "examples" and click "Finish"
- In the "Tools" menu select "AspectJ -> Start
AJDE" or just click on the "AJDE"
()
button (shown as label 1 of the screenshot).
3.2 Compiling the Spacewar Example
- After AJDE is started, a new "AspectJ" tab is
added to the explorer window. Click it. The next thing to do is to
choose a particular build, since there are many in the examples
distribution. To the right of the "Build" button ()
there is a downward arrow. Click it, and select "spacewar/demo.lst" (as
in label 2 of the screenshot). This will start a build of the demo
configuration of spacewar. Clicking the "Build" button will rebuild.
- When the compile is finished and the "AspectJ
Explorer" structure is present navigate the structure by clicking nodes
(as shown in label 3 of the screenshot). Note that associations between
nodes appear with UML-style arrow icons and italicized names and
reperesent how a particular node in the structure relates to others. In
order to navigate these associations expand the notes and click the
corresponding links (in blue). These links represent structure nodes
elsewhere in the tree.
- If there are compilation errors, clickable
messages will appear (as in label 4 of the screenshot).
3.3 Running the Spacewar Example
- You may now need to add the AspectJ Runtime to
the project so that the debugger can see it. In the same way as
described in 3.1 select "Mount -> Archive (JAR, Zip)".
- Browse to the your lib/ext/aspectjrt.jar file
within your NetBeans install directory and click "Finish".
- In the "Filesystems" Explorer tab open the
"spacewar" directory, right click "spacewar/Game.java", and the select
"Execute".
- When finished executing switch back to the
"Editing" mode.
- Select and build the "debug.lst" configuration
as described in 3.2 and execute again--you will notice that the debug
configuration adds a debug window used for tracing by including the
"Debug.java" aspect in the compile.
3.4 Debugging the Spacewar Example
- You must first add the filesystem to the
project so that the debugger can see the main class. Do this in the
"Project AspectJ Examples" tab in the explorer by right clicking the
root node and selecting "Add Existing...".
- Select "Project -> Set Project Main Class..."
in the menu bar, browse to "spacewar/Game.java" in the examples
directory that you created and click "OK".
- In the "Filesystems" Explorer tab open the
"spacewar" directory, click "Game.java", and the select "Debug -> Strat"
from the menu bar.
AspectJ-related options can be modified in the AJDE settings window.