AspectJ In Action

The source code is provided to ease compiling and running examples in the "AspectJ in Action" by Ramnivas Laddad. The sources files are structured to allow easy experimentation. Towards this goal, each section contains all the necessary files and modifying a file will not affect the remaining sections.

THE SOURCE CODE AND ACCOMPANYING FILES ARE PROVIDED WITHOUT ANY WARRANTY, WRITTEN OR IMPLIED.

Running the scripts

Each section contains a batch file (run.bat) and an Ant build file (build.xml) that will compile and run the example. Executing either form of the script requires you to modify the CLASSPATH and other environment variables as described in the next section.

Note that in certain cases, compilation is supposed to produce an error and therefore the script will not attempt to run the example. Further, certain sections contain multiple ways to compile and run the examples, in which case the batch file names or Ant targets are appropriated changed.

Obtaining and installing external tools and packages

Package and version
Tested version URL
Classpath components
JDK 1.4 1.4.1_01
http://java.sun.com/j2se -
(Include JAVA_HOME/bin into PATH)
AspectJ 1.1 1.1.0 http://www.eclipse.org/aspectj aspectjrt.jar and aspectjtools.jar
log4j 1.2 1.2
http://jakarta.apache.org/log4j log4j-1.2.jar
J2EE SDK 1.3 1.3.1
http://java.sun.com/j2ee Those set by bin\setenv.bat in J2EE_HOME
Doug Lea’s Concurrency library  1.3.2 http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html Obtain sources, compile it yourself, and put the resulting directory/jar file in classpath.
Jess 6.1 6.1p2 http://herzberg.ca.sandia.gov/jess/ jess.jar
Ant 1.5 1.5.1
http://ant.apache.org/
-
(Include ANT_HOME/bin into PATH)

Setting up the database table

Running the examples in chapter 7 and chapter 11 requires the use of a database. Here are general instruction to set up the example database for MySQL and MS Access. You should be able to use a similar process for other databases.

Chapter 7 setup

The examples in chapter 7 simply prints the content of a database table and as such you may use any new or existing database. The instructions here creates a table that match the one in the book

MySQL

    > mysqladmin create stock
    > mysql stock
mysql> create table price (symbol VARCHAR(8), price FLOAT);
mysql> insert into price VALUES ('SUNW', 5.0);
mysql> insert into price VALUES ('IBM', 85.0);
mysql> flush table price;
mysql> quit

Microsoft Access

SUNW 5.0
IBM 85.0

Chapter 11 setup

MySQL

    > mysqladmin create bank
    > mysql bank
mysql> create table accounts (accountNumber INTEGER, balance FLOAT);
mysql> insert into accounts VALUES (1, 0);
mysql> insert into accounts VALUES (2, 0);
mysql> insert into accounts VALUES (3, 0);
mysql> flush table accounts;
mysql> quit

Microsoft Access

1 0
2 0
3
0