AspectJ Demo
1. Installing the Demo
- Extract the contents of "aspectj-demo.zip" to
"C:\aspectj-demo", resulting in the following directory structure:
- Verify that JBuilder 4 is using the correct project by opening it, closing
all of the current projects
- Under the "File" menu select "Close Projects...",
select all of the open projects and close them
- Under the "File" menu select "Open Project...",
and open "C:\aspectj-demo\examples\jbuilder\Spacewar.jpr"
- You should now be able to compile "Spacewar". If
ajdeForJBuilder reports any problems refer to
"C:\aspectj-demo\apps\aspectj0.8\doc\primer\tools\ajdeForJBuilder.html"
- Set up your "Windows Taskbar" to be permanently visible by
right-clicking the bar, selecting "Properties", and un-checking
"Auto hide"
- From your "Windows Explorer" drag the
"C:\aspectj-demo\bin\Demo" folder to the "Windows
Taskbar". This will have the effect of placing the demo buttons
on the taskbar. To remove the buttons drag off the "Demo"
toolbar and close the resulting floating toolbar window.
- It is useful to have the "Task Manager" running in the
"System Tray" during the demo in order to see when the debugger is
loading since it is slow. To launch it right-click the "Windows
Taskbar" and select "Task Manager", then minimize the window.
2. Initial Setup
- Emacs Setup
- Click "Emacs", and move the cursor to the beginning of the
"spacewar.Ship.fire" method
- JBuilder Setup
- Click "JBuilder", open the "AspectJ Structure
View", and bring the editor to the "spacewar.Ship.fire"
method
- under the "Spacewar.jpr" node in the "Project
Explorer" (left pane of main window) expand the "spacewar"
package to see its classes
- ensure that the last compile was done without "Debug.java"
in the build configuration
- Forte Setup
- Click "Forte", click the "AspectJ Structure View"
button, and navigate the editor to the "spacewar.EnsureShipIsAlive"
class
- AJDoc Setup
- click "AJDoc", browse to the "spacewar/Ship.java"
class
3. Running the Demo
- Emacs
- At the declaration of the "spacewar.Ship.fire" method hit
"<cntrl>x, <cntrl>j"
- Follow the resulting popup menu to the "EnsureShipIsAlive"
advice
- Navigate back to "spacewar.Ship.fire" using the same method
- JBuilder
- Navigation
- In the "Structure View" select the "fire"
method and expand it's children to reveal "EnsureShipIsAlive:
around..."
- Double-click "EnsureShipIsAlive: around..." to navigate
to that advice declaration
- Navigate back using the same method, or using the
"Back", then "Forward" method in conjuntion with
the structure tree (this navigation can also be done by
right-clicking the inline advice icons in the editor's gutter)
- Compilation
- In "EnsureShipIsAlive" remove "ship" from the
"proceed(ship)" call and recompile.
- When the error message pops up fix it by replacing
"ship"
- Build Configuration
- Double-click "Default.lst" and select the "lst
Designer" tab at the bottom of the editor pane
- Expand the "spacewar" node
- Click "Debug.java" in order to add it to the
configuration
- Navigate to the "Ship.java" class so that the effects of
the new compilation are visible in the "Structure View"
when the compilation completes
- Compile "Default.lst"
- Run the project (top the execution of the project by clicking the
red stop button in the run messages pane)
- Debugging
- Start the debugger
- When the "Please select launch parameters..." dialog
pops up click "OK"
- Select the "Classes" tab (4th tab from the top)
- When the game starts, expand "spacewar", expand "Ship.java"
- Browse to the "fire" method and expand it
- Right-click on the "fire" method and select "stop
in spaceawar.Ship.fire"
- Wait for the breakpoint to be hit
- Use the "Step Into" button (5th button on the bottom
from the left) to single step the file until you step through the
advice and into the body of the fire method
- Click the red stop button (1st button) in order to stop the
debugging
- Forte
- Currently no Forte demo (fyi: navigate the structure the same way as
in JBuilder, and right-click the LST files to compile them, right click
"Game.java" to execute it)
- AJDoc
- Scroll down to the "fire" method, and follow it's
"Advised by: " link to get to the "EnsureShipIsAlive"
aspect