在線考試系統(tǒng)外文翻譯_第1頁(yè)
在線考試系統(tǒng)外文翻譯_第2頁(yè)
在線考試系統(tǒng)外文翻譯_第3頁(yè)
在線考試系統(tǒng)外文翻譯_第4頁(yè)
在線考試系統(tǒng)外文翻譯_第5頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、J2EE文獻(xiàn)及翻譯1引言本文分析了 Hibernate和Struts的機(jī)制,提出了一種基于Hibernate和 Struts的J2EE應(yīng)用開(kāi)發(fā)策略。在這種策略中,模型層用 Hibernate實(shí)現(xiàn),視圖和 控制器則用Struts框架實(shí)現(xiàn)。這樣可大大降低代碼的耦合性以及提高系統(tǒng)的開(kāi) 發(fā)效率。 關(guān)鍵字 Hibernate , Struts , MVQ持久層。隨著Java技術(shù)的逐漸成熟與完善,作為建立企業(yè)級(jí)應(yīng)用的標(biāo)準(zhǔn)平臺(tái),J2EE平臺(tái)得到了長(zhǎng)足的發(fā)展。借助于J2EE規(guī)范中包含的多項(xiàng)技術(shù): EnterpriseJavaBean(EJB)、Java Servlets(Servlet) 、Java Serv

2、er Pages(JSP)、Java Message Service(JMS)等,開(kāi)發(fā)出了許多應(yīng)用系統(tǒng)。但是, 在傳統(tǒng)J2EE應(yīng)用的開(kāi)發(fā)過(guò)程中也出現(xiàn)了一些問(wèn)題:1)數(shù)據(jù)模型和邏輯模型之間 的矛盾。目前使用的數(shù)據(jù)庫(kù)基本上都是關(guān)系型數(shù)據(jù)庫(kù),而Java本質(zhì)上是一種面向?qū)ο蟮恼Z(yǔ)言,對(duì)象在存儲(chǔ)和讀取時(shí)使用SQ5口口801行數(shù)據(jù)庫(kù)操作,降低了編程的效率以及系統(tǒng)的可維護(hù)性;2)傳統(tǒng)的J2EE應(yīng)用多采用基于EJB的重量級(jí)框 架,這種框架適合于開(kāi)發(fā)大型企業(yè)應(yīng)用,但是使用EJB容器進(jìn)行開(kāi)發(fā)和調(diào)試需要耗費(fèi)大量時(shí)間。為了降低代碼的耦合性,提高系統(tǒng)的開(kāi)發(fā)效率,本文提出了一 種基于Struts框架和Hibernate框架

3、的J2EE應(yīng)用開(kāi)發(fā)策略。2J2EE開(kāi)源技術(shù)介紹數(shù)據(jù)持久層及Hibernate , Hibernate是一個(gè)數(shù)據(jù)持久層框架,是一種實(shí)現(xiàn) 對(duì)象和關(guān)系之間映射(O/R Mapping)的工具,它對(duì)JDBQ!行了輕量級(jí)的對(duì)象封 裝,使程序員可以使用對(duì)象編程思想來(lái)操作數(shù)據(jù)庫(kù)。它不僅提供了從Java類到數(shù)據(jù)表的映射,也提供了數(shù)據(jù)查詢和恢復(fù)機(jī)制。相對(duì)于使用JDBCS SQL操作數(shù)據(jù)庫(kù),使用Hibernate能大大的提高實(shí)現(xiàn)的效率。Hibernate框架用配置文件的 形式來(lái)定義Java對(duì)象和數(shù)據(jù)表之間的映射關(guān)系,同時(shí)在更深的層面將數(shù)據(jù)表之 問(wèn)的關(guān)系解釋為Java對(duì)象之間的繼承及包含等關(guān)系。通過(guò)使用 HQL&#

