Last active
May 30, 2017 22:02
-
-
Save minostro/5ed4a4e5c1377b0cc88476aa00c7f7d0 to your computer and use it in GitHub Desktop.
Join Point Interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JPITypeDecl : TypeDecl ::= | |
ReturnType:Access Parameters:ParameterDeclaration* Exception:Access*; SuperTypeName:Access SuperArgumentName:Access*; | |
ExhibitBodyDecl : BodyDecl ::= | |
ReturnType:Access JPIName:Access Parameter:ParameterDeclaration* Pointcut:PointcutExpr; | |
CJPAdviceDecl : AdviceDecl; | |
CJPPointcutExpr: PointcutExpr; | |
CJPBeforeSpec : BeforeSpec ::= JPIName:Access; | |
/*the rest of the advice specifications are omitted from this listing*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jpi void CheckingOut(double price, Customer cus); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aspect Discount { | |
pointcut CheckingOut(double pPrice, Customer pCustomer): | |
execution(* ShoppingSession.checkOut(..)) | |
&& args(*,pPrice,*,pCustomer); | |
void around (double aPrice, Customer aCustomer) : CheckingOut(aPrice, aCustomer) { | |
double factor = aCustomer.hasBirthdayToday() ? 0.95 : 1; | |
proceed(aPrice*factor, aCustomer); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aspect Discount { | |
void around CheckingOut(double price, Customer c) { | |
double factor = c.hasBirthday()? 0.95 : 1; | |
proceed(price*factor, c); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypeDecl type_declaration = jpi_declaration.d {:return d; :}; | |
BodyDecl class_member_declaration = exhibit_declaration.d {: return d; :}; | |
BodyDecl aspect_body_declaration = cjp_advice_declaration.d {: return d; :}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void checkingOut() throws Exception { | |
throw new Exception(); | |
} | |
void around(): call(* checkingOut(..) ) { | |
proceed(); | |
//throw new Exception(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void initLexerKeywords(AbcLexer lexer) { | |
lexer.addGlobalKeyword( | |
"jpi", //"exhibits" | |
new LexerAction_c( | |
new Integer(Terminals.JPI), //Terminals.EXHIBITS | |
new Integer(lexer.pointcut_state()) | |
) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShoppingSession { | |
ShoppingCart cart; | |
double totalValue; | |
void checkOut(Item item, double price, int amount, Customer cus){ | |
cart.add(item, amount); //fill shopping cart cus.charge(price); //charge customer | |
totalValue += price; //increase total value of session | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShoppingSession { | |
exhibits void CheckingOut(double price, Customer c): | |
execution(* checkOut(..)) | |
&& args(*, price, *, c); | |
void checkOut(Item item, double price, int amount, Customer cus){ | |
cart.add(item, amount); //fill shopping cart cus.charge(price); //charge customer | |
totalValue += price; //increase total value of session | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment