Aspect-oriented programming [1] (AOP) tries to provide linguistic mechanisms to factor out design concerns, which can be defined, understood, and evolved separately from the functional core of the application. A first approach to AOP can be the definition
caller(theseconditionsarenameddenyguards);
2.thecallviolatessomepreconditionandthecallerissuspendeduntiltheconditionbecomestrue(suspendguards);3.thecalldoesnotviolateanyprecon-ditionandexecutionofthefunctionalunitmayproceed.Malajprovidestheguardianconstructforexpressingsynchronisationconstraintsofmethodsofaclass.Eachguardianguardsaclassandeachclasshasatmostoneguardian.
ForeachclassC,theguardianGofCba-sicallyrepresentsthesetofsynchronizedmethodsofC.
Aguardianmayincludealsoasetoflo-calattributesandmethodde nitionstocodeguardsthatdependonstatecondi-tions.Finally,foreachmethodmoftheguardedclass,theguardianmayintroduceafragmentofcodetobeexecutedbeforeorafterm.Observethat,toavoidbreak-ingobjectencapsulationandtoincreaseseparationbetweenthefunctionalandsynchronisationaspects,guardiancode(i.e.,denyandsuspendguards,andbeforeandafterclauses)cannotaccessprivateelementsoftheguardedclassandhasread-onlyaccesstothepublicandpro-tectedattributesoftheguardedclass.
tomoveB.Bydefault,BfollowsAinitsmovements.
Interest:ifanobjectAisinterestedinB,
AhastobealwaysabletoreachB,butAandBmovecompletelyinde-pendently.IfanobjectAdoesnotownBandisnotinterestedinit,itsimplydoesnotcareofB’slocation,andevenofitsexistence.Evidently,ownershipimpliesinterest.Theserelationshipsareinherentlydy-namic:theyaresubjecttochangedur-ingprogramexecution,asobjectschangetheirinterestinotherobjectsaccordingtotheprogrammers’needs.
Malajprovidestherelocatorcon-struct:itrelocatestheobjectsofaclass.Relocationactionscanbeexecutedbeforeoraftertheexecutionofanymethod.Tospecifythis,therelocatorprovidesbeforeandafterclausesthatallowprogrammerstointroducethepieceofcodethatwillbeexecutedbeforeoraftertheexecutionofthemethod.
Inbeforeandafterclausesoneisnotallowedtochangeattributes(i.e.,thein-ternalstateofanobjectcanbechangedonlybyusingthemethodsitprovides).However,itispossibleto:
Takeorreleasetheownershipofanobject,byusingthemethods:
takeOwnership(Objectowned)throwsObjectOwnedExceptionreleaseOwnership(Objectowned)throwsNotOwnerException
1.2TheRelocationAspect
Networkawareprogramshaveoftentheneedtorelocatefunctionalunitsamongsites.Relocationcanbeexpressedinde-pendentlyspecifyingobjectsdeploymentandrelationshipstobemaintainedduringobjectsmotion:
Ownership:ifanobjectAownsanobject
B,thenAistheonlyobjectentitled
Onlytheownerisallowedtore-leaseownershipandonlyobjectsthathavenoownercanbeargumentsoftakeOwnership.Observethat,bydefault,eachnewlycreatedobjectisownedbytheobjectthatcreatedit.
2
1 Malaj A Multi Aspect L... 暂无评价 3页 免费 Abstract A Query ... Typing For a Minimal Aspect Language Preliminary Report Peter Hui James ...
1 Malaj A Multi Aspect L... 暂无评价 3页 免费 Abstract A Query ... Typing For a Minimal Aspect Language Preliminary Report Peter Hui James ...
热门文档