4、174;句將復(fù)雜的 關(guān)系算法用對(duì)象的方式描述,在很大程度上簡(jiǎn)化了對(duì)數(shù)據(jù)的查詢,加快了開(kāi)發(fā) 的效率。在Hibernate中有一個(gè)簡(jiǎn)單而直觀的API,用于對(duì)數(shù)據(jù)庫(kù)所表示的對(duì)象 執(zhí)行查詢。要?jiǎng)?chuàng)建或修改這些對(duì)象,只需在程序中與它們進(jìn)行交互,然后告訴 Hibernate保存即可。這樣,大量封裝持久化操作的業(yè)務(wù)邏輯不再需要編寫(xiě)煩瑣 的JDBC®句,從而使數(shù)據(jù)持久層得到了極大的簡(jiǎn)化。用 Struts 實(shí)現(xiàn) MV琛才M MVC(Model-View-Controller )由 Trygve Reenskaug提出,首先被應(yīng)用在SmallTalk-80環(huán)境中,是許多交互和界面系統(tǒng)的 構(gòu)成基礎(chǔ)。根據(jù)界面

5、設(shè)計(jì)可變性的需求,MVCG交互系統(tǒng)的組成分解成模型、視圖、控制器三部分。模型(Model)是軟件所處理問(wèn)題邏輯在獨(dú)立于外在顯示內(nèi)容和形式情況下的內(nèi)在抽象,封裝了問(wèn)題的核心數(shù)據(jù)、邏輯和功能的計(jì)算關(guān) 系,獨(dú)立于具體的界面表達(dá)和I/O操作。視圖(View)把表示模型數(shù)據(jù)及邏輯關(guān) 系和狀態(tài)的信息及特定形式展示給用戶。它從模型獲得顯示信息,對(duì)于相同的 信息可以有多個(gè)不同的顯示形式或視圖??刂破?Controller )是處理用戶與 軟件的交互操作的,其職責(zé)是控制提供模型中任何變化的傳播,確保用戶界面 于模型間的對(duì)應(yīng)聯(lián)系;它接受用戶的輸入,將輸入反饋給模型,進(jìn)而實(shí)現(xiàn)對(duì)模 型的計(jì)算控制,是使模型和視圖協(xié)調(diào)工

6、作的部件。通常一個(gè)視圖對(duì)應(yīng)一個(gè)控制 器。模型、視圖與控制器的分離,使得一個(gè)模型可以具有多個(gè)顯示視圖。如果 用戶通過(guò)某個(gè)視圖的控制器改變了模型的數(shù)據(jù),所有其它依賴于這些數(shù)據(jù)的視 圖都應(yīng)反映到這些變化。因此,無(wú)論何時(shí)發(fā)生了何種數(shù)據(jù)變化,控制器都會(huì)將 變化通知所有的視圖,導(dǎo)致顯示的更新。這實(shí)際上是一種模型的變化-傳播機(jī)制。Struts框架最早是作為Apache Jakarta項(xiàng)目的組成部分問(wèn)世運(yùn)做,它繼承 了 MVC勺各項(xiàng)特性,并根據(jù)J2EE的特點(diǎn),做了相應(yīng)的變化與擴(kuò)展。Struts框架很 好的結(jié)合了 Jsp, Java Servlet , Java Bean, Taglib 等技術(shù)。在 Strut

7、s 中,承 擔(dān)MVCH空制器角色的是ActionServlet 。ActionServlet 是一個(gè)通用的控制組件。 這個(gè)控制組件提供了處理所有發(fā)送到 Struts的HTTP青求的入口點(diǎn)。它截取和 分 發(fā)這些請(qǐng)求到相應(yīng)的動(dòng)作類(這些動(dòng)作類都是Action類的子類)。另外控制組件也負(fù)責(zé)用相應(yīng)的請(qǐng)求參數(shù)填充 Action Form (FromBear),并傳給動(dòng)作類(ActionBean)。動(dòng)作類訪問(wèn)核心商業(yè)邏輯,即訪問(wèn) Java Bean或調(diào)用EJR最后動(dòng)作類把控制權(quán)傳給后續(xù)的JSP文件,由JSP文件生成視圖。所有這些控制邏 輯利用Struts-config.xml文件來(lái)配置。在Struts框架

