diff --git a/Example31_Aspect_Oriented_Paradigm.mp b/Example31_Aspect_Oriented_Paradigm.mp new file mode 100644 index 0000000000000000000000000000000000000000..63efa4a0c0359b3661ef555f971e604f71d8548e --- /dev/null +++ b/Example31_Aspect_Oriented_Paradigm.mp @@ -0,0 +1,32 @@ +/* Example31_Aspect_Oriented_Paradigm.mp + + The COORDINATE operation supports a “cause-effect†refinement for +the behavior of two components and it bears a certain similarity +to Aspect-Oriented Programming (AOP) paradigm [Kiczales et al. 1997] +(or read https://en.wikipedia.org/wiki/Aspect-oriented_programming). +For example, the following AOP pattern could be modeled by MP schema +where event coordination implements AOP join point and advice +coordination. + + Suppose that the main stream of execution contains calls to +methods M1 and M2 as join points, and the aspect behavior requires +a call to Prolog before, and to Epilog after each method call as an +advice. The corresponding MP model may look like the following. + +*/ + +SCHEMA Aspect_Oriented_Paradigm + +ROOT Main: (* ( M1 | M2 | do_something_else ) *); +ROOT PreAdvice: (* Prolog *); +ROOT PostAdvice: (* Epilog *); + +COORDINATE + $jp: ( M1 | M2 ) FROM Main, + $a1: Prolog FROM PreAdvice, + $a2: Epilog FROM PostAdvice + +DO ADD + $a1 PRECEDES $jp, + $jp PRECEDES $a2; +OD; \ No newline at end of file