收藏 分享(赏)

Flex 与 J2ee BlazeDS框架译文.doc

上传人:HR专家 文档编号:7510979 上传时间:2019-05-20 格式:DOC 页数:22 大小:237KB
下载 相关 举报
Flex 与 J2ee BlazeDS框架译文.doc_第1页
第1页 / 共22页
Flex 与 J2ee BlazeDS框架译文.doc_第2页
第2页 / 共22页
Flex 与 J2ee BlazeDS框架译文.doc_第3页
第3页 / 共22页
Flex 与 J2ee BlazeDS框架译文.doc_第4页
第4页 / 共22页
Flex 与 J2ee BlazeDS框架译文.doc_第5页
第5页 / 共22页
点击查看更多>>
资源描述

1、Chapter 3: BlazeDS architecture第三章 BlazeDS 结构BlazeDS 客户端结构Flex 组件以下是 Flex 组件与 BlazeDS Server 交互的RemoteObjectHTTPServiceWebServiceProducerConsumer这些组件包含在 Flex SDK 的 rpc.swc 库中虽然 RemoteObject, Producer, and Consumer 组件包含在 SDK 中,但它们需要通过信息传达室送与服务器交互;BlazeDS 和 LiveCycle 两个都是这样服务器,一个 FLEX 应用程序能正确向 HttpSer

2、vice 或 WEB 服务执行远程调用,BlazeDS 与LiveCycle 作为中间层通过 BlazeDS 代理服务利于解决许多问题;客户端组件集合与 BlazeDS Server 通过发送与接收正确类型信息进行运作;传输通道与通道集合A Flex component uses a channel to communicate with a BlazeDS server. A channel set contains channels;Flex组件使用通道与BlazeDS进行通讯,一个通道包含多个渠道集Itsprimary function is to provide connectivit

3、y between the Flex client and the BlazeDS server.它是主要功能提供Flex客户端与BlazeDS进行连接的A channel set containschannels ordered by preference. 一个通道包含多个优先选择排好序的通道集;The Flex component tries to connect to the first channel in the channel set and inthe case where a connection cannot be established falls back to the

4、 next channel in the list. Flex组件常试连接通道集的第一个通道,当一个连接不确定时,跳到通道列表的下一个通道;The Flex componentcontinues to go through the list of channels in the order in which they are specified until a connection can be establishedover one of the channels or the list of channels is exhausted.Flex组件连续通过通道集列表中下达指令,直到确定连接

5、有用,超过一个或整个通道集耗尽Channels encapsulate the connection behavior between the Flex components and the BlazeDS server.Flex组件与BlazeDS Server通过通道集压宿后进行连接Conceptually,channels are a level below the Flex components and they handle the communication between the Flex client and theBlazeDS server. 通道是一个建立在Flex组件之

6、上,它们负责在Flex客户端与BlazeDS Server之前通讯;They communicate with their corresponding endpoints on the BlazeDS server; 它们通讯是通过它们相应设置在BlazeDS Server 的”Endpoints(端点)“for more informationabout endpoints, see “Endpoints” on page 29.更多关于Endpoints信息看“Endpoints” 在29页Flex clients can use different channel types such

7、as the AMFChannel and HTTPChannel. Channel selection dependson a number of factors, Flex客户端可以使用不同的通道类型,像“AMFChannel,HTTPChannel”通道选择取决于若干因素including the type of application you are building. If non-binary data transfer is required,you would use the HTTPChannel, which uses a non-binary format called

8、AMFX (AMF in XML). For more informationabout channels, see “Channels and endpoints” on page 38.如果在应用程不包括二进制数据传达传输,你可以使用“HttpChannel” ,没有二进制传达送的格式叫“AMFX (AMF IN XML) ”更多信息看 “Channels and Endpoints Page 38”Message信息All communication between Flex client components and BlazeDS is performed with messages

9、. 所有通讯通过Flex客户端组件与BlazeDS 通过信息传送执行;Flex components useseveral message types to communicate with their corresponding services in BlazeDS. Flex组件使用多个相应信息类型在BlazeDS中进行通讯.All messages have client-side(ActionScript) implementations and server-side (Java) implementations because the messages are serialize

10、d anddeserialized on both the client and the server. 所有信息有客户端(ActionScript)执行序列化和服务器边的(JAVA)执行反序列化.You can also create messages directly in Java and have those messagesdelivered to clients using the server push API.你可以直接用JAVA创建信息并且将这些信息交负到客户端使用.Some message types, such as AcknowledgeMessage and Comm

