外文翻译-基于S2SH 的Web应用程序框架的设计和实现_第1页
外文翻译-基于S2SH 的Web应用程序框架的设计和实现_第2页
外文翻译-基于S2SH 的Web应用程序框架的设计和实现_第3页
外文翻译-基于S2SH 的Web应用程序框架的设计和实现_第4页
外文翻译-基于S2SH 的Web应用程序框架的设计和实现_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

外文原文DesignandImplementationofWebApplicationFrameworkBasedonS2SAbstractAsingleframeworkhassomeproblemsinbuildingenterpriseapplication,suchaslowefficiencyofsystemdevelopment,poorexpansibility,highcouplingbetweenlayersandcomplexstructure,etc.Aimingattheseproblems,awebapplicationframeworkbasedonStrut2,SpringandHibernate(S2SH)isputforward.BymakinguseofthecompletenessofStruts2inthepresentationlayer,theflexibilityofSpringinbusinessmanagementandthematurityofHibernateinthepersistencelayer,itreallyachievesloosecouplingbetweenlayersandeasymaintenance,simultaneouslyreducesthedifficultyofdevelopmentamongthethreepartsandappliestheframeworktothedevelopmentofarmyfundsmanagementsystem.Keywords:Struts2framework;Springframework;Hibernateframework;WebapplicationI.INTRODUCTIONWebapplicationdevelopmentdemandsgenerallytobedividedintopagedisplay,businesslogicanddataoperationinordertoachieveloosecouplingbetweenthem,whichhelpsreducethecostofdevelopmentteamandthedifficultyofdevelopment1.Tomeettherequirement,traditionalwebapplicationproposedalayeredarchitecture,which,tocertainextent,reducedthedegreeofcouplingbetweenthethree,butdidnotrealizethetruesenseofthelooselycoupled.Besides,itsdifficulttoachievethefunctionsofthethreebyusingtraditionaltechnology2.Sotosolvetheseproblems,lotsofframeworksbasedonJ2EEareemerging.Amongthem,Struts2,SpringandHibernatehavealreadybeentothemainstreamofthecurrentwebapplicationdevelopment.However,theyareonlyaframeworkincertainlayerofwebapplicationandnotcompletewebapplicationarchitecture.Totheend,thispaperconductedastudyonStruts2,SpringandHibernateframeworksandputforwardanapplicationframeworkintegratedtheS2SHframeworks,besides,theintegrationprocessoftheapplicationframeworkisdiscussedinthepaper.Finally,thepapertakesarmyfundsmanagementsystemforexampletoillustratetheimplementationofvariouscomponentsoftheapplicationframework.II.BRIEFINTRODUCTIONOFS2SHFRAMEWORKStruct2isanew,morescalableMVCframeworkonthebasisoftheintegrationStructs1andWebWork3,MVCdesignpatternconsistsofthreeparts:Model,ViewandController.ModelisusedtoimplementbusinesslogicusuallyachievedbyJavaBeans,ViewisusedtointeractwithusersusuallyachievedbyJSPpages,andControllerisusedtoimplementbusinesslogicprocesscontrolmainlyachievedbythecorecontrollerofStructs2FilterDispatcherandAction.Thecorecontrollerinterceptstheclientsrequest,ittransmitstherequesttoappropriateActionobjectaccordingtotheStructs2configurationfile,andthenitassemblesViewbytheresultsofAction(Resultobjects),Structs2workflowisshowninFigure1.Inaddition,Structs2providesarichtaglibrary(Taglib),whichsimplifiesthedevelopmentofJSPpagesandreducesthedifficultyofsystemdevelopment4.Figure1.Struts2workflowSpringisanexcellentlightweightframework,whichprovidesacontainerofInversionofControl(IoC)andAspectOrientedProgramming(AOP)tosolvemanycommonproblemsinJ2EEdevelopment5.Springcaneffectivelyorganizethebusinesslogiclayerobject,seamlesslyintegratewithotherframeworksandprovideanunifiedinterfacefordifferentdataaccesstechnologies;Besides,SpringeasilyachievetheassemblyofbeancomponentsandtheloosecouplingbetweendifferentlayersbyIoC6;Whatsmore,makinguseofAOPimplementstransactionmanagement,meanwhile,simplifiestheoperationofitsservices.HibernateisapersistencelayerexcellentORMframework.ItisabridgebetweenJavaapplicationanddatabase,mappingsbetweenJavaobjectsanddatabasetablesarecreatedbywritingtheobject-relationalmappingfiles,anditprovidesalotofmethodsthatencapsulatedataaccessoperationstogreatlyreducethetimeofthemanualwritingSQLandJDBCtoprocessdataaccess7-8.Moreimportant,HibernatehasalightweightobjectencapsulationforJDBCtoreducethecomplexityofthepersistencelayer,whichmakesdeveloperspaymoreattentiontothebusinesslogicofapplicationsystemratherthantheunderlyingdatastructure.Simultaneously,Hibernateachievestheobject-orientedofrelationaldatabasetofacilitatetheunificationofdevelopmentthinking.Figure2showthestructureofHibernateframework.Figure2.ThestructureofHibernateframeworkIII.THEDESIGNOFTHEINTEGRATIONOFS2SHFRAMEWORKAccordingtotheintroductionoftheS2SHtechnicalframeworks,inordertoachievethecompleteseparationofthepagedisplay,businesslogicanddataprocessinginthewebapplicationdevelopment,traditionalJ2EEapplication9isre-dividedintothepresentationlayer,businesslogicandpersistencelayer,eachlayerhasitsownprocessinglogic.Inordertoachievetheisolationbetweenlayersandthecentralizedprocessingofthelogiclayers,Struts2,SpringandHibernateframeworksareimportedinthewebhierarchicalstructure.Theconcreteintegrationmethodisasfollows:takeStruts2frameworkbasedonMVCpatternastheinfrastructureofthesystemanddividethemodelpartofStruts2frameworkintothebusinesslayerwhichisresponsibleforhandlingbusinesslogicandthepersistencelayerthatmanagesdatapersistenceoperation.TheintegrationofS2SHframeworkisshowninFigure3.Figure3.TheintegrationofS2SHframeworkIntheintegrationwebframework,Struts2isusedforthepresentationlayertoprovideclearbusinessprocessesanduserinteractionandachieveloosedecouplingofthepresentationlayerandlogiclayer,besides,itgetsridofthehighcouplingoforiginaldevelopmentpattern;Springisresponsibleforthebusinesslogiclayer,itleavesthemanagementofAction,businessobjects,DAO,thesessionfactoryofpersistencelayerandothercomponentstoIoCcontainerbywritingtheconfigurationfiles,whichrealizestheloosecouplingbetweenlayersandreducestheircouplingtotheinterfacelevel.Moreover,theuseofitsAOPmoduleeasilyimplementstransactionmanagement;Hibernateisimportedbythepersistencelayertomakeuseofitsobject-relationalmappingtooperaterelationaldatabaseinaccordancewiththeobject-orientedideas.DAOpatternhidesthedetailsofdatabaseaccessinthebusinesslogiclayer.ThesequencediagramofS2SHapplicationframeworkisshowninFigure4.Figure4.ThesequencediagramofS2SHapplicationframeworkSo,awebapplicationframeworkisformedwiththecharacteristicsofaclearlevel,divisionoflaborandcompletedfunction,itachievesloosecouplingofsystemlayersandreducesthedevelopmentdifficultyofthelogicoflayers.Meanwhile,ithasagoodimprovementintheefficiency,maintainabilityanscalabilityofsystemdevelopment.IV.THECONCRETEIMPLEMENTATIONOFTHEAPPLICATIONFRAMEWORKArmyfundsmanagementsystembasedonthewebapplicationframeworkwasdesigned.Thesystemconsistedofbasicdatamanagement,accountmanagement,fundsmanagement,monitoring,managementanddatainquirymanagement.Becauseofspaceconstraints,thepapertakesaccountmanagementforexampletodescribetheconcreteimplementationofeverylayeroftheapplicationframework.A.ThePresentationLayerThepresentationlayerbasedonStruts2isresponsiblefortheinteractionofuserandsystem.AccordingtotheStruts2configurationfile,itscorecontrollerFilterDispatcherdecidestoforwardtherequesttothecorrespondingActionwhichcallstheappropriateservicescomponentsofbusinesslogic,andthenitreturnstheresponsethatisspecifiedintheResultobject.Inthisprocess,thecorecontrollerofStruts2determinesthesteeringofthebusinessflowandachievestheconnectionofcomponentsfromdifferentlayersthroughitsconfigurationfile.Therefore,writingthefile(Struts.xml)isthemainjobintheaspectofbusinessprocesscontrol.ThefollowingisthepartofStruts.xmlabouttheentryofaccountinformation./afms/success.jsp/afms/u2021.jspBaseAction(extendedfromStruts2ActionSupport)isinheritedbyalluser-definedActionclassthatcanaccesstheobjectsfromtheServletAPI,whichlowersthedependenceofActiononwebcontainer.Inaddition,italsodefinesthecommonlogicofalltheAction,improvingthereusabilityofcode.B.TheBusinessLogicLayerWiththehelpofthefunctionsofSpringsuchasIoC,AOPandinterface-orientedprogramming,thebusinesslogiclayercanhandlethebusinesslogicandtransactionmanagementofapplicationsystemwellandprovideinterfaceinteractwithotherlayers,whichcanmanagethedependenceofobjectsinthebusinesslayer.TheinteractionbetweenthebusinesslogiclayerandpersistencelayerisdonebyaccessingDAOcomponentsthatareinjectedbytheSettermethod.Finally,DAOcomponentsareconfiguredintheconfigurationfileofSpring.Inthisway,itachievesaloosecouplingbetweenthebusinesslogiclayerandpersistencelayer.Intheaccountmodule,aninterfaceIU2010ServiceanditsimplementationU2010ServiceImplcallingtheinterfaceIU2010DAOofthepersistencelayerweredefined,andthenSpringcombinedtheU2010ServiceImplwiththeIU2010DAObywritingApplicationContext.xmlfile.Thepartofthefileisasfollows:Besides,thereexiststransactionmanagementinthislayer;SpringAOPcanavoidwritingalotofcodesothatdeveloperspaymoreattentionstobusinesslogic.SoAOPcansolvethiskindofproblemwell.Thefollowingistheconfigurationfileabouttransactionmanagement./otherpartsareomittedhereWhatsmore,SpringprovidesagoodsupportthatitgivestheobjectsofHibernateallkindsofresourceswhattheywanttoinitializethembyintegratingtheSessionFactoryofHibernate;SoHibernatedoesnotneedtosetitsSessionFactorythroughhibernate.cfg.xmlfile,whichfurtherdecreasesthecouplingofsystem.C.ThePersistenceLayerThemaintaskofthislayeristobuilddomainobjects,O/RmappingfileandtheDAOinterfaceofthislayeranditsimplementation.ThelayerbasedonHibernateencapsulatesthedetailsaboutdataaccessandprovidesthebusinesslogiclayerwithdataaccessservices.HibernateestablishestheassociationofpersistenceobjectsanddatabasetablesthroughtheO/Rmappingfile,whichchangestheoperationsofpersistentobjectstotheonesofdatabasetables.Intheaccountmodule,theO/RmappingfileAccInfo.hbm.xmlwhichestablishedtherelationshipbetweentheaccountobjectpropertiesandthefieldsofaccounttablewasdefinedtoperformtheobject-orientedoperationsontheaccounttable,thepartofthefileisasfollows:.otherpartsareomittedhereMoreover,Hibernateprovidesalotofmethodsaboutdatabaseaccesssuchassave,delete,update,alleviatingtheworkloadofwritingSQLcodes.Toinvokethesemethods,theinterfaceofthepersistencelayershouldinherittheHibernateDaoSupportclassthatSpringprovidessothatitcanacquirethereferenceofHibernateTemplate.V.CONCLUSIONThroughtheintegrationofStruts2,SpringandHibernate,thewebapplicationframeworkisformedwiththecharacteristicsofaclearstructure,loosecoupling,highefficiencyofdevelopmentandgoodscalabilityandmaintainabilityandsoon,whichmakesdisplaymoduleindependent,businesscomponentslightweightanddataoperationsobject-oriented.Practiceshowsthattheframeworkissimpleandeasytouseandprovidesreferenceforbuildingakindofsmallormedium-sizedwebapplication;However,intheintegrationprocessofthethreeframeworks,thesizeoftheconfigurationfilesintheformsofXMLformatistoolarge;writing,modifyingandmaintainingtheseconfigurationfilesisnotalsoflexibleenough;Inaddition,thedegreeofmutualsupportbetweenthethreeframeworksneedstobefurtherimproved.ACKNOWLEDGMENTThisworkissupportedbythescientificresearchprojectsoftheDepartmentofEducationofShaanxiProvinceunderGrantNO.11JK1040.REFERENCES1WANGHai-taoandJIAZong-pu,“WebapplicationbasedonStrutsandHibernate”,ComputerEngineering,vol.37,No.9,pp.112-114,May2011.2LIXiao-ping,XIAOYue-feng,andSUYuan.“StudyofWeb-basedframeworkbasedonJ2EEmulti-tierarchitecture”,ApplicationResearchofComputers,vol.25,No.5,pp.1429-1431,May2008.3LIGang,“TheDefinitiveGuideforStruts2:MVCdevelopmentbasedonWebWork”,ElectronicIndustryPublishingpress,2007.SUNXiao-zhui,GUANYou-ni,andWENFu-an,“NetworkTeachingSystemBasedonLightweightJ2EEFramework”,ComputerEngineering,vol.34,No.6,pp.266-268,March2008.4WANGChun-chao,“Researchofbase-J2EEArchitectureSSHCombinationFramework”,ChangchunUniversityofScienceandTechnology,2010.5FENGRun-ming,“DesignandImplementationofHighEducationStudentManagementSystembasedonStruts&Hibernate&Spring”,ComputerEngineering,vol.35,No.6,pp.280-282,March2009.6CAIXue-tao,“DevelopmentandApplicationofHibernate”,TsinghuaUniversityPress,2006.7GAOAngandWEIWen-xue,“ApplicationofJavaDataPersistencewithHibernateandStrutsFramework”,ComputerApplications,vol.25,No.12,pp.2817-2819,December2005.8DUXiao-gangandLIZhou-jun,“ArchitectureofJ2EEWebDevelopmentFramework”,ComputerScience,vol.33,No.8,pp.236-239,August2006.中文翻译基于S2SH的Web应用程序框架的设计和实现摘要一个单一的框架在构建企业应用程序的一些问题,如效率低,系统开发,扩展性差,层次和结构复杂等。针对这些问题之间的高耦合,提出了基于Strut2,Spring和Hibernate(S2SH的一个Web应用框架)。通过使用Struts2中的表示层,Spring在企业管理的灵活性和Hibernate的持久层的成熟完备性,真正实现了层间的松散耦合,容易维护,同时降低了三个部分和框架开发的难度使其适用于军队的发展资金管理系统。关键词:Struts2框架;Spring框架;Hibernate框架;Web应用程序1.引言Web应用程序开发的要求一般要分为页面显示,业务逻辑和数据操作,以实现它们之间的松耦合,这有助于降低开发团队的成本和开发难度1。为达到上述要求,传统的Web应用提出了一种分层的结构,其中,在一定程度上降低了三者之间的耦合程度,但是没有实现松散耦合的真实感觉。此外,它很难用传统技术来实现三者的功能2。因此,要解决这些问题,很多基于J2EE框架的不断涌现。其中,Struts2,Spring和Hibernate已经为当前Web应用程序开发的主流。然而,他们只是某些层的Web应用程序的框架,而不是完整的Web应用程序架构。到最后,本文进行了Struts2,Spring和Hibernate框架进行研究,并提出了一个应用程序框架集成了S2SH框架,此外,它讨论了应用程序框架的集成过程。最后,本文以军队的资金管理系统为例来说明应用程序框架的各个组成部分的执行情况。2.STRUTS+SPRING+HIBERNATE框架Struct2是一个新的,更可伸缩的MVC框架的基础上集成Structs1和网络系统3,MVC设计模式包括三个部分:模型、视图和控制器。模型是用来实现由JavaBeans的logicusually实现业务,视图用于与通常通过JSP页面的用户交互,控制器用于实现主要由Structs2FilterDispatcher和行动的核心控制器实现业务逻辑的过程控制。核心控制器截获客户端的请求时,它根据Structs2配置文件发送请求到相应的Action对象,然后将其组装查看行动(Result对象)的结果,Structs2的工作流程如图1所示。此外,Structs2提供了丰富的标签库(Taglib是),从而简化了JSP页面的开发,并降低了系统开发的难度4。图1所示.Struts2工作流程Spring是一个优秀的轻量框架,它提供控制反转容器(IoC)和面向切面编程(AOP)来解决J2EE开发的许多常见问题5。Spring能有效地组织业务逻辑层对象,无缝地与其他框架集成,并提供一个统一的接口,用于不同的数据访问技术;此外,spring很容易地实现bean组件的装配和IoC的不同层之间的松耦合6;更重要的是,让使用AOP实现事务管理,同时,简化了其业务的运作。Hibernate是一个持久层优秀的ORM框架。它是Java应用程序和数据库之间的桥梁,Java对象和数据库表之间的映射记录的对象-关系映射文件被创建,它提供了大量的封装数据访问操作方法,大大减少了人工编写SQL语句和JDBC处理数据访问7-8。更重要的是,Hibernate轻量级对象封装了JDBC减少持久层的复杂性,使得开发人员更加注重应用系统的业务逻辑,而不是底层的数据结构。同时,Hibernate实现了面向对象的关系型数据库,以促进发展思想的统一。图2显示Hibernate框架的结构。图2.Hibernate框架的结构3.S2SH框架的整合设计根据S2SH框架技术的引入,为了实现页面显示的完全分离,业务逻辑和数据处理在web应用程序开发中,传统的J2EE应用程序9re-divided到表示层,业务逻辑和持久性层,每一层都有自己的处理逻辑。为了实现隔离层和集中处理的逻辑层,Struts2、Spring和Hibernate框架中导入网络层次结构。具体的集成方法如下:取Struts2框架基于MVC模式的基础设施系统和模型框架Struts2的一部分划分为业务层,负责处理业务逻辑和持久性层,管理数据持久化操作。整合S2SH框架如图3所示。图3.S2SH框架的集成Struts2集成web框架,用于表示层提供清晰的业务流程和自订的互动业务流程,实现表示层和逻辑层的松散的解耦,除此之外,它还能解决掉原始的高耦合发展模式;Spring负责业务逻辑层,它对叶子的行动管理,业务对象,Dao层,持久层和其他组件的IoC容器写入配置文件,实现层之间的松散耦合,并减少它们的耦合会话工厂在接口级。此外,使用AOP的模块容易实现事务管理;Hibernate是进口的对象-关系映射的持久层使用关系数据库操作按照面向对象的思想。DAO模式隐藏了细节的数据库访问业务逻辑层。S2SH应用程序框架的序列图如图4所示。图4.S2SH应用程序框架的序列图所以,一个Web应用程序框架形成有层次清晰,分工和完成功能的特点,实现了系统层的松散耦合,并减少层的逻辑的开发难度。同时,它在效率,可维护性系统开发的可扩展性良好的改善。4.应用程序框架的具体实施军队资金管理的基础上,Web应用框架系统的设计。该系统由基础数据管理,账户管理,资金管理,监督,管理和数据查询管理。由于篇幅所限,本文以账户管理为例来描述的具体实施应用程序框架的每一层。A.表示层基于Struts2的表示层负责用户和系统之间的交互。根据Struts2configurationfileitscorecontrollerFilterDispatcher决定将请求转发到相应的操作调用适当的服务组件的业务逻辑,然后返回响应,在结果对象中指定。在这个过程中,Struts2的核心控制器确定业务流程的指导和实现来自不同组件的连接层通过其配置文件。因此,编写文件(Struts.xml)是主要的业务流程控制方面的工作。以下是Struts的一部分xml中的有关账户信息的入口部分。/afms/success.jsp/afms/u2021.jsp基类(扩展Struts2ActionSupport)继承了所有用户定义的操作类,可以从ServletAPI访问的对象,这降低了行动依赖web容器。此外,它还定义了普通逻辑的所有行动,提高代码的可重用性。B.业务逻辑层在Spring功能的帮助下如国际奥委会,AOP和interface-oriented编程中,业务逻辑层可以处理和事务管理的业务逻辑的应用程序系统,提供接口与其他层交互,可以在业务层管理对象的依赖。业务逻辑层和持久层之间的交互是通过访问Dao组件所注入的Setter方法。最后,Dao组件是在Spring的配置文件中进行配置。通过这种方式,它实现了业务逻辑层与持久层之间的松散耦合。在帐户模块中,一个接口IU20

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论