Tải bản đầy đủ - 0 (trang)
Lesson 19. Introducing Adobe Flex Data Services

Lesson 19. Introducing Adobe Flex Data Services

Tải bản đầy đủ - 0trang

Lesson19/complete/proxy-config.xml

Lesson19/complete/TfsDataServices.mxml

FlexDataServices(FDS)istheJ2EEserversoftwarethat

enablesyoutoaccessandsynchronizedataacrossoneormore

applicationsbuiltwithFlexframework.Inthislesson,youwill

learnaboutFDSanditsconfiguration.YouwillinstallFDSand

buildasimpleapplicationthatcanbeusedwithFDSand

understandtheservercompilationprocessaswellassomeof

thefeaturesofFDS.

ThedifferentpiecesoftheAdobeFlexDataServicesand

howtheycanintegratewiththeenterprise



IntroducingFlexDataServices(FDS)

FDSenablesyoutocreatereal-time,data-drivenapplications

thathavebeenbuiltwiththeFlexframework.FDSitselfisa

server-sideJavaapplicationthatisdesignedtoworkwithmost

Javaapplicationservers,includingJRun,JBoss,WebLogic,

WebSphere,Oracle10g,andTomcat.Therearefourdifferent

partstoFDS,whichincludethefollowing:

FlexMessageService(FMS)

FlexDataManagementService

FlexProxyService(FPS)

RemotingService

FollowingisadiagramoftheFDSbasicarchitectureandan

explanationofthefunctionalityofthedifferentelements:



TheFlexMessageService(FMS)enablesyoutobuild

applicationsthatsupportreal-timechatandcollaboration.A

clientapplicationinFlashPlayerusesaclient-sideAPItosend

andreceivemessagesfromaserver-sidedestination.Messages

aresentviaaspecialprotocol.Youcanbuildapplicationsthat

allowcollaboration,suchasAdobeBreeze,whichenablesthe



synchronizationofdesktops.UsingtheFMS,youalsocanpush

dataoutfromtheserver.Forexample,usingFMS,youcould

buildanapplicationthatupdatessportsscoresorstockdataon

thefly.TheapplicationdatainFlashPlayerwouldupdate

whenevertheserver-sidedatachanged.

TheFlexDataManagementServiceprovidestoolsformanaging

distributeddatainFlexapplications.Theserviceconsistsof

bothserver-andclient-sidecomponents.Ontheserverside,

thereareadaptorsforcommondatapersistenceframeworks.

Ontheclientside,therearecomponentsthatautomate

synchronizationofanapplication'sclientandservertiers.You

canusetheDataManagementServicetocreateapplications

thatmightbeoccasionallyconnected,aswellasperforming

datasynchronizationandreplication.Youcanmanagelargesets

ofdatabypagingthroughthatdata.UsingtheData

ManagementService,youcanalsomanagenesteddata

relationshipssuchasone-to-oneandone-to-many

relationships.

Forsecurityreasons,aFlexapplicationisnotpermittedto

accessdatafromanotherdomainunlessacross-domain

securityfilehasbeeninstalledonthatremoteserver.TheFlex

ProxyService(FPS)isdesignedtoovercomethesandbox

securityrestrictionsofFlashPlayerwhenyoutrytoretrieve

dataorotherassetsatruntimefromremoteservers.TheProxy

ServicerelaysHTTPandwebservicerequestsfromtheFlex

applicationinFlashPlayertotheserverthatishostingthe

remoteservice.Thecommunicationwiththeremoteservernow

occursfromFDSinsteadofFlashPlayer.Thismeansthatwhen

youusetheserver-sideproxy,thesecuritysandboxerrorwill

nolongerappear.

RemotingServiceissimilartowebservice,butcommunication

betweentheapplicationandtheserverisdoneinAction

MessageFormat(AMF),whichisabinaryformatthatisfaster

thanatextualprotocolsuchasSOAPorXML.Javaclassesthat

areusedasremoteobjectsarehostedbyanapplicationserver



