




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
0外文原文HotelReservationSystemBasedontheJavaServerFacesTechnologyThispaperdescribesimplementationofaweb-basedhotelreservationsystemwhichenablesuserstobookhotelroomsbymeansofawebbrowser.ThesystemisbasedonJavaServerFacestechnologyinthepresentationlayer,SpringFrameworkintheservicelayerandiBatislibraryforthedataaccesslayer.I.INTRODUCTIONTheHotelReservationSystemisaspecifictypeofsoftwarethatsupports,oftenbymeansofawebbrowser,wholeinfrastructureofthehotelforwhichthesystemhasbeendeployed.Itskeyfeaturesarelistedbelow:Tosearchandtobookhotelrooms.Tonotifyofeveryeventrelatedtoauserbysendingtheemailonagivenaddressduringtheregistrationprocess.Tosupportdefinitionprocessofeachcomponentofthehotel.Thecomponentsofthehotelare:rooms,promotions,packages,discountsandservices.Tocompletethereservationprocessbynotifyingthesystemaboutthefactthattheguestcametothehotelandreceivedkeystothebookedroom.II.JAVASERVERFACESTheusergraphicalinterfaceisacrucialpartofeverycomputerprogrammewithregardtoitsresponsibilityforinteractionwiththeusers.Thispartofapplicationshouldbeflexible,whichmeanssusceptibletoanyneededchangesandwithoutanydoubts,userfriendly.Regrettably,processofdevelopingsuchuserinterfaceinthemainrequiresusuallyaprofusionofdevelopersworkandtime,makingthewholedevelopmentprocessinvolvedandonerous.ThemostaptingtechnologytothisfieldisJavaServerFaces(JSF).Thisholistic,component-basedsolutionforlongstandingproblemsfacingsoftwaredevelopershasaspecificgoal:tomakewebdevelopmentfasterandeasierbymaskingalotofcomplexitieshiddenbehindthiskindofprogramming.JSFtechnologyisaserver-sideuserinterfaceframeworkforJavatechnology-basedwebapplications.ThemaincomponentsofJSF1technologyareasfollows:TwoJavaServerPagescustomtagslibraryforexpressingUIcomponentswithinaJSPpageandforwiringcomponentstoserver-sideobjects.TheuserinterfacecreatedwithJSFtechnology(representedbymyUIontheFig.1)runsontheserverandrendersbacktotheclient(inthiscasethebrowser).Becauseweb-basedapplications,mustoftenappeasemultipleclients(suchasdesktopbrowsers,cellphones,andPDAs),JSFhasapowerfularchitecturefordisplayingcomponentsindifferentways.Asforthebrowsers,forwhichJSFismostlyused,thedefaultrenderingtechnologyisHTML4.0,thoughtheotherslikeWMLorSVGarealsopossible.OneofthegreatestadvantagesofJSFtechnologyisthatitoffersacleanseparationbetweenbehaviorandpresentationlayers.III.SPRINGFRAMEWORKSpringisalightweight,inversionofcontrolcontainer,createdtoaddressthecomplexityofenterpriseapplicationdevelopment.SpringmakespossibletouseplainJavaBeanstoachievethingsthatwerepreviouslyonlypossiblewithEJBs10,11.AnyJavaapplicationcanbenefitfromSpringintermsofsimplicity,test-ability,andloosecoupling.TheSpringFrameworkcontainsalotoffeatures,whicharewell-organizedinsevenmodules.Whentakenasawhole,thesemodulesgiveeverythingthatisneededtodevelopenterpriseapplications,althoughthereisnomusttobuildtheapplicationfullyontheSpringframework.Onecanpickandchooseonlythosemodulesthatsuitbesttotheapplicationandignoretherest.ThisstrategywaschosenfortheHotelReservationSystemSinceoneofthecorevaluepropositionsoftheframeworkisthatofenablingchoicebynotforcingonetoapplyanyparticulararchitecture,technologyormethodology,Springalsoprovidesconvenientmechanismsforintegrationwithnumberofthird-partyframeworks(alsowithJSFandiBatis).IV.APACHEIBATISDATAMAPPERApacheiBatisJDBCbasedDataMapperprovidessimpleandflexiblewaytotransportdatabetweenrelationaldatabaseandJava,.NetorRubyapplication.ContrarytopopularHibernatelibrary,iBatisdoesnotdirectlytieclassestotablesorfieldstocolumns,butinstead,itcouplesobjectswithresultsofstoredproceduresorSQLstatementsusingsimple2XMLdescriptorlettingthedevelopertoreachonlyforrequireddata.TheiBatisframeworkcanmapnearlyanydatabasetoanyobjectmodelandisverytolerantoflegacydesigns,orevenbaddesigns.SimplicityisthemainadvantageoftheiBatisoverotherframeworks.TheHotelReservationSystemwasprimarilybuiltuponJSFtechnologyfortheuserinterfacealongwithauxiliarylibrariesSpringandiBatis.TheapplicationarchitectureispresentedinFig.3.Thecompositionofthesystemismodular.Eachlayerisseparatedwithandappropriateinterfacelayer.Suchsolutionmakesthearchitecturenotonlymoreerror-resistantbutalsomoreflexibleforchanges.ThepresentationlayerconsistsofthegraphicaluserinterfacewrittenintheJSFtechnologyandunderlyingbackingbeansobjects.ItcommunicateswiththeServicelayerthroughtheserviceinterfaces.Servicelayeristhecentralbusinesspartofthesystemwhere,onthebasisoftheuserinputdata,properdecisionsaremade.ItalsotranslatesinputdataintoexplicitformunderstoodfortheDataaccesslayer,withwhichcommunicationtakesplacebymeansofDataaccessinterfacelayer.TheDataaccesslayercooperateswithDataMapperlayerandisresponsiblefordataexchangewithdatabase.TheDataMapperlayertalksviaJDBCtodatabasetoaskrequireddata.ThisisalayerwhereiBatisDataMapperplaysthemainrole.V.JSF-SPRINGINTEGRATIONInanutshell,JSFSpringintegrationmakesSpringmanagedbeansvisibleasvariablestoJSF,justasiftheSpringbeansareconfiguredasJSFmanagedbeans.BeforedivingintotheintegrationspecificsofJavaServerFaces,thegeneralintegrationstepforanywebframeworkmustbesetforth.Allthatneedtobedone,istodeclareContextLoaderListenerinthestandardJEEservletweb.xmldeploymentdescriptor.ThislistenerinitializestheSpringsWebApplicationContextthatcontainsallofthebusinessbeansintheapplication.(Fig.4).ThesecondstepintheintegrationbetweenSpringandJSFisspecificjustforJSF.ThekeyclassusedinthisprocessisDelegatingVariableResolver.Toconfigurethisvariablethefaces-context.xmlfilemustbeedited.AfteropeningtagtagmustbeaddedandwithinitthepointingtotheSpringsDelegatingVariableResolvermustbeput.Theexamplefaces-config.xmlfileispresentedin.TheDelegatingVariableResolverdelegatesvaluelookupstothedefaultresolverofthe3underlyingJSFimplementation,andthengoingtotheSpringsbusinesscontextWebApplicationContext.ThisallowstoeasilyinjectdependenciesintoonesJSF-managedbeans.Exampleoffaces-config.xmlfilefromHotelRVI.JSFANDGETMETHOD.TheJSFonlyrecommendedmethodforsendinginputdatafromanonlineformtoanapplicationserveristhePOSTmethod,thoughsometimesthereisastrongneedforusetheGETmethodinstead.IntheHotelReservationSystemtheGETmethodisusedduringtheregistrationprocessforbringingaboutuseraccountactivation.ThecommonwaytoimplementtheGETmethodistocreateaspecialfilterwhichcanmanipulatetheheaderorcontents(orboth)ofarequestorresponse.ToputGETmethodintooperation,incaseofJavaServerFaces,thefollowingalgorithmmustbefulfilledinthebodyofthefilter:1.Getparametersfromtherequest.2.Createappropriatebackingbeanobjectaccordinglytotheviewthatwillbeusedfurther.3.Storethebackingbeanobjectinthecurrentsession.4.SetchangedJSFcontextascurrent.5.CreateviewandstoreitintheJSFcontext.6.Executebackingbeansmethods.TheHotelReservationSystemwasalsobasedontheSpringlibrary,hencesomechangestotherawalgorithmwerenecessary.TheforemostmethodforanyfilterisdoFilter()wheretheproperfiltrationhappens.publicvoiddoFilter(ServletRequestrequest,ServletResponseresponse,FilterChainchain)throwsIOException,ServletExceptionFacesContextfacesContext=getFacesContext(request,response);if(facesContext!=null)request.getRequestDispatcher(4facesContext.getViewRoot().getViewId().forward(request,response);elsechain.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);Creatingbackingbeanobjectandsettingspringoriginproperty.GettingSpringmanaged-beanobjectrequiresoperatingonSpringsWebApplicationContextobjectthatisinitialisedduringtheserverstart-up.SetchangedJSFescontextascurrent.WhenstoringbackingbeanobjectinthesessionthewholeFacescontextbecomeschanged,thereforeitmustbesetascurrentinorderallmodificationstakeplace.FacesContextFactorycontextFactory=(FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);LifecycleFactorylifecycleFactory=(LifecycleFactory)FactoryFinder.5getFactory(FactoryFinder.LIFECYCLE_FACTORY);Lifecyclelifecycle=lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);facesContext=contextFactory.getFacesContext(servletContext,req,res,lifecycle);ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext);SettingJSFcontextascurrentBeforetheactualsettingcontextintocurrent,itisindispensabletograbLifecycleobject.LifecyclemanagestheprocessingoftheentirelifecycleofaparticularJSFrequest.ItisresponsibleforexecutingallofthephasesthathavebeendefinedbytheJSFspecification,inthespecifiedorder,unlessotherwisedirectedbyactivitiesthatoccurredduringtheexecutionofeachphase.AninstanceofLifecycleiscreatedbycallingthegetLifecycle()methodofLifecycleFactory,foraspecifiedlifecycleidentifier.Becausethisinstanceissharedacrossmultiplesimultaneousrequests,itmustbeimplementedinathread-safemanner.UsingthecurrentLifecycleobjectalongwithServletContext,HttpServletReqestandHttpServletResponseobjectstheFacesContextcanbeupdatedandbecomesuptodate.CreateviewandstoreitintheJSFcontext.AftermakingFacescontextactual,thenewviewissupposedtobecreatedandaddedtothiscontext,neverthelessitisnotpossibletodoitwithusageofnewoperator,insteadithastobedoneinanindirectmanner.UIViewRootview=facesContext.getApplication().getViewHandler().createView(facesContext,/confirm/register.jsp);facesContext.setViewRoot(view);6CreatingnewviewandstroingitinFacescontextThecreateView()methodofViewHandlerobjectconstructsandreturnanewUIViewRootinstanceinitializedwithinformationfromtheargumentFacesContextandviewId.TheviewedparameterisalwaysStringvariablerepresenting(relativeto/WEB-INF/directory)pathwherethedefinitionfileislocated.AsshowninFig.9thedefinitionoftheviewisplacedinordinaryJSPfileandislocatedinsubdirectoryofaWEB-INFdirectory.ExecutingbackingbeansmethodsThelaststepistheactualexecutionofmethodsoftheunderlying,propertocreatedviewbackingbeanobject.ThisexampleofthefilterfortheGETmethodwasbasedupononeusedintheHotelReservationSystem,whichworksasaregistrationconfirmationtool,sointheend,themethodofresponsibilityforthehotelmanagementconfirmationwouldbeandshouldbeinvoked:confirmBean.confirmRegistration(userId);VII.CONCLUSIONSTheHotelReservationSystemisdevelopedapplicationdesignedaccordinglytothemodernprogrammingtrendswithusageoftechnologieslikeJavaServerFaces,SpringFrameworkandiBatisDataMapper.Itsmodulararchitecturemakestheapplicationmoreerror-resistantandflexibleforanychangesthereforeeasytoaddnewfunctionality.ThecommonproblemofsendinginputdatathroughtheGETmethodhasalsobeensolved.Systemiseasytoinstallanduseandthethreemodulecompositionputswork-divisionpatternintooperation.ThisresearchwassupportedbytheTechnicalUniversityofLodzGrantK-25/1/2007/Dz.St.7中文翻译基于JavaServerFaces技术的酒店预订系统本文介绍了基于网络的酒店预订系统如何利用JavaServerFaces技术和Spring框架访问系统通过Web浏览器为用户预定酒店客房。一引言酒店预订系统是一个支持特定类型功能的软件,往往通过Web浏览器作为承载手段。其主要特点为寻找并发送一个在登记过程中给定的地址的电子邮件来预订酒店相应的房间。为了支持各酒店的组件定义的过程。酒店的组成部分是:房间,促销,包装,折扣,完成的通知等有关的事实,客人来到酒店,并收到钥匙,以及房间预订系统预订的过程。二JavaServerFaces图形用户界面是每一个计算机程序的关键部分,其承载与用户的交互的责任。这应该是灵活的应用程序的一部分,这意味着容易因用户需求产生更改,但是无疑的可以增加用户友的好性。令人遗憾的是,发展中的主要过程需要好的用户界面,通常造成的是开发人员的工作和时间泛滥,并且使整个开发过程涉及JavaServerFaces(JSF)这一领域的技术。这种整体的,基于构件的,软件开发人员所面临的长期问题的解决有一个具体的目标:使网站发展速度和复杂性掩盖了很多种类的技术。JSF技术更容易隐藏的是一个服务器的端用户对基于Java技术的Web应用程序界面框架。JSF的技术的主要组成部分如下:以UI组件为代表的并且管理他们,处理事件,执行服务器交互和数据转换,定义页面导航,支持国际和普及,并为所有这些功能提供扩可展性的技术支持。两个JavaServerPages定制标记库在JSP页面表示UI组件和布线组件的服务器端的用户界面与JSF技术在服务器上运行,并返回客户端(在这种情况下浏览器)由于基于Web的应用程序。如桌面浏览器,手机和PDA(多个客户端),JSF的已经以不同的方式展示了强大的组件体系结构。至于浏览器,因为它主要用于JSF,默认的渲染技术是HTML4.0,尽管像其他的WML或SVG也有可能。JSF技术的最大优势之一是,它提供了一个干净的分离行为层和表示层和表示层的架构。三Spring框架Spring是一个轻量级,控制反转容器,它的创建解决了企业应用发展.Spring的复杂性使得可以使用普通的JavaBeans实现的东西,以前只可能与EJB的相关联。任何Java应用程序能够受益于Spring,简单来说,测试能力和松散的耦合。当作为一个整体,这些模块提供的一切需要发展的企业来进行应用,虽然不一定要有充分的构建Spring框架的应用程序。人们可以从中挑选适合的模块,只有那些最好的应用,而忽略其他方面。这一战略是为酒店预订系统选择了自构框架的核心价值主张之一,并且是社会的选择方向,没有强迫任何一个适用于特定的架构,技术或方法,Spring还提供了与第三个数字一体化的便利机制-框架(也与JSF和iBatis)。四iBATISDataMapper的APACHEiBatis的JDBC在apache-数据库和Java基于数据映射器提供了简单和灵活的运输方式之间的关系,.Net或Ruby应用程序的数据。与流行的Hibernate库,8iBatis的并没有直接配合,以表或列或字段,而是,它的存储过程或使用简单的XML描述符开始的开发,以达到对所需数据的应用。产生只有SQL语句的结果对象。iBatis的框架几乎任何数据库可以映射到任何对象模型,是非常传统的设计,甚至坏designs.Simplicity宽容,是与其他框架相比iBatis的主要优点。酒店预订系统,主要是建立基于JSF技术的同时辅助库,Spring与iBATIS的用户界面。应用程序体系结构,该系统的组成模块。每一层和适当的分隔与界面层。这种解决方案不仅能降低更多的错误发生可能性,也能产生更灵活的变化。表示层组成的图形用户在JSF支持bean对象技术编写的界面。它传达的是在那里,对用户输入数据的基础上,适当的决定是系统的核心业务的一部分,通过服务层。这也意味着为数据访问层明确了解的形式,而沟通需要通过数据访问接口是指数据访问层与数据输入数据映射层进行合作,并与数据库上进行数据交换的数据映射层负责通过JDBC数据库谈判要求所需的数据。这是一个在iBatis的数据映射层起着主要作用。五JSF的Spring集成概括地说,JSF的spring的整合使Spring管理类在JSF变量可见,就像spring为JSF管理beans到JavaServerFaces,任何Web框架综合集成一体化的具体步骤,必须配置forth.All需要做的事,是标准的J2EEservlet的ContextLoaderListener的web.xml部署文件。这个监听器初始化Spring的WebApplicationContext的,它包含所有在应用程序的业务类。在spring和JSF之间的整合只是第二个步骤是具体为JSF。课堂上使用的关键在这个过程中。要配置这个变量在faces-context.xml文件必须被编辑。开幕后标签指向Spring的DelegatingVariable分解必须付诸表决。这个例子的faces-config.xml文件。代表们的值查找到相关的JSF实现的默认解析器,然后到Spring的业务范围内的WebApplicationContext。这使得很容易注入一的JSF管理的bean依赖关系。示例的faces-config.xml文件从酒店冗余接点JSF只建议应用的一个利用表格获取输入数据到应用服务器的方法是POST方法,虽然有时也有一种强烈的
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年湖南省娄底市涟源市中考三模语文试题(含解析)
- 2025年苏州中考道德与法治考前最后一卷(含答案)
- 福建省宁德市2024-2025学年高三上学期12月联考物理试题(解析版)
- 农业科技产业园市场需求分析与资源配置
- java面试题及答案内存过高
- 2025贷款担保合同范本
- 2025共同经营合同范本
- 2025超市货架租赁合同
- 个人债权授权委托书范文
- 2024年西昌民族幼儿师范高等专科学校辅导员考试真题
- 《防雷接地基础知识》课件
- 北师大版七年级数学上册教材同步课后习题答案
- 个人诚信承诺书模板(共4篇)
- 供水公司自来水厂隐患排查和风险分级管控管理制度
- 1+X工业网络运维资格考试题及答案
- 《乘风破浪扬帆起航》高三主题班会 高中主题班会
- 职业技术学院森林和草原资源保护专业人才培养方案(三年制)
- 理解当代中国阅读与写作学习通超星期末考试答案章节答案2024年
- 附着式升降脚手架维护保养管理制度
- 安徽省宣城市2024-2025学年高二地理下学期期末考试试题含解析
- 购买牦牛合同范本
评论
0/150
提交评论