Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Multiple Parameters

As long as the first argument is the string, using 
	args(sql,..)
should do what you want.

On Fri, 3 Sep 2004 13:16:48 -0400
"Seaman, Sloan" <Sloan.Seaman@xxxxxxxxxxx> wrote:

> 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
> 
> 
> 


Back to the top