1、Flex 与 J2ee BlazeDS框架译文Chapter 3: BlazeDS architecture第三章 BlazeDS 结构BlazeDS客户端结构Flex组件以下是Flex组件与BlazeDS Server 交互的 RemoteObject HTTPService WebService Producer Consumer这些组件包含在Flex SDK 的 rpc.swc 库中虽然RemoteObject, Producer, and Consumer 组件包含在SDK中,但它们需要通过信息传达室送与服务器交互;BlazeDS和LiveCycle两个都是这样服务器,一个FLEX应用
2、程序能正确向HttpService 或 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进行通讯,一个通道包含多个渠道集 Its primary function is to provide con
3、nectivity 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 ba
4、ck to the 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. 通道是一个建
6、立在Flex组件之上,它们负责在Flex客户端与BlazeDS Server之前通讯;They communicate with their corresponding endpoints on the BlazeDS server; 它们通讯是通过它们相应设置在BlazeDS Server 的”Endpoints(端点)“for more information about endpoints, see “Endpoints” on page 29.更多关于Endpoints信息看“Endpoints” 在29页Flex clients can use different channel t
7、ypes such as the AMFChannel and HTTPChannel. Channel selection depends on 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 for
8、mat called AMFX (AMF in XML). For more information about 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 wit
9、h messages. 所有通讯通过Flex客户端组件与BlazeDS 通过信息传送执行;Flex components use several 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 ar
10、e serialized and deserialized 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 AcknowledgeMess
11、age and CommandMessage, are used across different Flex components and BlazeDS services. 一些信息类型,像AcknowledgeMessage and CommandMessage,使用不同的Flex组件和BlazeDS的服务Other message types are used by specific Flex components and BlazeDSservices. 其它信息类型使用指定FLEX组件与BlazeDS服务。For example, to have a Producer compone
12、nt send a message to subscribed Consumer components, you create a message of 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 a
13、nd sending messages.其它情况,你不必写代码去构建与发送信息; For example, you simply use a RemoteObject component to call the remote method from the Flex application. 例如,你在应用程序中,简单使用”RemoteObject”构成调用远程方法。The RemoteObject component creates a RemotingMessage to encapsulate the RemoteObject call. “RemoteObject”组件创建一个远程信息
14、放到压宿包中,RemoteObject进行调用。In response it receives an AcknowledgeMessage from 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
15、server. For example, you could send a message by creating an AsyncMessage and passing it to a Producer.有时候你必需创建信息发送到服务器,例如:你可以发送“AsyncMessage”信息并且通过 “Producer”组件来传送。BlazeDS uses two patterns for sending and receiving messages: the request/reply pattern and the publish/subscribe pattern. BlazeDS 使用了两
16、个模式进行发送与接收信息,“request/reply pattern”与 “publish/subscribe pattern”请求/应答模式例子: 发布/订阅模式RemoteObject, HTTPService, and WebService components use the request/reply message pattern, in which the Flex component makes a request and receives a reply to that request. RemoteObject, HTTPService, and WebService组件
17、使用请求/应答模式进行信息传送,那个组件发送请求,它同时进行接收。Producer and Consumer components use the publish/subscribe message pattern. Producer and Consumer组件使用发布与订阅模式In this pattern, the Producer publishes a message to a destination defined on the BlazeDS server. All Consumers subscribed to that destination receive the mess
18、age.这个模式,Producer组件向目的BlazeDS服务器发布信息,所有订阅者在目的地接收信息;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 the request is routed to an endpoint on the BlazeDS server. Flex客户端发送一个请求,
19、透过通道发送到BlazeDS Server终点.From the endpoint, the request is routed through a chain of Java objects that includes the MessageBroker object, a service object, a destination object, and finally an adapterobject.通过”Endpoint”终点,请求发送包含在MessageBroker对像中的Java对像链,一个服务对像,一个目的对像,还有一个适配器对像.The adapter fulfills th
20、e request either locally, or by contacting a backend system or a remote server such as Java Message Service (JMS) server.适配器满足本地请求,或者负责接触后端系统与远程服务,像Java Message Service(JMS)The following illustration shows the BlazeDS server architecture:以下图像显示BlazeDS服务架构:Endpoints终点BlazeDS servlet-based endpoints a
21、re inside the J2EE servlet container, which means that the servlet handles the I/O and HTTP sessions for the endpoints. BlazeDS servlet-based endpoints 是在J2EE servlet 容器里, servlet负责I/O输入输出与HTTP sessions控制。Servlet-based endpoints are bootstrapped by the MessageBrokerServlet,which is configured in the
22、 web.xml file of the web application. Servlet-based endpoints 由MessageBrokerServlet类处理,配置在应用程序的web.xml中.In addition to the MessageBrokerServlet, an HTTP session listener is registered with the J2EE server in the web applications web.xml file so that BlazeDS has HTTP session attribute and binding lis
23、tener support.除了MessageBrokerServlet之外,HTTP session 监听器是登记在J2EE应用程序的web.xml文件,BlazeDS 的session属性可能通过监听器提供BlazeDS Flex client applications use channels to communicate with BlazeDS endpoints. BlazeDS Flex客户端应用程序使用通道来与BlazeDS endpoints进行通信。There is a mapping between the channels on the client and the e
24、ndpoints on the server. 在客户端与服务器端之间通道是有映射的。It is important that the channel and the endpoint use the same 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 AMFEn
25、dpoint.就像AMFChannel使用AMF信息格式的通道,, Endpoint与信息必需是配搭使用AMF格式,如AMFEndpoint. A channel that uses the AMFX message 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 m
26、ust be paired with an endpoint that uses streaming.同样,一个通道使用流,必需搭配使用流。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 end
27、points” on page 38.更多信息请查阅38页。MessageBroker消息代理The MessageBroker is responsible for routing messages to services and is at the core of BlazeDS on the server.MessageBroker是为信息发送到核心的BlazeDS服务的。After an endpoint initially processes the request, it extracts the message from the request and passes it to
28、the Message-Broker. 经过初步端点处理请求,它从请求中提取的信息并将其传递给了消息代理The MessageBroker inspects the messages destination and passes the message to its intended service. 消息代理会检查信息目的地并且把消息传递到预定的服务.If the destination is protected by a security constraint, the MessageBroker runs the authentication and authorization chec
29、ks before passing the message along (see “Configuring security” on page 158). 如果目的地受安全保护约束,在信息传递前,消息代理执行授权认可验证, 配置安全设置查阅Page158You configure the MessageBroker in the services-config.xml file in he WEB-INF/flex directory of your BlazeDS web application.在WEB-INF/flex目录下services-config.xml文件配置MessageBr
30、okerServices and destinations服务与目的地Services and destinations are the next links in the message processing chain in the BlazeDS server. 服务与目的地是BlazeDS服务中下一个连接信息过程链.The system includes four services and their corresponding destinations BlazeDS:系统包含了四个服务与他们相应的通讯目持地 RemotingService and RemotingDestinati
31、on HTPProxyService and HTTPProxyDestination MessageService and MessageDestinationServices are the targets of messages from client-side Flex components. 服务目的地是从客户端的Flex组件指定。Think of destinations as instances of a service configured in a certain way. 作为一个服务配置的情况下,目的地的思考以某种方式.For example, a RemoteObjec
32、t component is used on the Flex client to communicate with the RemotingService. 例如,在Flex客户端使用一个RemoteObject组件与远程服务进行通信。In the RemoteObject component, you must specify a destination id property that refers to a remoting destination with certain properties, such as the class you want to invoke methods on. 在Rem
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1