//List of import instructions generated in every AspectJ file import fr.enst.ocarina.polyORB_HI_runtime.OutPort; import fr.enst.ocarina.polyORB_HI_runtime.InPort; import fr.enst.ocarina.polyORB_HI_runtime.ProgramException; import fr.enst.ocarina.polyORB_HI_runtime.Debug; import fr.enst.ocarina.polyORB_HI_runtime.Message; aspect CheckCode{ //The generated AspectJ pointcut //In our case, we intercept the event of sending a data through an output port pointcut Verification(): call (* Activity.sendOutput (..)); //The variables generated from the variables and initially sections public static final GeneratedTypes.IntegerType COUNTER = new GeneratedTypes.IntegerType(1); public static final GeneratedTypes.StringType MESSAGE = new GeneratedTypes.StringType("Card Rejected !"); //The generated Advice code void around():Verification(){ //Advice declaration //The condition that checks the intercepted port //In our case the identification number of the output port is //NODE_CUSTOMER_VALIDATION_RESTORECODE_OUT_K if (((OutPort)(thisJoinPoint.getArgs()[1])).getPortNumber()== Deployment.NODE_CUSTOMER_VALIDATION_RESTORECODE_OUT_K){ //The generated advice action part if(COUNTER.value==3){ // Set the call sequence OUT port values try { Activity.putValue(Deployment.NODE_CUSTOMER_VALIDATION_K, Activity.REJECTEDCARD_OUT_V, MESSAGE); } catch (ProgramException e) { Debug.debugMessage("Error while putting value in port " +Deployment.NODE_CUSTOMER_VALIDATION_REJECTEDCARD_OUT_K + " from entity " + Deployment.NODE_CUstomer_VALIDATION_K); } // Send the call sequence OUT port values try { Activity.sendOutput(Deployment.NODE_CUSTOMER_VALIDATION_K, Activity.REJECTEDCARD_OUT_V);} catch (ProgramException e) { Debug.debugMessage("Error while sending output in port " + Deployment.NODE_CUSTOMER_VALIDATION_REJECTEDCARD_OUT_K + " from entity " + Deployment.NODE_CUSTOMER_VALIDATION_K);} COUNTER.value=1; } else{ //The proceed action proceed(); //The generated code from the assignment action //In this case, the operator ":=" used in AO4AADL is transformed //to the operator "=" //For the arithmetic operations, no changes are applied to //the operators {*, /, +, -} COUNTER.value=COUNTER.value+1; }} //This code will be executed if the intercepted port is not RestoreCode_Out_V. else{proceed();}}}