Flex 与 J2ee BlazeDS框架译文.docx

上传人:b****5 文档编号:7875784 上传时间:2023-01-26 格式:DOCX 页数:40 大小:62.20KB
下载 相关 举报
Flex 与 J2ee BlazeDS框架译文.docx_第1页
第1页 / 共40页
Flex 与 J2ee BlazeDS框架译文.docx_第2页
第2页 / 共40页
Flex 与 J2ee BlazeDS框架译文.docx_第3页
第3页 / 共40页
Flex 与 J2ee BlazeDS框架译文.docx_第4页
第4页 / 共40页
Flex 与 J2ee BlazeDS框架译文.docx_第5页
第5页 / 共40页
点击查看更多>>
下载资源
资源描述

Flex 与 J2ee BlazeDS框架译文.docx

《Flex 与 J2ee BlazeDS框架译文.docx》由会员分享,可在线阅读,更多相关《Flex 与 J2ee BlazeDS框架译文.docx(40页珍藏版)》请在冰豆网上搜索。

Flex 与 J2ee BlazeDS框架译文.docx

Flex与J2eeBlazeDS框架译文

Chapter3:

BlazeDSarchitecture

第三章BlazeDS结构

BlazeDS客户端结构

Flex组件

以下是Flex组件与BlazeDSServer交互的

•RemoteObject

•HTTPService

•WebService

•Producer

•Consumer

这些组件包含在FlexSDK的rpc.swc库中

虽然RemoteObject,Producer,andConsumer组件包含在SDK中,但它们需要通过信息传达室送与服务器交互;

BlazeDS和LiveCycle两个都是这样服务器,一个FLEX应用程序能正确向HttpService或WEB服务执行远程调用,BlazeDS与LiveCycle作为中间层

通过BlazeDS代理服务利于解决许多问题;

客户端组件集合与BlazeDSServer通过发送与接收正确类型信息进行运作;

传输通道与通道集合

AFlexcomponentusesachanneltocommunicatewithaBlazeDSserver.Achannelsetcontainschannels;

Flex组件使用通道与BlazeDS进行通讯,一个通道包含多个渠道集

ItsprimaryfunctionistoprovideconnectivitybetweentheFlexclientandtheBlazeDSserver.

它是主要功能提供Flex客户端与BlazeDS进行连接的

Achannelsetcontains

channelsorderedbypreference.

一个通道包含多个优先选择排好序的通道集;

TheFlexcomponenttriestoconnecttothefirstchannelinthechannelsetandin

thecasewhereaconnectioncannotbeestablishedfallsbacktothenextchannelinthelist.

Flex组件常试连接通道集的第一个通道,当一个连接不确定时,跳到通道列表的下一个通道;

TheFlexcomponent

continuestogothroughthelistofchannelsintheorderinwhichtheyarespecifieduntilaconnectioncanbeestablished

overoneofthechannelsorthelistofchannelsisexhausted.

Flex组件连续通过通道集列表中下达指令,直到确定连接有用,超过一个或整个通道集耗尽

ChannelsencapsulatetheconnectionbehaviorbetweentheFlexcomponentsandtheBlazeDSserver.

Flex组件与BlazeDSServer通过通道集压宿后进行连接

Conceptually,

channelsarealevelbelowtheFlexcomponentsandtheyhandlethecommunicationbetweentheFlexclientandthe

BlazeDSserver.

通道是一个建立在Flex组件之上,它们负责在Flex客户端与BlazeDSServer之前通讯;

 

TheycommunicatewiththeircorrespondingendpointsontheBlazeDSserver;

它们通讯是通过它们相应设置在BlazeDSServer的”Endpoints(端点)“

formoreinformationaboutendpoints,see“Endpoints”onpage29.

更多关于Endpoints信息看“Endpoints”在29页

FlexclientscanusedifferentchanneltypessuchastheAMFChannelandHTTPChannel.Channelselectiondependsonanumberoffactors,

Flex客户端可以使用不同的通道类型,像“AMFChannel,HTTPChannel”通道选择取决于若干因素

includingthetypeofapplicationyouarebuilding.Ifnon-binarydatatransferisrequired,

youwouldusetheHTTPChannel,whichusesanon-binaryformatcalledAMFX(AMFinXML).Formoreinformationaboutchannels,see“Channelsandendpoints”onpage38.

如果在应用程不包括二进制数据传达传输,你可以使用“HttpChannel”,没有二进制传达送的格式叫“AMFX(AMFINXML)”更多信息看“ChannelsandEndpointsPage38”

Message

信息

AllcommunicationbetweenFlexclientcomponentsandBlazeDSisperformedwithmessages.

所有通讯通过Flex客户端组件与BlazeDS通过信息传送执行;

