I have an AspectJ trace routine set up to log method entry and exit
conditions using the following pointcuts:
public aspect Trace {
pointcut anyMethodExecuted(): execution (*
biz.ianw.lanchecker.*.*(..)) && !within(Trace); // && !within(
is(AnonymousType) );
pointcut anyConstructorExecuted(): execution
(biz.ianw.lanchecker.*.new(..)) && !within(Trace);
In my email class I have a method which calls the setDebugOut method to
redirect the debug output to a LogOutputStream:
final private static Logger log =
LoggerFactory.getLogger(MailMail.class);
...
LogOutputStream losStdOut = new LogOutputStream() {
@Override
protected void processLine(String line, int level) {
log.debug(line);
}
};
public void sendPlainHtmlMessage(...) {
Session session = javaMailSender.getSession();
PrintStream printStreamLOS = new PrintStream(losStdOut);
session.setDebugOut(printStreamLOS);
...
This works fine, except that the Trace class pointcut intercepts the
call to, presumably, the anonymous inner class, producing as output:
20:14:18.908 TRACE [biz.ianw.lanchecker.Trace] - Enters method:
Logger biz.ianw.lanchecker.MailMail.access$0()
20:14:18.909 TRACE [biz.ianw.lanchecker.Trace] - Exits method:
Logger biz.ianw.lanchecker.MailMail.access$0().
20:14:18.909 TRACE [biz.ianw.lanchecker.Trace] - with return
value: Logger[biz.ianw.lanchecker.MailMail]
20:14:18.909 DEBUG [biz.ianw.lanchecker.MailMail] - DEBUG:
getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
I added the rather overly broad
&& !within( is(AnonymousType) )
condition to the pointcut, as shown above, but it had no effect. In fact
I'm having real difficulty finding is(AnonymousType) documented anywhere.
How can I write a pointcut that excludes this anonymous inner method,
preferably without impacting any others I may wish to log in future?
Ian
(Originally posted this 5 days ago on SO, but haven't had any replies)
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users