11、andMessage, are used across different Flex componentsand BlazeDS services. 一些信息类型,像AcknowledgeMessage and CommandMessage,使用不同的Flex组件和BlazeDS的服务Other message types are used by specific Flex components and BlazeDSservices. 其它信息类型使用指定FLEX组件与BlazeDS服务。Forexample, to have a Producer component send a mess

12、age to subscribed Consumer components, you create a messageof type AsyncMessage and pass it to the send() method of the Producer component.例如,使用一个“Producer”组件发送一条信息认购消费者组件,你创建信息类型为“AsyncMessage”并且将它交给“Producer”组件的 “send()”方法In other situations, you do not write code for constructing and sending mess

13、ages.其它情况,你不必写代码去构建与发送信息;For example, you simply use aRemoteObject component to call the remote method from the Flex application. 例如,你在应用程序中,简单使用”RemoteObject”构成调用远程方法。The RemoteObject componentcreates a RemotingMessage to encapsulate the RemoteObject call. “RemoteObject”组件创建一个远程信息放到压宿包中,RemoteObjec

14、t进行调用。In response it receives an AcknowledgeMessagefrom the server. 服务器回应时,RemoteObject接收 AcknowledgeMessage 信息.The AcknowledgeMessage is encapsulated in a ResultEvent in the Flex application.AcknowledgeMessage信息压宿到ResultEvent事件中。Sometimes you must create a message to send to the server. For example

15、, you could send a message by creating anAsyncMessage and passing it to a Producer.有时候你必需创建信息发送到服务器,例如:你可以发送“AsyncMessage”信息并且通过 “Producer”组件来传送。BlazeDS uses two patterns for sending and receiving messages: the request/reply pattern and the publish/subscribepattern. BlazeDS 使用了两个模式进行发送与接收信息,“request

16、/reply pattern”与 “publish/subscribepattern”请求/应答模式例子:http:/ HTTPService, and WebService components use the request/reply message pattern, in whichthe Flex component makes a request and receives a reply to that request. RemoteObject, HTTPService, and WebService组件使用请求/应答模式进行信息传送,那个组件发送请求,它同时进行接收。Produ

17、cer and Consumer components usethe publish/subscribe message pattern. Producer and Consumer组件使用发布与订阅模式In this pattern, the Producer publishes a message to a destination defined onthe BlazeDS server. All Consumers subscribed to that destination receive the message.这个模式,Producer组件向目的BlazeDS服务器发布信息,所有订

18、阅者在目的地接收信息;BlazeDS server architectureBlazeDS服务器端结构The BlazeDS server is contained in a J2EE web application. BlazeDS服务是包含在J2EE WEB应用程序中。A Flex client makes a request over a channel and therequest is routed to an endpoint on the BlazeDS server. Flex客户端发送一个请求,透过通道发送到BlazeDS Server终点.From the endpoint

19、, the request is routed through a chain ofJava objects that includes the MessageBroker object, a service object, a destination object, and finally an adapterobject.通过”Endpoint”终点,请求发送包含在MessageBroker对像中的Java对像链,一个服务对像,一个目的对像,还有一个适配器对像.The adapter fulfills the request either locally, or by contacting

20、 a backend system or a remote server such asJava Message Service (JMS) server.适配器满足本地请求,或者负责接触后端系统与远程服务,像Java Message Service(JMS)The following illustration shows the BlazeDS server architecture:以下图像显示BlazeDS服务架构:Endpoints终点BlazeDS servlet-based endpoints are inside the J2EE servlet container, which

21、 means that the servlet handles the I/Oand HTTP sessions for the endpoints. BlazeDSservlet-based endpoints 是在J2EE servlet 容器里,servlet负责I/O输入输出与HTTP sessions控制。Servlet-based endpoints are bootstrapped by the MessageBrokerServlet,which is configured in the web.xml file of the web application. Servlet-

22、based endpoints 由MessageBrokerServlet类处理,配置在应用程序的web.xml中.In addition to the MessageBrokerServlet, an HTTPsession listener is registered with the J2EE server in the web applications web.xml file so that BlazeDS has HTTPsession attribute and binding listener support.除了MessageBrokerServlet之外,HTTP sess

