Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] question regarding .class files protected by license w.r.t. AspectJ.....

To advise call join points only requires the code for the
caller, so this implementation of AspectJ should be able to
implement the join point picked out by your advice without
weaving the third-party library.  (And yes, using the
execution(..) pointcut designator would change that.)

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/limitations.html
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/faq.html#q:comparecallandexecution

And just to add a related comment on your pointcut,
it now advises any such calls from any code:

  call(ResultSet Statement.executeQuery(String))
  && target(stmt) && args(sql)

If instead you only mean to advise calls from your own
application, you can say that explicitly:

  call(ResultSet Statement.executeQuery(String))
  && within(com.company.app..*)
  && target(stmt) && args(sql)

Being explicit can avoid surprises when you compile the aspect
with more code or when you adopt a different implementation
of AspectJ (e.g., a load-time weaver with access to
all non-java classes in the system).

Wes

Garry Cronin wrote:

Hi All!

I'm new to AOP and AspectJ so this question is a little naive, nevertheless I think its important for me to ask it.

In the "Frequently Asked Questions about AspectJ" documentation, within Question "4 What about load-time weaving? Can I weave aspects at runtime? " it is stated:

"And just to state the obvious: do not use bytecode weaving, at load-time or otherwise, to modify .class files protected by license, without permission from the licensor."

Now, what I want to do is to capture all calls made to java.sql.Statement.executeQuery(String) from within our application code using the following pointcut/advice combination:

aspect JdbcLogger
{
pointcut bootstrapTwo(Statement stmt, String sql): call(ResultSet Statement.executeQuery(String)) && target(stmt) && args(sql);

  before (Statement stmt, String sql): bootstrapTwo(stmt, sql)
  {
System.out.println(); System.out.println("invoking: " + thisJoinPoint);
    System.out.println("argument: " + sql);
System.err.println("invoker : " + thisJoinPointStaticPart.getSourceLocation());
 }
}

The issue is that our application currently uses a commercially available, third-party JDBC driver to access the RDBMS. Here are my questions:

Using the above aspect, which code gets weaved? It is the application code that invokes Statement.executeQuery() or is it the third-party driver class file that implements the java.sql.Statement interface? If it's the latter, then I guess I need to get permission form the JDBC driver vendor to do it, right?

Notice I'm using the call predicate. If I were using the execution predicate would this change things any?

thanks in advance
- Garry







Back to the top