FlexcomponentsuseseveralmessagetypestocommunicatewiththeircorrespondingservicesinBlazeDS.

Flex组件使用多个相应信息类型在BlazeDS中进行通讯.

Allmessageshaveclient-side(ActionScript)implementationsandserver-side(Java)implementationsbecausethemessagesareserializedanddeserializedonboththeclientandtheserver.

所有信息有客户端(ActionScript)执行序列化和服务器边的(JAVA)执行反序列化.

YoucanalsocreatemessagesdirectlyinJavaandhavethosemessages

deliveredtoclientsusingtheserverpushAPI.

你可以直接用JAVA创建信息并且将这些信息交负到客户端使用.

Somemessagetypes,suchasAcknowledgeMessageandCommandMessage,areusedacrossdifferentFlexcomponentsandBlazeDSservices.

一些信息类型,像AcknowledgeMessageandCommandMessage,使用不同的Flex组件和BlazeDS的服务

OthermessagetypesareusedbyspecificFlexcomponentsandBlazeDSservices.

其它信息类型使用指定FLEX组件与BlazeDS服务。

Forexample,tohaveaProducercomponentsendamessagetosubscribedConsumercomponents,youcreateamessageoftypeAsyncMessageandpassittothesend()methodoftheProducercomponent.

例如,使用一个“Producer”组件发送一条信息认购消费者组件,你创建信息类型为“AsyncMessage”并且将它交给“Producer”组件的“send()”方法

 

Inothersituations,youdonotwritecodeforconstructingandsendingmessages.

其它情况,你不必写代码去构建与发送信息;

Forexample,yousimplyuseaRemoteObjectcomponenttocalltheremotemethodfromtheFlexapplication.

例如,你在应用程序中,简单使用”RemoteObject”构成调用远程方法。

TheRemoteObjectcomponentcreatesaRemotingMessagetoencapsulatetheRemoteObjectcall.

“RemoteObject”组件创建一个远程信息放到压宿包中,RemoteObject进行调用。

InresponseitreceivesanAcknowledgeMessagefromtheserver.

服务器回应时,RemoteObject接收AcknowledgeMessage信息.

TheAcknowledgeMessageisencapsulatedinaResultEventintheFlexapplication.

AcknowledgeMessage信息压宿到ResultEvent事件中。

Sometimesyoumustcreateamessagetosendtotheserver.Forexample,youcouldsendamessagebycreatinganAsyncMessageandpassingittoaProducer.

有时候你必需创建信息发送到服务器,例如:

你可以发送“AsyncMessage”信息并且通过“Producer”组件来传送。

 

BlazeDSusestwopatternsforsendingandreceivingmessages:

therequest/replypatternandthepublish/subscribepattern.

BlazeDS使用了两个模式进行发送与接收信息,“request/replypattern”与“publish/subscribepattern”

请求/应答模式例子:

发布/订阅模式

 

RemoteObject,HTTPService,andWebServicecomponentsusetherequest/replymessagepattern,inwhichtheFlexcomponentmakesarequestandreceivesareplytothatrequest.RemoteObject,HTTPService,andWebService组件使用请求/应答模式进行信息传送,那个组件发送请求,它同时进行接收。

ProducerandConsumercomponentsusethepublish/subscribemessagepattern.

ProducerandConsumer组件使用发布与订阅模式

Inthispattern,theProducerpublishesamessagetoadestinationdefinedontheBlazeDSserver.AllConsumerssubscribedtothatdestinationreceivethemessage.

这个模式,Producer组件向目的BlazeDS服务器发布信息,所有订阅者在目的地接收信息;

BlazeDSserverarchitecture

BlazeDS服务器端结构

TheBlazeDSserveriscontainedinaJ2EEwebapplication.

BlazeDS服务是包含在J2EEWEB应用程序中。

AFlexclientmakesarequestoverachannelandtherequestisroutedtoanendpointontheBlazeDSserver.

Flex客户端发送一个请求,透过通道发送到BlazeDSServer终点.

Fromtheendpoint,therequestisroutedthroughachainofJavaobjectsthatincludestheMessageBrokerobject,aserviceobject,adestinationobject,andfinallyanadapter

object.

通过”Endpoint”终点,请求发送包含在MessageBroker对像中的Java对像链,一个服务对像,一个目的对像,还有一个适配器对像.

Theadapterfulfillstherequesteitherlocally,orbycontactingabackendsystemoraremoteserversuchasJavaMessageService(JMS)server.

适配器满足本地请求,或者负责接触后端系统与远程服务,像JavaMessageService(JMS)

 

ThefollowingillustrationshowstheBlazeDSserverarchitecture:

以下图像显示BlazeDS服务架构:

Endpoints

终点

