Two questions:
First:
I
seem to be hitting some odd behavior with AspectJ.
As discussed earlier, I have an Aspect that
watches all the SQL calls to my JDBC Driver (Oracle). It then
logs the statements to a log file via Log4j.
It seems to only be doing this some of the
time though. Here is my aspect:
private static AuditLogger LOG =
AuditLogger.getLogger(StatementAspect.class,
LDAPPrincipal.class);
pointcut executeSql(String sql):
(
call (public CallableStatement Connection.prepareCall(..))
||
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) {
recordSqlStmt(sql);
}
private void recordSqlStmt(String sql) {
//
custom level
LOG.audit((Subject)currentSubjectHolder.get(), sql);
}
It seems to log it initiailly but when my
JDO implementation (XORM) does anything, it doesn't get logged.
I've looked at XORM's src and it is using
Connection.prepareStatement(String)....
Any one know what this would be
happening?
Second question:
I have a class, AspectAuditProxy that has
the following:
public static void setAuditable(Subject subject) {}
public static void
setAuditable(Subject subject, Class principalClass) {}
public static void
setAuditable(Class auditingClass,
Subject subject,
Class principalClass)
{}
I then have an Aspect like so:
before (Subject subject):
call (public static void
AspectAuditProxy.setAuditable(Subject)) &&
args(subject)
{
currentSubjectHolder.set(subject);
}
before (Subject subject, Class principalClass):
call (public static void
AspectAuditProxy.setAuditable(Subject, Class)) &&
args(subject, principalClass)
{
currentSubjectHolder.set(subject);
LOG =
AuditLogger.getLogger(StatementAspect.class, principalClass);
}
before (Class auditingClass, Subject subject, Class
principalClass):
call (public static void
AspectAuditProxy.setAuditable(Class, Subject, Class))
&&
args(auditingClass, subject,
principalClass)
{
currentSubjectHolder.set(subject);
LOG = AuditLogger.getLogger(auditingClass,
principalClass);
}
But it doesn't seem to be catching
anything. I use AspectAuditProxy as a way to get the Subject
object to the Aspect system for logging purposes like so (in my
Login.class):
LoginContext lc = new LoginContext("Ldap",
new SimpleCallbackHandler(username, password));
lc.login();
AspectAuditProxy.setAuditable(lc.getSubject());
Any ideas about this one?
Sorry for the long email...
--
Sloan