版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2015年-11月-13日第一章INTRO概念一类独立的系统软件和服务程序Aclassofstandalonesystem-levelsoftwareandservicesprocedures在操作系统的顶部WorkingonthetopofOS管理计算机资源和网络Managingcomputationalresourcesandnetworkcommunications支持分布式通信Supportingdistributedappsb)功能在异构的网络环境中,涉及到跨连通性和可操作问题中提供统一的协议和接口Providingstandardizedinterfacesandprotocols隐藏实现细节Hidingimplementationdetails提高程序的可移植性Increasingtheportabilityofapps放置于操作系统和数据库管理系统的顶部为高级应用的开发和执行提供环境Providingenvironmentsfortheexecutionanddevelopmentofhigher-levelapps协助软件工程师灵活高效地开发和集成复杂的分布式软件Assistingsoftwareengineersinflexiblyandefficientlydevelopingandintegratingcomplexdistributedsoftware中间件发展的主要因素隐藏异构型Hidingheterogeneity硬件异构hardwareheterogeneity操作系统异构OSheterogeneity数据库异构databaseheterogeneity支持可操作性supportinginter-operability不同的平台differentplatforms不同的网络协议differentnetworkprotocols不同的通信机制differentcommunicationmechanisms提高软件的复用率improvingefficiencyandqualityofsoftwaredevelopment主要类别对象请求代理中间件ORBobjectrequestbrokersmiddleware面向信息中间件MOMmessage-orientedmiddleware数据库访问中间件DAMdatabaseaccessmiddleware事务处理中间件TPMtransactionprocessingmiddleware第二章RMI对象请求代理ORB提供一个框架,使得远程对象可以在网络中以同样的方式使用在网络中的本地对象Providingaframeworkwhereremoteobjectcanuselocalobjectsinthesamewayoverthenetwork当对象在客户端和服务器之间传递时,提供功能的编组和解组的功能Providingfunctionalitiesformarshallingandunmarshalingwhenobjectsaretransmittedbetweenclientsandservers.客户端和服务器之间的传输隐藏实现的细节,这使得开发人员能够有效地实现分布式应用程序,而无需面对复杂的底层操作系统和网络通信Hidingtheimplementationdetails,whichenabledeveloperstoimplementdistributedappsefficientlywithoutfacingthecomplexunderlyingoperatingsystemsandnetworkcommunicationsJAVARMI的概述WritingdistributedobjectsusingjavaSimpleanddirectmodelfordistributedcomputationwithjavaobjects以java为中心,由此带来了安全性和分布式计算的可移植性Centeredaroundjava,thusbringingthepowerofJavaSafetyandportabilitytodistributedcomputing行为可以被转移动Behaviorcanberemoved通过JNI可以链接到现有的遗留系统Connectedexistedlegacysystemby JNI通过JDBC可以链接到关系数据库ConnectedrelationaldatabasebyJDBC优点面向对象OO全部的对象可以作为参数和返回值Allobjectscanbeargumentsandreturnvalues可移动性行为mobilebehavior类的实现可以被移植Theimplementationsofclasscanbemoved设计模式designpatterns传递性对象确保了面向对象技术的全功率PassingobjectsensurethefullpowerofOOtechs基于JAVA的安全机制:安全经理BasedonJAVAsecuritymechanismssecuritymanager次优点十分容易开发,使用,维护Easytowrite,useandmaintain可以与现存的遗留系统链接canconnectwithexistedlegacysystemRMI/JNI,RMI/JDBC开发一次,可以在任何地方运行writeonce,canbeuseanywhere100%移植到任何JVM100%portabletoanyJVM分布式垃圾收集distributedgarbagecollection并行计算parallelcomputing多线程,并行处理MUTI-thread,concurrentprocessing架构architecture存根stub1.编组参数,发送调用Marshalingarguments,sendinginvocation骨骼skeleton解封参数,调用服务器来实现Unmarshalingarguments,invokingserver'simplementationf)RMI的分布式应用定位远程对象locateremoteobjects与远程对象通信communicatewithremoteobjectsiii.为被传递的对象加载类定义loaddefinitionofclassesthatarepassedaroundg)远程接口,对象和方法remoteinterface,objectsandmethods通过实现一个具有以下特点的远程接口来实现对象远程化Anobjectsbecomesremotebyimplementingaremoteinterfacewithfollowingcharacteristics—个远程接口扩展了接口oneremoteinterfaceextendsaninterfaceJava.rmi.remote接口的每—个方法都有事先声明everymethodsoftheinterfacehasbeendeclareda)Java.rmi.RemoteExceptioninitsthrowsclauseh)主要步骤mainsteps定义远程接口definetheremoteinterfaceremotely可能包括本地接口/方法的实现mayincludetheimplementationoflocalinterface/method客户实现implementingtheclient1.在远程接口定义后的任何时间都可以被实现canbeimplementedanytimewhentheremoteinterfacehasbeendefined第三章JMSa)面向消息中间件MOM在异构平台上发送/接收分布式应用软件/组件之间的消息Sending/receivingmessagesbetweendistributedapps/componentsovertheheterogeneousplatforms1.支持异步调用Supportingasynchronouscalls创建一个分布式通信层Createadistributecommunicationlayer1.避免应用开发者接触来自不同系统和网络接口的细节InsulatingappdevelopersfromthedetailsaboutdifferentOSandnetworkinterfaces在不同平台和网络上的API通常是MOM提供的TheAPISfromdifferentplatformsandnetworkareprovidedbyMOM比较异步通信Asynchronouscommunication组件松散耦合Loosely-coupledcomponentsRPC/ORB1.同步通信Synchronouscommunication组件紧密耦合Tightly-coupledcomponentsMOM标准i.历史上,缺乏MOM的准确标准Therewasalackofstandardsinthehistory.高级消息队列协议AMQPAdvancedMessageQueuingProtocol数据分发服务DDSDataDistributionService可扩展消息和存在协议XXMPextensibleMessagingandPresenceProtocolJava消息服务的JAVAEEJavaMessageServicebyJAVAEE由大多数MOM供应商实施,旨在隐藏特定的MOMAPI实现方法ImplementedbymostMOMvendorsandaimstohidetheparticularJavaMessageService—种JAVAAPI接□,允许应用程序创建发送接收读取消息AjavaAPIthatallowsappstocreate,send,receiveandreadmessages定义一组通用接□和关联用语Definesasetofcommoninterfaceandassociatedsemantics通过JMS的提供者,力争最大力度的提高JMS应用程序的可移植性TrythebesttoimprovetheportabilityofJMSappsacrossJMSproviders使得通信变得松散耦合的,异步的,可靠的Enablingcommunicationthatislooselycoupled,asynchronous,andreliable当用JMS的时候提供者希望该组件不依赖与其他组件的接□信息,因此组件可以很容易地被替换Providershopethecomponentsdon'trelyonothercomponents'message,socomponentscanbeeasilyreplaced提供者希望该应用程序运行时其他组件也同时运行Providerswantstheappstorunwhetherornotallcomponentsareupandrunningsimultaneously应用业务模式允许组件将信息发送到另—个组件,并继续操作而不用即时响应Applicationbusinessmodelallowscomponentssendmessagetoanothercomponentsandtocontinuetooperatewithoutreceivinganimmediateresponse信息传递方式点对点传送消息方式Pointtopointmessagingstyle1.每个消息都是针对特定队列的Eachmessageisaddressedtoaspecificqueue队列将保留所有发送的消息,直到他们被消耗或者过期Thequeuewillretainallthemessagesthathavebeensentuntiltheyareconsumedorexpire.每一条消息都只有一个消费者Everymessagehasoneconsumerii. 发布/订阅消息方式Publish/subscribemessagingstyle1.客户端可以将信息发到一个主题里Theclientcansendamessagetoatopic出版社和订阅者可以动态的发布或者订阅主题Publisherandsubscribercandynamicallypublishorsubscribetothetopic.当且仅当消息被发送给订阅服务器后,主题才会保留信息Topicwillretainthemessagesonlywhenmessageshavebeensenttothesubscribers每一条信息都可以有多个消费者Eachmessagehasmultipleconsumers当一个客户端创建了一个主题后,另一个订阅了相应主题的客户端才可以消费已发送的信息,并且消费者必须要保持活跃来消费信息
Afteraclientcreateatopic,anotherclientwhichhassubscribedthetopiccanconsumemessagesthathavebeensent,andtheconsumermustcontinuetobeactiveinorderforittoconsumemessages.MsgM旳Cltent1Senda*<——Consumes 〜Acknowledges—-CNent2QueueMsgC*ieni1——PuMlsties一*GllentSTopicMsgC*ieni1——PuMlsties一*GllentSTopic百 SuDacrlbeaDellrvarsSubscribesDelirversQiams消息消费同步Synchronously1.消费者通过调用消息接收方法来获取消息的目的地Consumerfetchesthemessagefromthedestinationbycallingthereceivemethod如果消息没有在指定时间内到达,该接收方法会阻止消息进入Thereceivemethodcanblockuntilamessagearrivesorcantimeoutifamessagedosenotarrivewithinaspecifiedtimelimit异步Asynchronously客户端可以注册一个消息监听器Theclientcanregisteramessagelistenerwithaconsumer当消息到达目的地时,JMS的提供者通过调用监听器的onMessage方法来提供信息Whenmessagearrivestothedestination,theproviderofJMSdeliverthemessagebycallingthelistener'sonMessagemethodh) JMS兀素JMS提供者:一个JMS接口的实现JMSprovider:animplementationoftheJMSinterfaceJMS客户端:一个应用或者过程,可以生产/接收消息JMSclient:anapplicationorprocessthatcanproduce/receivemessagesJMS提供者/出版者:创建/发送消息的客户端JMSprovider/publisher:aclientthatcancreate/sendmessagesJMS消费者:接收消息的客户端JMSconsumer:aclientthatcanreceivemessagesJMS消息:包含数据的对象,在客户端之间转移JMSmessage:anobjectincludingdataandtransferredbetweenJMSclientsJMS队列:一个包含着已经被发送出去并且等待被接收的信息(只有一个消费者)中转区JMSqueue:aqueuethatincludemessageswhichhavebeensentand
waitingtobereadxiii.JMS主题:一个发送信息给多个订阅服务器的初版发行机构xiv.JMSTopic:adistributionmechanismforpublishingmessagesthataredeliveredtomultiplesubscribersi)JMS应用程序的基本构造块JMSapplication'sbasicbuildingblocksi.ii.iii.管理对象:连接工厂和目的地Administeredobjects:connectionfactoriesanddestinations链接iv.Connectionsv.会议vi.Sessionsvii.消息生产者viii.Messageproviderix.消息消费者x.Messageconsumerxi.消息xii.Message
JMSAPIProgrammingModelj)JMS信息类型JMSMessageTypesMessageTypeBodyContentsTextXlessageAjava」iin启-Stringobject(lorexaimple;thecontentsofanXMLfile). jMapMessageAsetofname-vaAiEpairs,withnamesasStringobjectsandvaluesasprimitivetypesintheJavaprogrannminglanguage.Theentriescanbeaccessedsequentiallybyenumeratororrandomlybynam^.Theorderoftheentriesisundcfincil.BytesMessageAstreamofuninterprEtEdbytes.ThismessagetypeUfbtliterallyencodingabodytomatchynexistinginessagefann?it.StreamMessageAstreamofprimitivevaluesintheJavaprograiniTiin^language,tilledandreadsequentially.ObfectMessageASerializablEobjecTintheJava卩rogramininglanguage.
第四章JDBCa)Intro一套为了建立JAVA编程语言和更大范围数据库之间独立性数据库连接的标准JAVAAPI接口b)框架b)框架JDBCArchitecture•JDBCAPI&JDBCDriverAPIJavaApplicationJD8CAPIc)组件JDBCOdvorJDBCDriverManagerc)组件JDBCOdvorJDBCDriverManagerDriverManagerDriverConnectionStatementResultSetSQLexceptionJDBC功能创造一个数据库连接产生SQL声明在数据库中执行SQL语句查看修改产生的记录生成一个简单的JDBC应用导入包导入数据库连接编程需要的JDBC类的包Importjava.Sql.*;注册JDBCdriver初始化一个driver,来建立一个与数据库联系的通信通道Class.forName(“com.mysql,jdbc,driver”);打开链接创造一个链接对象,代表着与数据库的物理连接Staticfinalstringuser=”username”;Staticfinalstringpass=”password”;Conn=DriverManager.getConnection(DB_URL.user,pass);执行语句为了建造并提交SQL说明给数据库,使用声明或者准备声明Stmt=conn.createStatement();Stringsql;Sql=“SELECTid,name,hometownFROMt_student”;
ResultsSetrs=stmt.executeQuery(sql);对更新,插入,删除进行声明Stmt=conn.createStatement();Stringsql;Sql=“DELETEFROMt_studentwhereid=1”;Intnum=stmt.executeUpdate(sql);从结果中提取数据1.用resultSet.getXXX()1.用resultSet.getXXX()从结果中提取数据vi.清空环境while(r5.next(]){//Retnevebycolumnnameintid=rs-getlntC^d");Stringname=rs.getStringC'name11);Stringhometown=rs.getStrjng("hometown");rs.close();stmtxlosef);ronrs.close();stmtxlosef);ronn.close();f)数据类型SQLJDBC/JavasetXXXupdateXXXVARCHARjava,lang.StringsetString□pdatestringCHARjavang,StringsetStringupdatestringNUMERICjava.math.BigDecimalsetBigDecimalupdateBigDecimalINTEGERintsetlntupdatelntFLOATfloatsetFloatupdateFloatDOUBLEdoublpsetDoubleupdateDouble□ATEjava.sql.DatesetDateupdateDateTIMEjava.sql.TimesetTimeupdateTimeTIMESTAMPjava.sql.TimesTampsetTimestampupdateTimestampg)执行SQL语句发送查询语句给数据库发送更新语句给数据库TheStatementObject•UsingcreateStatement()methodStatementstmt二null;try{stmt二conn.createStatement();}catch(SQLExceptione){}finally{stmt.close();k}
ThePreparedStatementObjectPreparedStatementpstmt=null;tn/{StringSQL="UPDATEt_studentSETage二?WHEREid=?”pstmt=cann.prepareStatement(SQL);catch(SQLExceptione){finally{pstmt.close();TheCallableStatementObjectCallableStatementcstmt=null;try{StringSQL="{callproceduneName(?/?)}ncstmt=conn.preparecall(SQL);catch(SQLExceptione){HR■finally{TheCallableStatementObject(cont.)ParameterDescriptionINAparameterwhosevalueisunknownwhentheSQLstatemsntiscreated.YoubindvaluestoINparameterswiththesetXKXf)methods.OUTAparameterwhose\/alueissuppliedbytheSQLstatementitreturns.YouretrievevaluesfromtheOUTparameterswiththegetXXXf)methods.INOUTAparameterthatprovidesbothinputandoutputvalues.YoubindvariableswiththesetXXX()methodsandretrievevalueswiththegetXXX()studentlD=102;stmt.se
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五版苗木种植与农业综合开发合同样本4篇
- 二零二五年度教育培训股东股权转让与合作办学合同2篇
- 二零二五版婴幼儿奶粉国际市场拓展与出口合同4篇
- 2025版绿色环保型商品房预售买卖合同3篇
- 2025年度校服品牌授权与校园形象塑造合同3篇
- 2025年度事业单位合同工劳动法执行监督评估合同3篇
- 2025年度生鲜配送冷链物流承包合同范本3篇
- 2025年度个人佣金提成与长期激励合同2篇
- 课题申报参考:能源数据要素赋能可再生能源电力生产的机制与对策研究
- 课题申报参考:民族传统体育与体育非物质文化遗产的传承与保护研究
- 2025年N1叉车司机考试试题(附答案)
- 《医院财务分析报告》课件
- 2025老年公寓合同管理制度
- 2024-2025学年人教版数学六年级上册 期末综合卷(含答案)
- 2024中国汽车后市场年度发展报告
- 感染性腹泻的护理查房
- 天津市部分区2023-2024学年高二上学期期末考试 物理 含解析
- 《人工智能基础》全套英语教学课件(共7章)
- GB/T 35613-2024绿色产品评价纸和纸制品
- 2022-2023学年五年级数学春季开学摸底考(四)苏教版
- 【蚂蚁保】2024中国商业医疗险发展研究蓝皮书
评论
0/150
提交评论