BlazeDSservlet-basedendpointsareinsidetheJ2EEservletcontainer,whichmeansthattheservlethandlestheI/OandHTTPsessionsfortheendpoints.

BlazeDSservlet-basedendpoints是在J2EEservlet容器里,servlet负责I/O输入输出与HTTPsessions控制。

Servlet-basedendpointsarebootstrappedbytheMessageBrokerServlet,whichisconfiguredintheweb.xmlfileofthewebapplication.

Servlet-basedendpoints由MessageBrokerServlet类处理,配置在应用程序的web.xml中.

InadditiontotheMessageBrokerServlet,anHTTPsessionlistenerisregisteredwiththeJ2EEserverinthewebapplication’sweb.xmlfilesothatBlazeDShasHTTPsessionattributeandbindinglistenersupport.

除了MessageBrokerServlet之外,HTTPsession监听器是登记在J2EE应用程序的web.xml文件,BlazeDS的session属性可能通过监听器提供

BlazeDSFlexclientapplicationsusechannelstocommunicatewithBlazeDSendpoints.

BlazeDSFlex客户端应用程序使用通道来与BlazeDSendpoints进行通信。

Thereisamappingbetweenthechannelsontheclientandtheendpointsontheserver.

在客户端与服务器端之间通道是有映射的。

Itisimportantthatthechannelandtheendpointusethesamemessageformat.

通道与终点使用用同样的信息格式它是非常重要的。

AchannelthatusestheAMFmessageformat,suchastheAMFChannel,mustbepairedwith

anendpointthatalsousestheAMFmessageformat,suchastheAMFEndpoint.

就像AMFChannel使用AMF信息格式的通道,,Endpoint与信息必需是配搭使用AMF格式,如AMFEndpoint.

AchannelthatusestheAMFXmessageformatsuchastheHTTPChannelcannotbepairedwithanendpointthatusestheAMFmessageformat.

就像HTTPChannel使用AMFX信息格式的通道,不能搭配使用AMF格式的endpoint与message.

Also,achannelthatusesstreamingmustbepairedwithanendpointthatusesstreaming.

同样,一个通道使用流,必需搭配使用流。

Youconfigureendpointsintheservices-config.xmlfileintheWEB-INF/flexdirectoryofyourBlazeDSwebapplication.

你可以在WEB-INF/flex目录下services-config.xml中配置你的endpoints

Formoreinformationaboutendpoints,see“Channelsandendpoints”onpage38.

更多信息请查阅38页。

MessageBroker

消息代理

TheMessageBrokerisresponsibleforroutingmessagestoservicesandisatthecoreofBlazeDSontheserver.

MessageBroker是为信息发送到核心的BlazeDS服务的。

Afteranendpointinitiallyprocessestherequest,itextractsthemessagefromtherequestandpassesittotheMessage-Broker.

经过初步端点处理请求,它从请求中提取的信息并将其传递给了消息代理

TheMessageBrokerinspectsthemessage'sdestinationandpassesthemessagetoitsintendedservice.

消息代理会检查信息目的地并且把消息传递到预定的服务.

Ifthedestinationisprotectedbyasecurityconstraint,theMessageBrokerrunstheauthenticationandauthorizationchecksbeforepassingthemessagealong(see“Configuringsecurity”onpage158).

如果目的地受安全保护约束,在信息传递前,消息代理执行授权认可验证,配置安全设置查阅Page158

YouconfiguretheMessageBrokerintheservices-config.xmlfileinheWEB-INF/flexdirectoryofyourBlazeDSwebapplication.

在WEB-INF/flex目录下services-config.xml文件配置MessageBroker

Servicesanddestinations

服务与目的地

ServicesanddestinationsarethenextlinksinthemessageprocessingchainintheBlazeDSserver.

服务与目的地是BlazeDS服务中下一个连接信息过程链.

ThesystemincludesfourservicesandtheircorrespondingdestinationsBlazeDS:

系统包含了四个服务与他们相应的通讯目持地

•RemotingServiceandRemotingDestination

•HTPProxyServiceandHTTPProxyDestination

•MessageServiceandMessageDestination

Servicesarethetargetsofmessagesfromclient-sideFlexcomponents.

服务目的地是从客户端的Flex组件指定。

Thinkofdestinationsasinstancesofaserviceconfiguredinacertainway.

作为一个服务配置的情况下,目的地的思考以某种方式.

Forexample,aRemoteObjectcomponentisusedontheFlexclienttocommunicatewiththeRemotingService.

例如,在Flex客户端使用一个RemoteObject组件与远程服务进行通信。

IntheRemoteObjectcomponent,youmustspecifyadestinationidpropertythatreferstoaremotingdestinationwithcertainproperties,suchastheclassyouwanttoinvokemethodson.

在Rem

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

当前位置:首页 > 高等教育 > 工学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1