外文翻译基于JavaServer Faces技术的酒店预订系统Word文档下载推荐.docx
《外文翻译基于JavaServer Faces技术的酒店预订系统Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《外文翻译基于JavaServer Faces技术的酒店预订系统Word文档下载推荐.docx(8页珍藏版)》请在冰豆网上搜索。
Tosearchandtobookhotelrooms.Tonotifyofeveryeventrelatedtoauserbysendingtheemailonagivenaddressduringtheregistrationprocess.
Tosupportdefinitionprocessofeachcomponentofthehotel.Thecomponentsofthehotelare:
rooms,promotions,packages,discountsandservices.Tocompletethereservationprocessbynotifyingthesystemaboutthefactthattheguestcametothehotelandreceivedkeystothebookedroom.
II.JAVASERVERFACES
Theusergraphicalinterfaceisacrucialpartofeverycomputerprogrammewithregardtoitsresponsibilityforinteractionwiththeusers.Thispartofapplicationshouldbeflexible,whichmeanssusceptibletoanyneededchangesandwithoutanydoubts,user–friendly.Regrettably,processofdevelopingsuchuserinterfaceinthemainrequiresusuallyaprofusionofdeveloper'
sworkandtime,makingthewholedevelopmentprocessinvolvedandonerous.ThemostaptingtechnologytothisfieldisJavaServerFaces(JSF).Thisholistic,component-basedsolutionforlongstandingproblemsfacingsoftwaredevelopershasaspecificgoal:
tomakewebdevelopmentfasterandeasierbymaskingalotofcomplexitieshiddenbehindthiskindofprogramming.JSFtechnologyisaserver-sideuserinterfaceframeworkforJavatechnology-basedwebapplications.ThemaincomponentsofJSFtechnologyareasfollows:
TwoJavaServerPagescustomtagslibraryforexpressingUIcomponentswithinaJSPpageandforwiringcomponentstoserver-sideobjects.TheuserinterfacecreatedwithJSFtechnology(representedbymyUIontheFig.1)runsontheserverandrendersbacktotheclient(inthiscasethebrowser).Becauseweb-basedapplications,mustoftenappeasemultipleclients(suchasdesktopbrowsers,cellphones,andPDAs),JSFhasapowerfularchitecturefordisplayingcomponentsindifferentways.Asforthebrowsers,forwhichJSFismostlyused,thedefaultrenderingtechnologyisHTML4.0,thoughtheotherslikeWMLorSVGarealsopossible.OneofthegreatestadvantagesofJSFtechnologyisthatitoffersacleanseparationbetweenbehaviorandpresentationlayers.
III.SPRINGFRAMEWORK
Springisalightweight,inversionofcontrolcontainer,createdtoaddressthecomplexityofenterpriseapplicationdevelopment.SpringmakespossibletouseplainJavaBeanstoachievethingsthatwerepreviouslyonlypossiblewithEJBs[10,11].AnyJavaapplicationcanbenefitfromSpringintermsofsimplicity,test-ability,andloosecoupling.TheSpringFrameworkcontainsalotoffeatures,whicharewell-organizedinsevenmodules.
Whentakenasawhole,thesemodulesgiveeverythingthatisneededtodevelopenterpriseapplications,althoughthereisnomusttobuildtheapplicationfullyontheSpringframework.Onecanpickandchooseonlythosemodulesthatsuitbesttotheapplicationandignoretherest.ThisstrategywaschosenfortheHotelReservationSystemSinceoneofthecorevaluepropositionsoftheframeworkisthatofenablingchoicebynotforcingonetoapplyanyparticulararchitecture,technologyormethodology,Springalsoprovidesconvenientmechanismsforintegrationwithnumberofthird-partyframeworks(alsowithJSFandiBatis).
IV.APACHEIBATISDATAMAPPER
ApacheiBatisJDBC–basedDataMapperprovidessimpleandflexiblewaytotransportdatabetweenrelationaldatabaseandJava,.NetorRubyapplication.ContrarytopopularHibernatelibrary,iBatisdoesnotdirectlytieclassestotablesorfieldstocolumns,butinstead,itcouplesobjectswithresultsofstoredproceduresorSQLstatementsusingsimpleXMLdescriptorlettingthedevelopertoreachonlyforrequireddata.TheiBatisframeworkcanmapnearlyanydatabasetoanyobjectmodelandisverytolerantoflegacydesigns,orevenbaddesigns.SimplicityisthemainadvantageoftheiBatisoverotherframeworks.
TheHotelReservationSystemwasprimarilybuiltuponJSFtechnologyfortheuserinterfacealongwithauxiliarylibraries–SpringandiBatis.TheapplicationarchitectureispresentedinFig.3.Thecompositionofthesystemismodular.Eachlayerisseparatedwithandappropriateinterfacelayer.Suchsolutionmakesthearchitecturenotonlymoreerror-resistantbutalsomoreflexibleforchanges.ThepresentationlayerconsistsofthegraphicaluserinterfacewrittenintheJSFtechnologyandunderlyingbackingbeansobjects.ItcommunicateswiththeServicelayerthroughtheserviceinterfaces.Servicelayeristhecentralbusinesspartofthesystemwhere,onthebasisoftheuserinputdata,properdecisionsaremade.ItalsotranslatesinputdataintoexplicitformunderstoodfortheDataaccesslayer,withwhichcommunicationtakesplacebymeansofDataaccessinterfacelayer.TheDataaccesslayercooperateswithDataMapperlayerandisresponsiblefordataexchangewithdatabase.TheDataMapperlayertalksviaJDBCtodatabasetoaskrequireddata.ThisisalayerwhereiBatisDataMapperplaysthemainrole.
V.JSF-SPRINGINTEGRATION
Inanutshell,JSF–SpringintegrationmakesSpringmanagedbeansvisibleasvariablestoJSF,justasiftheSpringbeansareconfiguredasJSFmanagedbeans.BeforedivingintotheintegrationspecificsofJavaServerFaces,thegeneralintegrationstepforanywebframeworkmustbesetforth.Allthatneedtobedone,istodeclareContextLoaderListenerinthestandardJEEservletweb.xmldeploymentdescriptor.ThislistenerinitializestheSpring'
sWebApplicationContextthatcontainsallofthebusinessbeansintheapplication.(Fig.4).ThesecondstepintheintegrationbetweenSpringandJSFisspecificjustforJSF.ThekeyclassusedinthisprocessisDelegatingVariableResolver.Toconfigurethisvariablethefaces-context.xmlfilemustbeedited.Afteropening<
faces-config>
tag<
application>
tagmustbeaddedandwithinitthe<
variable-resolver>
pointingtotheSpring'
sDelegatingVariableResolvermustbeput.Theexamplefaces-config.xmlfileispresentedin.TheDelegatingVariableResolverdelegatesvaluelookupstothedefaultresolveroftheunderlyingJSFimplementation,andthentoSpring'
sbusinesscontextWebApplicationContext.Thisallowstoeasilyinjectdependenciesintoone'
sJSF-managedbeans.
Exampleoffaces-config.xmlfilefromHotelRVI.JSFANDGETMETHOD.TheJSFonlyrecommendedmethodforsendinginputdatafromanonlineformtoanapplicationserveristhePOSTmethod,thoughsometimesthereisastrongneedforusetheGETmethodinstead.IntheHotelReservationSystemtheGETmethodisusedduringtheregistrationprocessforbringingaboutuseraccountactivation.ThecommonwaytoimplementtheGETmethodistocreateaspecialfilterwhichcanmanipulatetheheaderorcontents(orboth)ofarequestorresponse.ToputGETmethodintooperation,incaseofJavaServerFaces,thefollowingalgorithmmustbefulfilledinthebodyofthefilter:
1.Getparametersfromtherequest.
2.Createappropriatebackingbeanobjectaccordinglytothe
viewthatwillbeusedfurther.
3.Storethebackingbeanobjectinthecurrentsession.
4.SetchangedJSFcontextascurrent.
5.CreateviewandstoreitintheJSFcontext.
6.Executebackingbeansmethods.
TheHotelReservationSystemwasalsobasedontheSpringlibrary,hencesomechangestotherawalgorithmwerenecessary.TheforemostmethodforanyfilterisdoFilter()wheretheproperfiltrationhappens.
publicvoiddoFilter(ServletRequestrequest,
ServletResponseresponse,
FilterChainchain)throwsIOException,
ServletException{
FacesContextfacesContext=
getFacesContext(request,response);
if(facesContext!
=null){
request.getRequestDispatcher(
facesContext.getViewRoot().getViewId()).
forward(request,response);
}else{
chain.doFilter(request,response);
}
ThedoFiltermethodfromGETfilterimplementationAsitmaybeseenonFig.6,anadditionalfunctionimplementingthepresentedalgorithmwasusedtokeepthesourcecodeclearandeasy-to-read.Createappropriatebackingbeanobject.AlmostallbackingbeansfromHotelReservationSystemhaveatleastonepropertyofSpringmanaged-beanorigin.Becauseofthat,itisnecessarytosetthispropertyafterbackingbeanobjectcreation.
WebApplicationContextwac=WebApplicationContextUtils.
getRequiredWebApplicationContext
(servletContext);
RegisterServiceregisterService=
(RegisterService)
wac.getBean("
registerService"
);
ConfirmBeanconfirmBean=newConfirmBean();
confirmBean.
setRegisterService(registerService);
Creatingbackingbeanobjectandsettingspring–originproperty.GettingSpringmanaged-beanobjectrequiresoperatingonSpring'
sWebApplicationContextobjectthatisinitialisedduringtheserverstart-up.SetchangedJSFescontextascurrent.WhenstoringbackingbeanobjectinthesessionthewholeFacescontextbecomeschanged,thereforeitmustbesetascurrentinorderallmodificationstakeplace.
FacesContextFactorycontextFactory=(FacesContextFactory)
FactoryFinder.getFactory(
FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactorylifecycleFactory=(LifecycleFactory)FactoryFinder.
getFactory(FactoryFinder.
LIFECYCLE_FACTORY);
Lifecyclelifecycle=lifecycleFactory.
getLifecycle(LifecycleFactory.
DEFAULT_LIFECYCL