[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Introducing static member variable - Static Cross cutting concerns : Noob
|
Hello,
Is there any way to introduce a static member variable to all
classes in a package.
Following is a synopsis of what I would like to accomplish.
Here is the java functionality that I need
package foo;
import crazy.Trace;
class T
{
private static final Trace TRACE = new Trace("$$ foo/T Version 2.24");
T(Object... args)
{
TRACE.entering("T(Object... args");
try
{
......
......
}
finally
{
TRACE.exiting("T(Object... args");
}
}
void dooT(Object... args)
{
TRACE.entering("dooT(Object... args");
try
{
......
......
}
finally
{
TRACE.exiting("dooT(Object... args");
}
}
}
// similar class P
Here is how I would like to achieve it using aspects
class T
{
T(Object... args)
{
......
......
}
void dooT(Object... args)
{
......
......
}
}
// similar class P
package foo;
aspect L
{
pointcut scope() : within(foo..*);
pointcut methods() : scope() && execution(* *.*(..));
before() : methods()
{
TRACE.entering(thisJoinPointStaticPart.getSignature().toLongString(),
thisJoinPoint.getArgs());
}
after() : methods()
{
TRACE.exiting(thisJoinPointStaticPart.getSignature().toLongString());
}
}
The part of this that has been stumped is how would I introduce
the private static final Trace reference in all classes in the
package.
Thanks
Bhaskar