8、中,視圖主要由JSP生成頁(yè)面完成,Struts提供豐富的JSP標(biāo)簽庫(kù),這有利于分開(kāi)表現(xiàn)邏輯和程序邏輯。模型以一個(gè)或多個(gè)Java Bean的形式存在。在 Struts中,主要存在三種 Bean,分 別是:Action , ActionForm , EJB或者Java Bean= Struts 框架沒(méi)有具體定義模 型層的實(shí)現(xiàn),在實(shí)際開(kāi)發(fā)中,模型層通常是和業(yè)務(wù)邏輯緊密相連的,并且要對(duì) 底層數(shù)據(jù)進(jìn)行操作。下面介紹一種開(kāi)發(fā)策略,將 Hibernate引入到Struts框架的 模型層中,使用它來(lái)進(jìn)行數(shù)據(jù)封裝和映射,提供持久化的支持。下面結(jié)合開(kāi)發(fā)實(shí)踐,以在J2EE應(yīng)用中非常普遍的用戶登錄過(guò)程為例,來(lái)說(shuō) 明上

9、述體系結(jié)構(gòu)是如何具體運(yùn)用的。登錄的流程非常清晰:用戶從登錄頁(yè)面 login.jsp 輸入登錄信息,系統(tǒng)對(duì)登錄信息進(jìn)行驗(yàn)證,如果正確則成功登錄,否 則提示相應(yīng)錯(cuò)誤信息。在開(kāi)發(fā)過(guò)程中,使用Eclipse做為開(kāi)發(fā)環(huán)境,同時(shí)加載了對(duì)Struts及Hibernate提供更好的控制和支持的第三方插件 MyEclipse , WebK 務(wù)器使用Tomcat,數(shù)據(jù)庫(kù)選用了 Mysql。首先對(duì)Hibernate進(jìn)行配置,只需要對(duì) 系統(tǒng)自動(dòng)生成的hibernate.cfg.xml進(jìn)行修改,配置好數(shù)據(jù)庫(kù)連接的各種參數(shù)以及定義數(shù)據(jù)映射文件。由于Hibernate所帶的連接池主要用于測(cè)試,性能不是很 好,可以通過(guò)JND

10、I將其修改為使用Tomcat的連接池。附件:外文資料原文J2EEAndrewGlover1 IntroductionThis text analysisthe mechanismof Hibernate and Struts, put forward 1 kind EE according to the J2 of the Hibernate and the Struts application development strategy.Inthis kind of strategy, the model layer use a Hibernate realization and see di

11、agram and controller to then use a Struts frame a realization.So can consumedly lower the development efficiency that the Ou of codematch sexand exaltation system.The key word Hibernate, Struts, the MVC, hold out for long time a layer one preface along with the Java technique of gradual mature and p

12、erfect, Be establishment business enterprise class application of standard terrace, the J2EE terrace got substantialof development.Severatechnique asked for help from to include in the J2 EE norm:Enterprise JavaBean(EJB),Java Servlets(Servlet), Java Server Pages(JSP), Java Message Service(JMS).etc.,

13、 development many application system.But, also appearedsome problem in the tradition J2 the EE the application of the development the process:the antinomy of of data model and logic model.Currently the databaseof usagebasically and all is relation type database,but the Java be essentiallya kind of t

14、he languagewhich face to object, object at saving with read usage SQL and JDBC carry on a databaseoperation and lowered plait distance of efficiency and system of can maintenance;tradition of J2 EE application much the adoption is according to the EJB heavy weight frame, this kind of frame suitable

15、for develop a large business enterprise application, but usagethe EJB container carry on developmentand adjust to try to need to be waste a great deal of time.For lowering the Out of code to match sex, exaltation system of development efficiency, this text put forward 1 kind EE according to the J2EE

16、 of the Struts frame and the Hibernate frame application developmentstrategy.2 Open SourceTechnologyof J2EEDatas' holding out for long time layer and Hibernate is one piece according to hold out for long time layer frame, is a kind of realization object and relation of the tool which reflect to

17、shoot(O/R Mapping), it carried on the object of the lightweight to pack to the JDBC and make procedure member can usage object plait distance thought to operation database.Itnot only provided to shootfrom Java to reflect of data form, but also provided a data a search and instauration mechanism.Oppo