thatiscompatiblewithversion3oftheAMFprotocol.FDScan

hostPlainoldJavaobjects(POJOs)aswellasColdFusion7

applicationsbuiltwithColdFusioncomponents.

YoucaninstallFDSonanintegratedJRunserverorasaJ2EE

webapplication.YoushouldusetheintegratedJRunserveronly

fortestingbecauseitisnotdesignedforproduction

environments.Forproductionenvironments,youcanselectthe

J2EEwebapplicationoptiontocreateaninstallable.warfile,

whichcanthenbedeployedonaJ2EEserver.

FDSusesadirectorystructurethatfollowsthestandardmodel

forallJ2EEwebapplications.Theapplicationrootisknownin

J2EEasthecontextroot;underthisdirectory,thereisaWEBINFsubdirectorythatcontainsallthedirectoriesandfilesthat

configurethebehaviorofaJ2EEwebapplication.Inthislesson,

youwillinstalltheFDSandlearnaboutthecapabilitiesby

buildingasimpleapplication.

FlexprojectsbuiltwithFDShavetheaddedbenefitofbeing

abletogenerateorcompileSWFfilesontheserver.Upuntil

now,alltheSWFfilesyouhavecreatedhavebeencompiledon

theclientbydefaultinadirectorycalledbin.FDShasthe

capabilitytogenerateSWFfilesdynamicallybasedonabrowser

request.ThebrowserwillrequestaSWFfilefromFDS,anddata

services(ontheserver)willgenerateaSWFfilealongwiththe

requiredHTMLandJavaScriptcodethatwilldetectFlashPlayer.

TheserverwillthensendthegeneratedSWFbacktotheclient.

AftertheSWFfilehasbeengenerated,itwillbecachedinthe

servermemory.Theprocesslooksasshowninthefollowing

example:



ItisalsopossibletoconfigureFDStocompileanapplication

locally.ThecompiledFlexapplicationdoesnotneedtoresidein

therootdirectoryofFDS.However,theapplicationmustbe

deliveredtothewebbrowserfromawebrootdirectorythatis

inthesamedomainastheinstallationoftheFDS.Whenyou

buildaprojectinFlexBuilder,thereisanoptionforchoosing

localcompilationofthefile.Also,youcanusethecommandlinecompiler(mxmlc)tocompiletheapplication,whichis

includedwithFDS.

WithFDS,youhaveaverypowerfulwaytoincreasethe

personalizationandcustomizationofyourapplications.Using

FDS,youcancreateapplicationsthatcancommunicateeven

moreefficientlywithFlashPlayer,resultinginabestofbreedrichInternetapplication.TheRemotingServicespeedsupdata

transferusingtheAMFprotocol,themessagingservicecan

pushdatafromtheserverintoFlashPlayer.TheFlexData

ManagementServiceenablesyoutoefficientlysynchronizedata

betweentheclientandtheserver.TheFPSsolvesthesecurity

sandboxissuesthatmighthavefrustratedyouupuntilthis

point.FDSwillrunonavarietyofindustry-standardJ2EE

applicationserverssotheycanfitintomanyproduction

environmentsandoffersolutionsforallapplications.



InstallingtheAdobeFDS

Inthistask,youwillinstalltheFDSontheAdobeJRunserver.

1. InstallFDSwiththeintegratedJRunserveroptionusingall

thedefaultsettings.DoubleclicktheFlexDataServices

installationfile,FDS-win2.exe.



[Viewfullsizeimage]



Acceptthelicenseagreement.Specifywhichbrowserto

installtheFlashplayerinto.FDS,runningonastand-alone

JRunserver,enablesyoutohaveaccesstoallthedata

services.

2. OpenWindowsExplorer(orifyouareworkingonanother

operatingsystem,anytypeoffilemanagementutility)and

navigatetotheFlexcontextroot.Thedefaultdirectory

locationfortheWindowsinstallationisthefollowing:



c:\fds2\jrun4\servers\default\flex

