Skip to main content

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

Title: Message
Change args(sql) to args(sql, ..) and you should be good to go, assuming that a String is always the 1st parameter.
 
Ron DiFrango
-----Original Message-----
From: Seaman, Sloan [mailto:Sloan.Seaman@xxxxxxxxxxx]
Sent: Friday, September 03, 2004 1:17 PM
To: 'aspectj-users@xxxxxxxxxxx'
Subject: [aspectj-users] 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


************************************************************************** The information transmitted herewith is sensitive information intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.


Back to the top