18、sitein usage JDBC and SQL to operation database, use a Hibernate ability consumedly of exaltation realization of efficiency.The Hibernate frame use allocation document of the form come to the reflect of the definition Java object and data form to shoot relation, in the meantime at moredeepof level o

19、f data form of relation explanation for the relations such as inherit of and containment etc. of Java object.Passthe usage HQL language sentencecomplications of relation the calculate way use the way of object description, to a large extent simplification logarithms according to of search, speeddeve

20、lopmentof efficiency.Have in the Hibernate a simple but keepthe API of view, used for to the databasemeanof object performancesearch.Wantto establishor the modification be theseobjects, need in the procedurecarry on with them to hand over with eachother, then tell Hibernate to keep.So,a great deal o

21、f pack hold out for long time turn operation of business logic no longer demand write a trivial JDBC languagesentencemake datalastlong thusthe layer got biggest of simplification.Use the Struts realization MVC structure MVC(Model-View-Controller) is put forward by the Trygve Reenskaug, first drive a

22、pplication in the environment SmallTalk-80, is many to hand over with each other with interface system of constitute foundation.According to the need of variable of the interface design, MVC hand over with eachother constitute of system to resolve into modeland seediagram, controller three part. Mod

23、el(Model) is software processing problem logic at independencein outside manifestation under contentsand form circumstanceof inside abstract, packed the core data, logic of problem and function of calculation relation, independencein concrete of interface expressionand I/O operation.Seediagram(View)

24、 mean information and particular form demonstrationof model data and logic relation and appearanco the customer.Itacquire a manifestation information from the model, there can be many for homology of information dissimilarity of manifestation form or seediagram.The controller(Controller) is a proces

25、sing the customer hand over with software with each other operation of, its job is control provide model in any variety of dissemination, insure a customer interface among the model of rightness should contact;It accept a customer of importation, give the importation feedback model, then realization

26、 compute model control, is make model and seediagram to moderate work of parts.Usually 1 see a diagram rightness should a controller.Model, see separateof diagram and controller, make a model be able to have many manifestation to seediagram.If the customer passa certain seethe controller of diagram

27、changethe data of model, all other dependencein theseseeof data diagram all should reflection arrive these variety.When therefore and regardless occurrence what data variety, controller all would variety notice allly see diagram, cause manifestation of renewal.Thisis actually a kind of variety of mo

28、del-disseminationmechanism.The Struts frame is to be the item of Apache Jakartato constitute part to publish luck to do at the earlieststage,it inheritted MVC of each item characteristic,and did according to the characteristicsof J2 EE correspondof variety with expand.TheStruts frame wasgood to comb

29、ine Jsp,JavaServlet, JavaBean, Taglib etc. technique.Inthe Struts, what to undertake the controller role in the MVC be an ActionServlet.The ActionServlet is an in general use control module.This control module provided a processingall HTTP claim which send out Struts of entrance point.Its intercepti

30、on with distribute theseclaim to arrive correspondof action type.(theseaction all of type is Action son type)Moreover the control module is also responsible for using to correspond of claim the parameter fill Action Form(FromBean), and pass action type(ActionBean).Action type the businesslogic of th

31、e interview core, then interview JavaBean or adjust to use EJB.End action type control the power passfollow-up of JSPdocument,from JSPdocumentborn seediagram.All thesecontrol logic makeuse of Struts-config.xml the document cometo allocation.Seediagram in the Struts frame main from JSP born page comp

32、letion, the Struts provide abundant of JSP label database, this is advantageous to separating performance logic and procedure logic.The model is with 1 or the form existence of several JavaBean.In the Struts, main existence three kinds of Bean, respectively BE:Action, ActionForm, EJB perhaps Java Be

33、an. The Struts frame have no concrete definition model layer of realization, in actually the development, model layer usually is close with business logic connect with each other, and want to carry on operation to the first floor data.The underneath's introduction is a kind of development strate

34、gy, lead the Hibernate into the model layer of Strutsframe, usageit to carry on a data to pack with reflect to shoot, provide hold out for long time turn of support.4 usageHibernateand the Struts development J2 EE application 4.1 system structure diagram 3 manifestation according to Hibernate and Struts development strategy of system structure

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論