[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Multiple Parameters
|
Title: Multiple Parameters
I'm new to AspectJ and am having some trouble setting up my first aspect.
I want to be able to record all the SQL statements that get executed by my JDBC drivers.
I've set up an aspect like so:
public aspect StatementAspect {
pointcut executeSql(String sql):
(
call (public PreparedStatement Connection.prepareStatement(..)) ||
call (public boolean Statement.execute(..)) ||
call (public ResultSet Statement.executeQuery(..)) ||
call (public int Statement.executeUpdate(..)) ||
call (public void Statement.addBatch(..))
) &&
args(sql);
before(String sql): executeSql(sql) {
System.out.println("Entering: "+thisJoinPoint);
}
after(String sql): executeSql(sql) {
recordSqlStmt(sql);
}
private void recordSqlStmt(String sql) {
System.out.println("SQL call:"+sql);
}
}
This works fine for any methods that only take (String sql) as their arguments. But how do I handle methods that take N number of arguments like Connection.prepareStatement(String sql, int[] columnIndexes, int resultSetConcurrency) and
Statement.executeUpdate(String sql, int autoGeneratedKeys)?
--
Sloan