23、ion 监听器是登记在J2EE应用程序的web.xml文件,BlazeDS 的session属性可能通过监听器提供BlazeDSFlex client applications use channels to communicate with BlazeDS endpoints. BlazeDS Flex客户端应用程序使用通道来与BlazeDS endpoints进行通信。There is a mapping betweenthe channels on the client and the endpoints on the server. 在客户端与服务器端之间通道是有映射的。It is i

24、mportant that the channel and the endpoint use thesame message format. 通道与终点使用用同样的信息格式它是非常重要的。A channel that uses the AMF message format, such as the AMFChannel, must be paired withan endpoint that also uses the AMF message format, such as the AMFEndpoint.就像AMFChannel使用AMF信息格式的通道,,Endpoint与信息必需是配搭使用

25、AMF格式,如AMFEndpoint.A channel that uses the AMFXmessage format such as the HTTPChannel cannot be paired with an endpoint that uses the AMF message format.就像HTTPChannel使用AMFX信息格式的通道,不能搭配使用AMF格式的endpoint与message.Also, a channel that uses streaming must be paired with an endpoint that uses streaming.同样,

26、一个通道使用流,必需搭配使用流。You configure endpoints in the services-config.xml file in the WEB-INF/flex directory of your BlazeDS web application.你可以在WEB-INF/flex 目录下services-config.xml中配置你的endpointsFor more information about endpoints, see “Channels and endpoints” on page 38.更多信息请查阅38页。MessageBroker消息代理The Mes

27、sageBroker is responsible for routing messages to services and is at the core of BlazeDS on the server.MessageBroker是为信息发送到核心的BlazeDS服务的。Afteran endpoint initially processes the request, it extracts the message from the request and passes it to the Message-Broker. 经过初步端点处理请求,它从请求中提取的信息并将其传递给了消息代理The

28、 MessageBroker inspects the messages destination and passes the message to its intended service. 消息代理会检查信息目的地并且把消息传递到预定的服务.If thedestination is protected by a security constraint, the MessageBroker runs the authentication and authorizationchecks before passing the message along (see “Configuring sec

29、urity” on page 158). 如果目的地受安全保护约束,在信息传递前,消息代理执行授权认可验证, 配置安全设置查阅Page158You configure the MessageBrokerin the services-config.xml file in he WEB-INF/flex directory of your BlazeDS web application.在WEB-INF/flex目录下services-config.xml文件配置MessageBrokerServices and destinations服务与目的地Services and destinatio

30、ns are the next links in the message processing chain in the BlazeDS server. 服务与目的地是BlazeDS服务中下一个连接信息过程链.The systemincludes four services and their corresponding destinationsBlazeDS:系统包含了四个服务与他们相应的通讯目持地RemotingService and RemotingDestinationHTPProxyService and HTTPProxyDestinationMessageService and

31、MessageDestinationServices are the targets of messages from client-side Flex components. 服务目的地是从客户端的Flex组件指定。Think of destinations as instances of a serviceconfigured in a certain way. 作为一个服务配置的情况下,目的地的思考以某种方式.For example, a RemoteObject component is used on the Flex client to communicate withthe Re

32、motingService. 例如,在Flex客户端使用一个RemoteObject组件与远程服务进行通信。In the RemoteObject component, you must specify a destination id property that refers to aremoting destination with certain properties, such as the class you want to invoke methods on. 在RemoteObject组件中,你必需指定指定destination属性,确定远程目的地中某一个属性,像调用某些类的方法

33、。The mappingbetween client-side Flex components and BlazeDS services is as follows:以下列表是客户端组件与BlazeDS服务相应对像。HTTPService and WebService communicate with HTTPProxyService/HTTPProxyDestinationRemoteObject communicates with RemotingService/RemotingDestinationProducer and Consumer communicate with Messag

34、eService/MessageDestinationYou can configure services and their destinations in the services-config.xml file, but it is best practice to put them inseparate files as follows:你可以在services-config.xml文件中配置他们的地址(目的地),但是最好办法是分别在指定文件上配置。如下:RemotingService configured in the remoting-config.xml fileHTTPProx

35、yService configured in the proxy-config.xml fileMessageService configured in the messaging-config.xml fileFor more information on RPC services (HTTPProxy Service and RemotingService) and MessageService, see thefollowing topics:更多关于RPC服务使用请看以下提示:“Using HTTP and web services” on page 73“Using the Remo

