[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
AW: [aspectj-users] Is there a common syntax for a compile time "if"pointcut?
|
Hi Scott,
I also try to use the "declare warning/error" statement, but you seem to be already on some next steps forward; I stuck at the pointcut declaration for System.out.
If I say:
pointcut notice() : call( * *.*+.notice*(..) );
declare error : notice() : "don't call 'notice' function" ;
all runs fine; I get some error messages in my tasks list, but similarly:
pointcut sysout() : call( * *.System.out*(..) );
declare error : sysout() : "don't call System.out" ;
doesn't do anything (even if I know there is a place where System.out is used). How do you make it ?
Regards,
Dragan
-----Ursprüngliche Nachricht-----
Von: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] Im Auftrag von Scott Hayward
Gesendet: Mittwoch, 1. Juni 2005 18:45
An: aspectj-users@xxxxxxxxxxx
Betreff: [aspectj-users] Is there a common syntax for a compile time "if"pointcut?
Hi,
I'm trying to write an aspect that will declare either a warning or error,
depending on the value of some constant. However, the "if" pointcut
designator cannot be used with declare warning/error because it evaluates
at run time. I need something at compile time.
What I want is to be able to configure an aspect that will declare a
warning, error or ignore some condition like calls to System.out.
First, I define a set of constants in a class:
/** This constant defines whether a static aspect should generate an
error */
public static final String CFG_ERROR = "ERROR";
/** This constant defines whether a static aspect should generate a
warning */
public static final String CFG_WARN = "WARNING";
/** This constant defines whether a static aspect should be ignored
*/
public static final String CFG_IGNORE = "IGNORE";
/** This constant configures whether to generate an error, warning or
ignore */
public static final String CFG_STATIC_TEST_XYZ = CFG_ERROR;
Now I want to write aspects like this:
/** This pointcut determines if the static test condition is found */
public pointcut staticTestXYZ() : <<some pointcut, like writing to
System.out>> ;
/** Declare an warning if configured to do so */
declare warning : staticTestXYZ() &&
<<need compile time test for CFG_STATIC_TEST_XYZ=CFG_WARN>> :
"I'm warning you not to do XYZ";
/** Declare an error if configured to do so */
declare error : staticTestXYZ() &&
<<need compile time test for CFG_STATIC_TEST_XYZ=CFG_ERROR>> :
"You are not permitted to do XYZ";
Is there a standard syntax for doing things like this?
Thanks,
Scott.
_______________________________________________________
Scott Hayward
Advisory IT Specialist
IBM Canada Ltd., Pacific Development Centre
4611 Canada Way, Burnaby, BC, V5G 4X3 CANADA
Dir (604) 297-3096 Fax (604) 297-3030 4 / PA1 / 4611 / BURN
email: shayward@xxxxxxxxxx Web: http://www.can.ibm.com/pdc
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users