Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] passing information to a pointcut

Hi all,

I want to share the workaround i found for the my problem:
(note the abstract aspect will work as Logging - Handling Layer whereas the concrete aspect will just contain Logger-Instances & pointcuts)

public abstract aspect AbstractAspect {
        private static Log logref;

        public static boolean setLog(Log l) {
                logref = l;
                return l.isEnabled();
        }

        abstract pointcut beforeTrace();

        before() : beforeTrace() {
                logref.log("Before.");
        }
}

public aspect Aspect extends AbstractAspect {
        private static Log testLog = new Log(true, "Test");
        private static Log test2Log = new Log(true, "Test2");

        pointcut beforeTrace() : beforeTraceTest()
		|| beforeTraceTest2();

        pointcut beforeTraceTest() :
		execution(* Test.doSome(..))
		&& if (setLog(testLog));
        pointcut beforeTraceTest2() :
		 execution(* Test2.doSome(..))
		&& if (setLog(test2Log));

}


I'm not happy with this solution as it involves a method call & the target application is Logging (which in case of debug disabled) is quite time critical. However the JIT may optimize that away.

Perhaps some of you see another way to do such a thing?

Regards,
Simon


Simon Heinzle wrote:
Hi everybody,

is there a possibility to pass information other than args() and this() and alike to a pointcut?? For example like

pointcut logPointcut(Object thiz, Object logger) :
    call (* *..Clazz.method(..) && this(thiz) && logger(myLogger);
                                                     \--------------/
(something like this) ---------------------------------------^

Didn't find any information on that...

Thanks,
Simon
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top