中间件复习笔记
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
中间件复习笔记
2015年-11月-13日
第一章INTRO
1.概念
ii.一类独立的系统软件和服务程序
iii. A class of standalone system-level software and services procedures iv.在操作系统的顶部
v.Working on the top of OS
vi.管理计算机资源和网络
vii.Managing computational resources and network communications
viii.支持分布式通信
ix.Supporting distributed apps
b)功能
i.在异构的网络环境中,涉及到跨连通性和可操作问题中
ii.提供统一的协议和接口
iii.Providing standardized interfaces and protocols
iv.隐藏实现细节
v.Hiding implementation details
vi.提高程序的可移植性
vii.Increasing the portability of apps
viii.放置于操作系统和数据库管理系统的顶部
ix.为高级应用的开发和执行提供环境
x.Providing environments for the execution and development of higher-level apps
xi.协助软件工程师灵活高效地开发和集成复杂的分布式软件
xii.Assisting software engineers in flexibly and efficiently developing and integrating complex distributed software
c)中间件发展的主要因素
i.隐藏异构型Hiding heterogeneity
1.硬件异构hardware heterogeneity
2.操作系统异构OS heterogeneity
3.数据库异构database heterogeneity
ii.支持可操作性supporting inter-operability
1.不同的平台different platforms
2.不同的网络协议different network protocols
3.不同的通信机制different communication mechanisms
iii.提高软件的复用率improving efficiency and quality of software development d)主要类别
i.远程过程调用中间件RPC remote procedure call middleware
ii.对象请求代理中间件ORB object request brokers middleware iii.面向信息中间件MOM message-oriented middleware
iv.数据库访问中间件DAM database access middleware
v.事务处理中间件TPM transaction processing middleware
第二章RMI
a)对象请求代理ORB
i.提供一个框架,使得远程对象可以在网络中以同样的方式使用在网络中的本地
对象
ii.Providing a framework where remote object can use local objects in the same way over the network
iii.当对象在客户端和服务器之间传递时,提供功能的编组和解组的功能
iv.Providing functionalities for marshalling and unmarshaling when objects are transmitted between clients and servers.
v.客户端和服务器之间的传输隐藏实现的细节,这使得开发人员能够有效地实现分布式应用程序,而无需面对复杂的底层操作系统和网络通信vi.Hiding the implementation details,which enable developers to implement distributed apps efficiently without facing the complex underlying operating
systems and network communications
b)JAVA RMI 的概述
i.用java编写分布式对象
ii.Writing distributed objects using java
iii.直接用java对象来为分布式计算机建模
iv.Simple and direct model for distributed computation with java objects
v.以java为中心,由此带来了安全性和分布式计算的可移植性
vi.Centered around java, thus bringing the power of Java Safety and portability to distributed computing
vii.行为可以被转移动
viii.Behavior can be removed
ix.通过JNI可以链接到现有的遗留系统
x.Connected existed legacy system by JNI
xi.通过JDBC可以链接到关系数据库
xii.Connected relational database by JDBC
c)优点
i.面向对象OO
1.全部的对象可以作为参数和返回值
2.All objects can be arguments and return values
ii.可移动性行为mobile behavior
1.类的实现可以被移植
2.The implementations of class can be moved
iii.设计模式design patterns
1.传递性对象确保了面向对象技术的全功率
2.Passing objects ensure the full power of OO techs
iv.安全Secure
1.基于JAVA的安全机制:安全经理
2.Based on JAVA security mechanisms security manager
d)次优点
i.十分容易开发,使用,维护
ii.Easy to write, use and maintain
iii.可以与现存的遗留系统链接can connect with existed legacy system
1.RMI/JNI,RMI/JDBC
iv.开发一次,可以在任何地方运行write once, can be use anywhere
1.100%移植到任何JVM 100%portable to any JVM
v.分布式垃圾收集distributed garbage collection
vi.并行计算parallel computing
1.多线程,并行处理MUTI-thread ,concurrent processing
e)架构architecture
i.存根stub
1.编组参数,发送调用
2.Marshaling arguments, sending invocation
ii.骨骼skeleton
1.解封参数,调用服务器来实现
2.Unmarshaling arguments, invoking server’s implementation
f)RMI的分布式应用
i.定位远程对象locate remote objects
ii.与远程对象通信communicate with remote objects
iii.为被传递的对象加载类定义load definitionof classes that are passed around
g)远程接口,对象和方法remote interface,objectsand methods
i.通过实现一个具有以下特点的远程接口来实现对象远程化An objects
becomesremote by implementing a remote interface with following
characteristics
1.一个远程接口扩展了接口one remote interface extends an interface
a)Java.rmi.remote
2.接口的每一个方法都有事先声明every methods of the interface has
been declared
a)Java.rmi.RemoteException in its throws clause
h)主要步骤main steps
i.定义远程接口define the remote interface
1.指明可以远程调用的方法specifying the methods that can be invoked
remotely
ii.实施远程对象implementing the remote objects
1.可能包括本地接口/方法的实现may include the
implementation of local
interface/method
iii.客户实现implementing the client
1.在远程接口定义后的任何时间都可以被实现can be implemented
anytime when the remote interface has been defined
第三章JMS
a)面向消息中间件MOM
i.在异构平台上发送/接收分布式应用软件/组件之间的消息
ii.Sending/receiving messages between distributed apps/components over the heterogeneous platforms
1.支持异步调用
2.Supporting asynchronous calls
iii.创建一个分布式通信层
iv.Create a distribute communication layer
1.避免应用开发者接触来自不同系统和网络接口的细节
2.Insulating app developers from the details about different OS and
network interfaces
v.在不同平台和网络上的API通常是MOM提供的
vi.The APIS from different platforms and network are provided by MOM
b)比较
i.MOM
1.异步通信
2.Asynchronous communication
3.组件松散耦合
4.Loosely-coupled components
ii.RPC/ORB
1.同步通信
2.Synchronous communication
3.组件紧密耦合
4.Tightly-coupled components
c)MOM 标准
i.历史上,缺乏MOM的准确标准
ii.There was a lack of standards in the history.
iii.高级消息队列协议AMQP
iv.Advanced Message Queuing Protocol
v.数据分发服务DDS
vi.Data Distribution Service
vii.可扩展消息和存在协议XXMP
viii.extensible Messaging and Presence Protocol
ix.Java消息服务的JAVA EE
x.Java Message Service by JAVAEE
1.由大多数MOM供应商实施,旨在隐藏特定的MOM API实现方法
2.Implemented by most MOM vendors and aims to hide the particular
MOM API implementations
d)JavaMessage Service
i.一种JAVA API接口,允许应用程序创建发送接收读取消息
ii. A java API that allows apps to create,send,receive and read messages
iii.定义一组通用接口和关联用语
iv.Defines a set of common interface and associated semantics
v.通过JMS的提供者,力争最大力度的提高JMS应用程序的可移植性
vi.Try the best to improve the portability of JMS apps across JMS providers vii.使得通信变得松散耦合的,异步的,可靠的
viii.Enabling communication that is loosely coupled, asynchronous, and reliable e)当用JMS的时候
i.提供者希望该组件不依赖与其他组件的接口信息,因此组件可以很容易地被替
换
ii.Providers hope the components don’trely on other components’message, so components can be easily replaced iii.提供者希望该应用程序运行时其他组件也同时运行
iv.Providers wants the apps to run whether or not all components are up and running simultaneously
v.应用业务模式允许组件将信息发送到另一个组件,并继续操作而不用即时响应vi.Application business model allows components send message to another components and to continue to operate without receiving an immediate
response
f)信息传递方式
i.点对点传送消息方式Point to point messaging style
1.每个消息都是针对特定队列的
2.Each message is addressed to a specific queue
3.队列将保留所有发送的消息,直到他们被消耗或者过期
4.The queue will retain all the messages that have been sent until they
are consumed or expire.
5.每一条消息都只有一个消费者
6.Every message has one consumer
ii.发布/订阅消息方式Publish/subscribe messaging style
1.客户端可以将信息发到一个主题里
2.The client can send a message to a topic
3.出版社和订阅者可以动态的发布或者订阅主题
4.Publisher and subscriber can dynamically publish or
subscribe to the
topic.
5.当且仅当消息被发送给订阅服务器后,主题才会保留信息
6.Topic will retain the messages only when messages have been sent to
the subscribers
7.每一条信息都可以有多个消费者
8.Each message has multiple consumers
9.当一个客户端创建了一个主题后,另一个订阅了相应主题的客户端才可以
消费已发送的信息,并且消费者必须要保持活跃来消费信息
10.After a client create a topic, another client which has subscribed the
topic can consume messages that have been sent, and the consumer
must continue to be active in order for it to consume messages.
g)消息消费
i.同步Synchronously
1.消费者通过调用消息接收方法来获取消息的目的地
2.Consumer fetches the message from the destination by calling the
receive method
3.如果消息没有在指定时间内到达,该接收方法会阻止消息进入
4.The receive method can block until a message arrives or can time out if
a message dose not arrive within a specified time limit
ii.异步Asynchronously
1.客户端可以注册一个消息监听器
2.The client can register a message listener with a consumer
3.当消息到达目的地时,JMS的提供者通过调用监听器的onMessage方法
来提供信息
4.When message arrives to the destination,the provider of JMS deliver
the message by calling the listener’s onMessage method
h)JMS元素
i.JMS提供者:一个JMS接口的实现
ii.JMS provider: an implementation of the JMS interface
iii.JMS客户端:一个应用或者过程,可以生产/接收消息
iv.JMS client:an application or process that can produce/receive messages v.JMS提供者/出版者:创建/发送消息的客户端
vi.JMS provider/publisher: a client that can create/send messages
vii.JMS消费者:接收消息的客户端
viii.JMS consumer : a client that can receive messages
ix.JMS消息:包含数据的对象,在客户端之间转移
x.JMS message : an object including data and transferred between JMS clients
xi.JMS队列:一个包含着已经被发送出去并且等待被接收的信息(只有一个消费者)中转区
xii.JMS queue: a queue that include messages which have been sent and
waiting to be read
xiii.JMS主题:一个发送信息给多个订阅服务器的初版发行机构
xiv.JMS Topic: a distribution mechanism for publishing messages that are delivered to multiple subscribers
i)JMS应用程序的基本构造块JMS application’s basic building blocks
i.管理对象:连接工厂和目的地
ii.Administered objects: connection factories and destinations
iii.链接
iv.Connections
v.会议
vi.Sessions
vii.消息生产者
viii.Message provider
ix.消息消费者
x.Message consumer
xi.消息
xii.Message
j)JMS信息类型
第四章JDBC
a)Intro
i.一套为了建立JAVA编程语言和更大范围数据库之间独立性数据库连接的标
准JAVA API 接口
b)框架
c)组件
i.DriverManager
ii.Driver
iii.Connection
iv.Statement
v.ResultSet
vi.SQLexception
d)JDBC功能
i.创造一个数据库连接
ii.产生SQL声明
iii.在数据库中执行SQL语句
iv.查看修改产生的记录
e)生成一个简单的JDBC应用
i.导入包
1.导入数据库连接编程需要的JDBC类的包
2.Importjava. Sql .*;
ii.注册JDBCdriver
1.初始化一个driver,来建立一个与数据库联系的通信通道
2.Class.forName(“com.mysql,jdbc,driver”);
iii.打开链接
1.创造一个链接对象,代表着与数据库的物理连接
2.Static final string user = ”username”;
3.Static final string pass = ”password”;
4.Conn=DriverManager.getConnection(DB_er,pass); iv.执行语句
1.为了建造并提交SQL说明给数据库,使用声明或者准备声明
2.Stmt=conn.createStatement();
3.String sql;
4.Sql = “SELECT id, name, hometown FROM t_student”;
5.ResultsSetrs = stmt.executeQuery(sql);
6.对更新,插入,删除进行声明
7.Stmt = conn.createStatement();
8.String sql;
9.Sql = “DELETE FROM t_student where id=1”;
10.Intnum = stmt.executeUpdate(sql);
v.从结果中提取数据
1.用resultSet.getXXX() 从结果中提取数据
vi.清空环境
f)数据类型
g)执行SQL语句
i.发送查询语句给数据库ii.发送更新语句给数据库。