欢迎来到天天文库
浏览记录
ID:51617613
大小:478.00 KB
页数:28页
时间:2020-03-26
《Java语言程序设计与数据结构 基础篇原书第11版PPT及其他教辅资源40slideRMI.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1Chapter40RemoteMethodInvocation2ObjectivesToexplainhowRMIworks(§40.2).TodescribetheprocessofdevelopingRMIapplications(§40.3).TodistinguishbetweenRMIandsocket-levelprogramming(§40.4).Todevelopthree-tierapplicationsusingRMI(§40.5).Tousecallbackstodevelopinteractiveapplicatio
2、ns(§40.6).3RMIBasicsRMIistheJavaDistributedObjectModelforfacilitatingcommunicationsamongdistributedobjects.RMIisahigher-levelAPIbuiltontopofsockets.Socket-levelprogrammingallowsyoutopassdatathroughsocketsamongcomputers.RMIenablesyounotonlytopassdataamongobjectsondifferentsy
3、stems,butalsotoinvokemethodsinaremoteobject.4TheDifferencesbetweenRMIandRPCRMIissimilartoRemoteProcedureCalls(RPC)inthesensethatbothRMIandRPCenableyoutoinvokemethods,buttherearesomeimportantdifferences.WithRPC,youcallastandaloneprocedure.WithRMI,youinvokeamethodwithinaspeci
4、ficobject.RMIcanbeviewedasobject-orientedRPC.5TheDifferencesbetweenRMIandTraditionalClient/ServerApproachARMIcomponentcanactasbothaclientandaserver,dependingonthescenarioinquestion.ARMIsystemcanpassfunctionalityfromaservertoaclientandviceversa.Aclient/serversystemtypicallyo
5、nlypassesdatabackandfourthbetweenserverandclient.6HowdoesRMIwork?Asubinterfaceofjava.rmi.Remotethatdefinesthemethodsfortheserverobject.Autilitythatregistersremoteobjectsandprovidesnamingservicesforlocatingobjects.Aninstanceoftheserverobjectinterface.Aprogramthatinvokestheme
6、thodsintheremoteserverobject.Anobjectthatresidesontheclienthostandservesasasurrogatefortheremoteserverobject.Anobjectthatresidesontheserverhost,communicateswiththestubandtheactualserverobject.RMIworksasfollows:(1)AserverobjectisregisteredwiththeRMIregistry;(2)Aclientlooksth
7、roughtheRMIregistryfortheremoteobject;(3)Oncetheremoteobjectislocated,itsstubisreturnedintheclient;(4)Theremoteobjectcanbeusedinthesamewayasalocalobject.Thecommunicationbetweentheclientandtheserverishandledthroughthestubandskeleton.7PassingParametersWhenaclientinvokesaremot
8、emethodwithparameters,passingparametersarehandledunderthecoverbythestubandtheskele
此文档下载收益归作者所有