[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Initializing inherited instance variables
|
Hi,
Im am trying to implement logging aspects that can be
customized on a class level basis. I have something
on the lines of:
public abstract aspect LoggingAspect
{
// log4j logger
protected Log log;
// call depth per log
protected int callDepth;
// Classes left unspecified
public abstract pointcut cutClass(Object o);
// Constructors in classes
protected pointcut cutConstructor(Object o) :
cutClass(o) &&
execution (new(..)) && !within(LoggingAspect+);
// Methods in classes
protected pointcut cutMethod(Object o) :
cutClass(o) &&
execution (* * (..)) && !within(LoggingAspect+);
before (Object o): cutConstructor(o)
{
if(log.isDebugEnabled()) {
log.debug(logConstruction(thisJoinPoint, o));
}
}
before (Object o): cutMethod(o)
{
if(log.isDebugEnabled()) {
log.debug(logBefore(thisJoinPoint, o));
}
}
after (Object o): cutMethod(o)
{
if(log.isDebugEnabled()) {
log.debug(logAfter(thisJoinPoint, o));
}
}
after (Object o) throwing(Exception e) :
cutMethod(o)
{
if(log.isDebugEnabled()) {
log.debug(logException(thisJoinPoint, e, o));
}
}
...
// log helper methods
}
public aspect CustomLog extends LoggingAspect
{
// compiler complains
callDepth = 2;
log = LogFactory.getLog(CustomLog.class);
// only log certain packages
public pointcut cutClass(Object o) :
this(o)
&& within(oracle.apps.ctb.admin.encounter.*);
}
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com