计算机系 Java EE 外文翻译 外文文献 英文文献Word下载.docx
《计算机系 Java EE 外文翻译 外文文献 英文文献Word下载.docx》由会员分享,可在线阅读,更多相关《计算机系 Java EE 外文翻译 外文文献 英文文献Word下载.docx(15页珍藏版)》请在冰豆网上搜索。
(5)AnoverviewofhowtobuildFlexapplicationsusingevents,states,MXMLcomponents,andmodules.
(6)AnintroductiontodevelopingaFlexapplicationwithreal-timeserverdatapush.
(7)Howtoboostproductivitydevelopingdata-intensiveapplicationsusingtheDataManagementserviceinLiveCycleDataServices.
(8)AnoverviewofmodeldrivendevelopmentusingFlashBuilderandLiveCycleDataServicestogenerateclientandserver-sidecode.
(9)HowtodeployaFlexapplicationonaportalserver.
(10)BesuretoalsowatchthevideoIntroductiontoFlex4andJavaintegration.
(11)Tolearnmoreaboutthetechnologiesusedtobuildtheseapplications,readThetechnologiesforbuildingFlexandJavaapplicationsarticle.
Client/serverarchitecture
FlexandJavaapplicationsuseamulti-tierarchitecturewherethepresentationtieristheFlexapplication,thebusinessorapplicationtieristheJavaEEserverandcode,andthedatatieristhedatabase.Youcanwritetheback-endcodejustasyounormallywouldforaJavaapplication,modelingyourobjects,definingyourdatabase,usinganobject-relationalframeworksuchasHibernateorEJB3,andwritingthebusinesslogictoqueryandmanipulatetheseobjects.ThebusinesstiermustbeexposedforaccessviaHTTPfromtheFlexapplicationandwillbeusedtomovethedatabetweenthepresentationanddatatiers.
TypicalHTMLapplicationsconsistofmultiplepagesandasausernavigatesbetweenthem,theapplicationdatamustbepassedalongsotheapplicationitself(thecollectionofpagesandfunctionalityitconsistsof)canmaintainstate.Incontrast,Flexapplications,bynature,arestateful.AFlexapplicationisembeddedinasingleHTMLpagethattheuserdoesnotleaveandisrenderedbyFlashPlayer.TheFlexapplicationcandynamicallychangeviewsandsendandretrievedataasynchronouslytotheserverinthebackground,updatingbutneverleavingthesingleapplicationinterface(seeFigure1)(similartothefunctionalityprovidedbytheXMLHttpRequestAPIwithJavaScript.)
Figure1.Theclient/serverarchitecture.
Client/servercommunication
Flexapplicationscancommunicatewithback-endserversusingeitherdirectsocketconnectionsormorecommonly,throughHTTP.TheFlexframeworkhasthreeremoteprocedurecallAPIsthatcommunicatewithaserveroverHTTP:
HTTPService,WebService,andRemoteObject.AllthreewrapFlashPlayer'
sHTTPconnectivity,whichinturn,usesthebrowser'
sHTTPlibrary.Flexapplicationscannotconnectdirectlytoaremotedatabase.
YouuseHTTPServicetomakeHTTPrequeststoJSPorXMLfiles,toRESTfulwebservices,ortootherserverfilesthatreturntextoverHTTP.YouspecifytheendpointURL,listenerfunctions(thecallbackfunctionstobeinvokedwhentheHTTPServicerequestreturnsasuccessfulorunsuccessfulresponse),andadatatypeforthereturneddata(whattypeofdatastructureitshouldbetranslatedintooncereceivedintheFlexapplication).YoucanspecifythedatatobehandledasrawtextandassignedtoaStringvariableorconvertedtoXML,E4X,orplainoldActionScriptobjects.IfyougetbackJSON,youcanusetheAdobeFlexcorelibpackageofclassestodeserializetheJSONobjectsintoActionScriptobjects.TomakecallstoSOAPbasedwebservices,youcanusetheHTTPServiceAPIorthemorespecializedWebServiceAPI,whichautomaticallyhandlestheserializationanddeserializationofSOAPformattedtexttoActionScriptdatatypesandviceversa.
ThethirdoptionformakingremoteprocedurecallsistousetheRemoteObjectAPI.ItmakesaFlashRemotingrequesttoamethodofaserver-sideJavaclassthatreturnsbinaryActionMessageFormatoverHTTP.Whenpossible,useFlashRemotingwhosebinarydatatransferformatenablesapplicationstoloaddataupto10timesfasterthanwiththemoreverbose,text-basedformatssuchasXML,JSON,orSOAP(seeFigure2).ToseeacomparisonofAMFtoothertext-basedserializationtechnologies,seeJamesWard'
sCensusRIABenchmarkapplication.
Figure2.MethodsforconnectingFlexandJava.
FlashRemoting
FlashRemotingisacombinationofclientandserver-sidefunctionalitythattogetherprovidesacall-and-responsemodelforaccessingserver-sideobjectsfromFlashPlatformapplicationsasiftheywerelocalobjects.ItprovidestransparentdatatransferbetweenActionScriptandserver-sidedatatypes,handlingtheserializationintoActionMessageFormat(AMF),deserialization,anddatamarshalingbetweentheclientandtheserver.
FlashRemotingusesclient-sidefunctionalitybuiltintoFlashPlayerandserver-sidefunctionalitythatisbuiltintosomeservers(likeColdFusionandZend)butmustbeinstalledonotherservers(asBlazeDSorLiveCycleDataServicesonJavaEEservers,WebORBorFluorineFXon.NETservers,theZendframeworkoramfphponPHPservers,andmore).SeethetechnologiesforbuildingFlexandJavaapplicationsarticleformoredetailsaboutBlazeDSandLiveCycleDataServices.
BlazeDSandLiveCycleDataServicesuseamessage-basedframeworktosenddatabackandforthbetweentheclientandserver.TheyprovideRemoting,Proxying,andMessagingservices,andforLiveCycle,anadditionalDataManagementservice.TheFlexapplicationsendsarequesttotheserverandtherequestisroutedtoanendpointontheserver.Fromtheendpoint,therequestispassedtotheMessageBroker,theBlazeDSandLiveCycleDataServicesenginethathandlesalltherequestsandroutesthemthroughachainofJavaobjectstothedestination,theJavaclasswiththemethodtoinvoke(seeFigure3).
Figure3.FlashRemotingarchitecture.
AMF
AMFisabinaryformatusedtoserializeActionScriptobjectsandfacilitatedataexchangebetweenFlashPlatformapplicationsandremoteservicesovertheInternet.Adobepublishesthisprotocol;
thelatestisAMF3SpecificationforActionScript3.YoucanfindtableslistingthedatatypemappingswhenconvertingfromActionScripttoJavaandJavatoActionScripthere.
Forcustomorstronglytypedobjects,publicproperties(includingthosedefinedwithgetandsetmethods)areserializedandsentfromtheFlexapplicationtotheserverorfromtheservertotheFlexapplicationaspropertiesofageneral0bject.Toenablemappingbetweenthecorrespondingclientandserver-sideobjects,youusethesamepropertynamesintheJavaandActionScriptclassesandthenintheActionScriptclass,youusethe[RemoteClass]metadatatagtocreateanActionScriptobjectthatmapsdirectlytotheJavaobject.
HereisanexampleEmployeeActionScriptclassthatmapstoaserver-sideEmployeeJavaDTOlocatedintheservicespackageontheserver.
packagevalueobjects.Employee{[Bindable][RemoteClass(alias="
services.Employee"
)]publicclassEmployee{publicvarid:
int;
publicvarfirstName:
String;
publicvarlastName:
(...)}}
InstallingBlazeDSorLiveCycleDataServices
TouseFlashRemotingwithBlazeDSorLiveCycleDataServices,youneedtoinstallandconfigurethenecessaryserver-sidefiles.ForBlazeDS,youcandownloaditasaWARfilewhichyoudeployasawebapplicationorasaturnkeysolution.Theturnkeydownloadcontainsaready-to-useversionofTomcatinwhichthetheBlazeDSWARfilehasalreadybeendeployedandconfiguredalongwithavarietyofsampleapplications.Similarly,forLiveCycleDataServices,theinstallerletsyouchoosetoinstallLiveCyclewithanintegratedTomcatserverorasaLiveCycleDataServiceswebapplication.
Ineitherscenarioawebapplicationcalledblazedsorlcds(usuallyappendedbyaversionnumber)iscreated.YoucanmodifyandbuildoutthisapplicationwithyourJavacode,ormoretypically,youcancopytheJARfilesandconfigurationfilestheblazedsorlcdswebapplicationcontainsandaddthemtoanexistingJavawebapplicationontheserver(seeFigure4).
Figure4.TherequiredBlazeDSorLiveCycleDataServicesfiles.
Modifyingweb.xml
Ifcopyingthefilestoadifferentwebapplication,youalsoneedtomodifytheweb.xmlfiletodefineasessionlistenerforHttpFlexSessionandaservletmappingforMessageBroker,whichhandlesalltherequestsandpassesthemofftothecorrectserver-sideJavaendpoints.Youcancopyandpastethesefromtheoriginalblazedsorlcdswebapplicationweb.xmlfile.
<
!
--HttpFlexSessionattributeandbindinglistenersupport-->
<
listener>
listener-class>
flex.messaging.HttpFlexSession<
/listener-class>
/listener>
--MessageBrokerServlet-->
servlet>
servlet-name>
MessageBrokerServlet<
/servlet-name>
display-name>
/display-name>
servlet-class>
flex.messaging.MessageBrokerServlet<
/servlet-class>
init-param>
param-name>
services.configuration.file<
/param-name>
param-value>
/WEB-INF/flex/services-config.xml<
/param-value>
/init-param>
load-on-startup>
1<
/load-on-startup>
/servlet>
servlet-mapping>
url-pattern>
/messagebroker/*<
/url-pattern>
/servlet-mapping>
Optionally,youmayalsowanttocopyandpaste(anduncomment)themappingforRDSDispatchServlet,which