文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 1 Malaj A Multi Aspect LAnguage for Java
侵权投诉

1 Malaj A Multi Aspect LAnguage for Java

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

上一页第2页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email