36、ting Service” on page 110“Using the Messaging Service” on page 122Adapters and assemblers适配器和装配Adapters, and optionally assemblers, are the last link in the message processing chain. 适配器与选择装配,是最后一个环节的信息处理链When a message arrives at thecorrect destination, it is passed to an adapter that fulfills the

37、request either locally or by contacting a backend systemor a remote server such as a JMS server. 当信息到达正确目的地后,它会传递给适配器执行请求在本地或后台系统或远程服务,像JMS服务一样.BlazeDS uses the following mappings between destinations andadapters/assemblers:以下是BlazeDS的目的地与适配器/装配器之前对应关系.RemotingDestination uses JavaAdapterHTTPProxyDe

38、stination uses HTTPProxyAdapter or SOAPAdapterMessageDestination uses ActionScriptAdapter or JMSAdapterAdapters and assemblers are configured along with their corresponding destinations in the same configuration files.适配器与装配配置是在与之相对应的目的地配文件中。Although the BlazeDS server comes with a rich set of adapt

39、ers and assemblers to communicate with differentsystems, custom adapters and assemblers can be plugged into the BlazeDS server. 虽然BlazeDS服务器伴随着一套装配的适配与不同系统之前通信,自定义的装配适配器能插入BlazeDS服务器Similarly, you do not have to createall destinations in configuration files, but instead you can create them dynamical

40、ly at server startup or when theserver is running; 同样,你不需要在配置文件中创建所有destinations,你可以在服务器开起来或正在运行时动态创建它们。for more information, see “Run-time configuration” on page 174.For information about the BlazeDS server-side classes, see the Javadoc API documentation.About configuration files关于配置文件You configure

41、 BlazeDS in the services-config.xml file. 你通过services-conig.xml配置BlazeDS.The default location of this file is the WEB-INF/flex directoryof your BlazeDS web application. You can set this location in the configuration for the MessageBrokerServlet in theWEB-INF/web.xml file.配置文件默认在BlazeDS应用程序的WEB-INF/f

42、lex目录下,你可以设置MessageBrokerServlet,将这个路径配置在WEB-INF/web.xml文件中。You can include files that contain service definitions by reference in the services-config.xml file. 您可以引入文件,其中包含了在service - config.xml文件中定义的参考咨询服务。Your BlazeDS installationincludes the Remoting Service, Proxy Service, and Message Service b

43、y reference.你的BlazeDS安装包含远程服务,代理服务和消息服务。The following table describes the typical setup of the configuration files. 以下表格描述典型的安装配置文件.Commented versions of these files areavailable in the resources/config directory of the BlazeDS installation.services-config.xml The top-level BlazeDS configuration fil

44、e. This file usually contains security constraint definitions,channel definitions, and logging settings that each of the services can use. It can contain servicedefinitions inline or include them by reference. Generally, the services are defined in theremoting-config.xml, proxy-config.xml, and messa

45、ging-config.xml.最顶层配置文件.这文定义安全约束,通道,日志设定,它可以包含服务定义内联或引用它们,一般,服务定义在remoting-config.xml, proxy-config.xml, and messaging-config.xmlremoting-config.xml The Remoting Service configuration file, which defines Remoting Service destinations forworking with remote objects.For information about configuring t

46、he Remoting Service, see “Using the Remoting Service” onpage 110.定义远程服务对像proxy-config.xml The Proxy Service configuration file, which defines Proxy Service destinations for working withweb services and HTTP services (REST services).For information about configuring the Proxy Service, see “Using HTTP

47、 and web services” onpage 73.代理服务配置文件,定义web services与Http Servicemessaging-config.xml The Messaging Service configuration file, which defines Messaging Service destinations forperforming publish subscribe messaging.For information about configuring the Messaging Service, see “Using the Messaging Ser

48、vice” onpage 122.消息服务配置文件,为发布与订阅服务定义消息服务When you include a file by reference, the content of the referenced file must conform to the appropriate XMLstructure for the service. 当你需要包含引用时,文件内容必需确认是XML结构。The file-path value is relative to the location of the services-config.xml file. The followingexampl

49、e shows service definitions included by reference:文件路径值与services-config.xml相对的,如下:Configuration tokens配置标记The configuration files sometimes contain special server.name and server.port tokens. 配置文件某些时候包含特殊的标记 server.name 和 server.port 标记。These tokens arereplaced with server name and port values based on the URL from which the SWF file is served when it is accessedthrough a web browser from a web server. 这些标记可以替换为浏览器访问的URL,名称与端口值。Similarly, a special context.root token is replaced with t

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报