The example proposed here is taken from Z. Yang et al. An aspect-oriented approach to dynamic adaptation as a pragmatic assessment on the expressiveness of the AIOC language with relation to distributed dynamic aspect-oriented systems.
In the scenario proposed in the paper, the authors describe a conferencing application which allows users to match into a conference and exchange messages among each other. The application is further enriched with aspects that adapt the level of security of the communication by introducing encrypt/decrypt functionalities on message-passing operations.
The AIOC implementation of this scenario uses empty scopes participated only by the user that sends (or receives) the message. These scopes work as AOP pointcuts that precede the sending (or the reception) of a message. Notably, the properties of a rule can capture the expressiveness of AOP pointcuts which allow the specification of its position along the execution of the program. Moreover, the rules apply based on the value of property N.position
and the identity of the participant of the scope (either user1 or user2).
// gets the message msg@user1 = getInput( "User1: Insert the message to send" ); // possibly encrypts it scope @user1{ skip } prop { N.position = "before_send" }; // sends the message send: user1( msg ) -> user2( msg ); // possibly decrypts it scope @user2{ skip } prop { N.position = "after_send" }; { _r@user2 = show( "User2: " + msg ) | // continue protocol c@user1 = getInput( "User1: Do you want to continue [y/n]? "); if( c != "y" )@user1{ continue@user1 = false | continue@user2 = false } }
rule { on{ N.position == "before_send" } do { msg@user1 = "[ENCRYPT]"+msg } } rule { on{ N.position == "after_send" } do { msg@user1 = "[DECRYPT]"+msg } } rule { on{ N.position == "before_send" } do { msg@user2 = "[ENCRYPT]"+msg } } rule { on{ N.position == "after_send" } do { msg@user2 = "[DECRYPT]"+msg } }