Thispathreferstotheapplicationroot,alsoknownasthe

contextroot,whichiswhereallthefilesyouwilluseforthe

dataservicesareinstalled.Notethatunderneaththis

directory,thereisasubdirectorycalledWEB-INF,which

containsallthedirectoriesandfilesthatconfigurethe

behaviorofaJ2EEwebapplication.AdobeFlexData

ServicesisavailableforWindows2000Server,WindowsXP

professionalServer2003,RedHatEnterpriseServer4or

theSUSELinuxenterpriseserverfromNovell.

3. OpentheWEB-INFdirectorywithinthecontextrootand

examinethefilesinthisdirectory.

Theweb.xmlfilecontainsinstructionsforprocessing

requestsfromtheFlexclientapplication.Theflex

subdirectorycontainsalllibrariesandconfigurationfiles

requiredbyFDS,andtheclassessubdirectoryisthe

preferredlocationforcompiledJavaclassesthatwillbe

calledbytheFDSatruntime.Thereisalsoalib

subdirectory,whichisthepreferredlocationforJARfiles

thatcontaincompiledJavaclassesthatwillbecalledbythe

FDSatruntime.

4. OpenacommandwindowbyclickingtheWindowsStart

menu.SelecttheRunoption,entercmd,andclickOK.

Becauseyouinstalledthestand-aloneversionofJRun,you

muststarttheservertousetheFDS.Inthefirststep,you

installedtheFDSasanapplicationratherthanaservice,

whichmeansyoumustkeepthecommandwindowopento

keeptheserverrunning.

5. Stillinthecommandwindow,switchtothebinsubdirectory

oftheintegratedJRunserverbyusingthechangedirectory.



Entercd/fds2/jrun4/binattheprompt.Thebin

directoryisunderthedataservicesroot,andthisiswhere

youstarttheFDSservice.

6. Enterthiscommand:

jrun-startdefault

YoushouldseetheJRunserverstartinthecommand

window.FDSisnowreadytouse.







CreatingaFlexBuilderProjectwithFDS

Inthistask,youwillcreateanewFlexprojectinFlexBuilder

thatwillusetheFDS.Youwillalsocreateasimpleapplication

andbrowseandcompilethatapplication.

1. OpenFlexBuilder2andbesurethatFDSisrunning.From

themenu,chooseFile>New>FlexProject.SelectFlex

DataServices.Also,selecttheCompileapplicationonthe

serverwhenthepageisviewedradiobutton.



ThiswillsetupaprojectthatusestheFDSandgeneratethe

SWFfilesontheserverwhenthepageisviewedinsteadof

compilingtheSWFfilesontheclient.Thisoffersmany

advantagesforcustomizationandpersonalizationof

applications.Inaddition,theFDSserverhasthecapability



tocachetheseSWFfilesforlateruse.

2. ClickNext.UnchecktheUsedefaultlocationforlocalFlex

DataServicesservercheckboxandselectthefollowing

locationastheFlexcontextrootyouwanttouseforyour

Flexproject:

c:\fds2\jrun4\servers\default\flex



TheFlexdevelopmentserverlocationdefaultstothe

integratedserver'sFlexcontextroot.Ifyouwanttousea

differentcontextroot,uncheckthedefaultlocationoption

andmaketheappropriatechanges.

3. ClickNext,assigntheprojectanameofTfsDataServices,

andleaveallthedefaults.

ThiscreatesanewfolderunderneaththeFDScontextroot



withthenameofTfsDataServices.AnewMXMLfilethatwill

serveasyourapplicationrootisalsocreated,againwiththe

nameofTfsDataServices.Ofcourse,youcanchangeall

thesenamesbyuncheckingtheUsedefaultlocationcheck

box.



4. ClickFinish,andnotethe[sourcepath]user_classesfolder

aswellasthehtml-templatefolder,andtheflex-config.xml

thathavebeencreatedforyou.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Lesson 19. Introducing Adobe Flex Data Services

Tải bản đầy đủ ngay(0 tr)

×