版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
外文文獻(xiàn)資料收集:應(yīng)用技術(shù)學(xué)院計(jì)算機(jī)科學(xué)與技術(shù)(外文文件名:JSPSplittingforImprovingExecutionPerformance)AbstractSplittingaJSP(JavaServerPages)pageintofragmentscanimprovetheexecutionperformanceofJSPpageswhentheWebapplicationservercanseparatelycachetheWebpagefragmentsobtainedbyexecutingtheJSPfragments.IfaJSPpageissplitintofragmentsaccordingtotheupdatefrequencyofeachportionoftheWebpageobtainedbyexecutingtheJSPpage,allofthesplitJSPfragmentsdonotneedtobeexecutedagainwhenonlyasinglecachedpartofaWebpageexpires.Inaddition,thefragmentsofaJSPpagecanbereusedbyotherJSPpages.Inbothcases,theexecutionresultsofalloftheJSPfragmentssplitfromtheJSPpagemustbethesameasfromtheJSPpagebeforeitwassplit.Inthispaper,weproposeJSPsplitting,whichisamethodofsplittingaJSPpageintofragmentsmaintainingthedataandcontroldependencesexistingintheoriginalJSPpage.JSPsplittingautomaticallydetectstheportionsneededtomaintainthedataandcontroldependencesofaJSPpagefortheportionsthatdeveloperswanttosplitfromtheJSPpage.WeimplementedJSPsplittingwithaGUItool,andconfirmedthatthesplitJSPfragmentswereexecutedinthesameasthewayastheJSPpagebeforethesplit.ExperimentalresultsshowthattheresponsetimetoaccessaWebpagecanbereducedbysplittingaJSPpageintofragmentsandsettingdifferentcachingperiodsfortheWebpagefragmentsobtainedbyexecutingtheJSPfragments.1.IntroductionSplittingaJSP(JavaServerPages)pageintofragmentscanimprovetheexecutionperformanceofsomeJSPpageswhentheWebapplicationservercanseparatelycachetheWebpagefragmentsobtainedbyexecutingthefragmentsoftheJSPpage.TheperiodofcachingdynamicWebpagesgeneratedbyaJSPengineislimitedduetothedynamicnatureofthecontent.WhenthecachedcontentofaWebpagegeneratedbyaJSPengineisupdated,theentireJSPpagemustbeexecutedagainontheapplicationserver,eventhoughthechangeoftheWebpagemightbesmall.SincefrequentupdatesofcachedWebpagesincreasetheloadonanapplicationserver,itisreasonabletosplitaJSPpageintofragmentsandsetdifferentcachingperiodsfortheWebpagefragmentsobtainedbyexecutingtheJSPfragments.Ofcourse,theWebpagefragmentsmustbemergedintoafinalWebpagecorrectly.TheDynacachetechnologyofIBMWebSphereApplicationServerallowsWebpagefragmentstohavedifferentcachingperiods.CachetaglibrariesprovidedbytheApacheJakartaProjectalsosupportdifferentcachingperiodsfortheJSPfragments.Inaddition,ESI(EdgeSideIncludes)technologyprovidesamechanismtocacheWebpagefragmentswithdifferentcachingperiods,andtomergethemintoafinalWebpageonanedgeserver.TheapplicationoffloadtechnologyofIBMWebSphereEdgeServerisanotherapproachtoimprovetheexecutionperformanceofJSPpages.ThistechnologyallowsoneormoreJSPfragmentstobecachedandexecutedonedgeservers.TheremainingJSPfragmentsaredeployedontheapplicationserverandarecalledbytheJSPfragmentsexecutedontheedgeserver.Thus,someoftheexecutionofaJSPpageisoffloadedtotheedgeserver.SplittingaJSPpagefacilitatesthereuseofJSPfragments.WhenaWebapplicationconsistsofmanyJSPpages,thesameportionstendtoexistinmanyJSPpages.Examplesaretheframes,thebanners,theheaders,andetc.WhenaJSPpageissplitintofragments,thetotalexecutionresultofallofthefragmentsmustbethesameastheJSPpagebeforeitwassplit.Inaddition,whenthefragmentsofaJSPpageareexecutedindifferentservers,eachfragmentneedstobeexecutedwithouttheotherfragments.Inordertosatisfytheseconditions,weproposeJSPsplitting,whichisthemethodofsplittingaJSPpageintofragmentsdescribedinthispaper.SinceitisverydifficulttoautomaticallyfindthebestwaytosplitaJSPpageintofragmentsforsomeparticularpurpose,weassumethatthedeveloperswillselecttheportionsthattheywanttosplitintofragments.InordertoexecuteallofthedividedJSPpagescorrectly,JSPsplittingautomaticallydetectsanyportionsthatmustbemovedorcopiedintoafragmentwiththeselectedportions.ThedetectionisdonebasedontheanalysisofthedataandcontroldependencesexistinginaJSPpage.JSPsplittingissimilartotheprogramslicingtechniquethatslicesaprogrambasedonthedataandthecontroldependences.However,theprogramslicingtechniquedoesnottakeintoaccountthattheslicedprogramsareexecutedindependentlyandthatthetotalexecutionresultoftheslicedprogramsmustbethesameastheprogrambeforethedivision.Inaddition,sincedataispassedtotheJSPengineduringtheexecutionofJSPpages,thesourceprogramoftheJSPengine,suchasApacheTomcat,isrequiredinordertoanalyzethedatadependencescorrectly.Thisisimpractical,becausethesourceprogramoftheJSPengineisverylargeandcomplex.JSPsplittingavoidstheanalysisoftheJSPenginebyutilizingthecharacteristicsofJSP.Therestofthepaperisorganizedasfollows.Section2explainsthedifficultyofsplittingaJSPpageintofragments.Section3givesdetailsofthealgorithmtosplitaJSPpage.Section4describestheJSPsplittingtoolthatisanimplementationofJSPsplittinganddemonstrateshowasampleJSPpageissplitbythetool.Section5showstheexperimentalresultsobtainedbyexecutingthesplitJSPfragmentswithdifferentcachingperiodsontheIBMWebSphereApplicationServer.Section6discussespreviousworkinrelationtoourcontributions.Ourconclusionsformthefinalsection.2.DifficultyofSplittingaJSPPageInthispaper,splittingaJSPpagemeansthatsomeportionsoftheJSPpagearecutfromtheJSPpageandsavedasnewJSPpages.SuchnewlycreatedJSPpagesareincludedintheoriginalJSPpagebyusingsomemechanismsuchasthejsp:includetag.WecalltheincludedJSPpagetheJSPfragment,andcalltheJSPpagethatinvokestheJSPfragmentsthemasterJSPpage.AmasterJSPpageinvokesJSPfragmentsandreceivesWebpagefragmentsobtainedbyexecutingthem.ThenthemasterJSPpagemergesitsownWebpagefragmentwiththeWebpagefragmentsreceivedfromtheJSPfragments,andcreatesafinalWebpage.JSPfragmentsarenotalwaysexecutedinthesameserveroratthesametime.TheapplicationoffloadtechnologyallowsamasterJSPpageandJSPfragmentstobeexecutedindifferentservers.WhentheESImechanismisused,esi:includetagsareputintoaWebpagefragmentobtainedbyexecutingamasterJSPpageandinterpretedinanedgeserverthatsupportstheESImechanism.Inthiscase,theedgeservercheckswhetherornottheWebpagefragmentsspecifiedbyesi:includetagsexistinitscache.IfthecontentsofWebpagefragmentsarenotcachedorhaveexpired,theJSPfragmentsareinvokedfromtheedgeserver,andexecutedinoneormoreapplicationservers.IfdifferentcachingperiodscanbegiventotheWebpagefragmentsobtainedbyexecutingtheJSPfragments,eachJSPfragmentisexecutedonlywhenthecachedcontenthasexpired.TheDynacachetechnology,theESImechanism,andthecachetaglibrariescansupportdifferentcachingperiodsforWebpagefragments.WhenaJSPpageissplitintofragments,thefollowingtwoconditionsmustbesatisfiedevenifthemasterJSPpageandtheJSPfragmentsarenotexecutedinthesameserveroratthesametime.Cond.1-1ThetotalexecutionresultofamasterJSPpageandtheJSPfragmentsisthesameastheJSPpagebeforeitwassplit.Cond.1-2EachJSPpage,whichiseitheramasterJSPpageoraJSPfragment,maybeexecutedwithoutotherJSPpages.TheseconditionsaresatisfiedbymaintainingthedataandcontroldependencesexistinginaJSPpageaftertheJSPpagehasbeensplitintofragments.However,itishardworkfordeveloperstodetectdataandcontroldependentportionsinaJSPpage,becausethedataandcontrolflowofaJSPpagecanbedividedamongtheJSPpage,theJSPenginethatexecutestheJSPpage,anyJavabeansusedintheJSPpage,andetc..Thus,anaturalsolutioncallsforautomaticallydetectingdata-dependentandcontrol-dependentportionslinkedtotheportionsthatdeveloperswanttosplit.TheprogramslicingtechniquedetectsasetofprogramstatementsthataffectaprogramstatementSbyanalyzingthedataandcontroldependencesexistingintheprogram.OneprogramsliceconsistsofthedetectedsetofprogramstatementsandthestatementS.Thistechniqueisusefulwhendebuggingormaintaininglargeprograms.SinceJSPpagesarecompiledintoservletprogramsbyusingaJSPcompilersuchastheApacheJaspercompiler[4],JSPslicescanbeobtainedbyapplyingprogramslicingtechniquetoaservletprogramcompiledfromaJSPpage.However,theprogramslicingtechniqueisnotsufficienttosplitaJSPpageintofragments,becausethetechniquedoesnottakeintoaccountthatprogramslicesareexecutedindependently.Figure1showsapartofasampleJSPpageandasampleservletprogramcompiledfromtheJSPpage.Figure2(a)showsthedatadependencegraphobtainedfromtheservletprogram.Inaprogram,whenastatementS1assignsavaluetoavariableandastatementS2followingS1usesthatvalue,atruedatadependenceexistsbetweenS1andS2.SuchadatadependenceisdenotedasS1S2.InFigure2(a),duetothedatadependences,theprogramsliceforthestatementS10consistsofS1,S9,andS10.Iftheprogramsliceiscutfromtheservletprogram,theremainingprogramstatementshaveerrorsbecausethedatadependencesS1S2,S11,andS12andS9S11andS12arenothonored.Thus,theprogramslicingtechniquedoesnotworkwellforsplittingJSPpages.3.JSPSplittingInthispaper,weproposeJSPsplitting,amethodofsplittingaJSPpageintofragments.TheproposedmethodanalyzesdataandcontroldependencesintheservletprogramcompiledfromaJSPpage.Atthetimeofanalysis,JSPsplittingtakesintoaccountthatsplitJSPpageswillbeexecutedindependently,andmaynotbeexecutedinthesameserveroratthesametime.First,theportionsthatdeveloperswanttosplitintoaJSPfragmentareselected.Fortheselectedportions,theportionsneededtosatisfytheconditions1-1and1-2aredetected.Thedetectedportionsarecategorizedintomovedandcopiedportions,andareminimizedinordertomatchtheintentionsofthedevelopers.3.1.IgnorableDataDependencesBasically,JSPsplittingdoesnotallowthedependentstatementstobesplitapart.However,ifthisruleisappliedtoostrictly,noneofthestatementsshowninFigure1(b)canbesplit,becausethereareinterlockingdependencesstartingfromS1andS9.Here,weconsiderhowthevariableoutshowninFigure1(b)isused.ThevariableoutisusedtowritethetextdataofanyWebpage.NotethatthevalueofoutcanberetrievedfromanyJSPengine.WhenamasterJSPpageJMincludesaJSPfragmentJFbyusingajsp:includetagandaJSPengineexecutesbothofthem,JMfirstretrievesthevalueofoutfromtheJSPengineandwritesitsowntextdatatothevalue.Next,JMinvokesJF.Afterbeinginvoked,JFalsoretrievesthevalueofoutandwritesitsowntextdatatothevalue.ThetextdatawrittenbyJMisreturnedtooutthroughtheJSPengineandmergedwiththetextdatawrittenbyJM.ThismeansthatthevalueofoutcanbeutilizedbyanyJSPpageandthetextdatawrittentothevalueismaintainedbytheJSPengines.Inotherwords,whenaJSPpageissplitintofragments,astatementthatretrievesthevalueofoutcanexistbothinaservletprogramcompiledfromamasterJSPpageandinservletprogramscompiledfromJSPfragments.Therefore,thedatadependencesforthevariableoutcanbeignoredatthetimeofsplittingaJSPpage.AsshowninFigure2(a),noneofthestatementscanbesplitwhilemaintainingthedatadependencesexistingintheservletprogramshowninFigure1(b).However,ifthedatadependencesforthevariableoutareignored,thedatadependencegraphischangedasshowninFigure2(b).UsingthedatadependencegraphshowninFigure2(b)makesitpossibletosplitS2fromthesetofS9,S10,S11,andS12whichcannotbesplitduetothedatadependencesforthevariablebook.InservletprogramscompiledbytheApacheJaspercompiler,thedatadependencesforthevariablesshowninTable1canbeignoredforthesamereasonasforthevariableout.Sincethevaluesofthesevariablesaredefinedatthetopofeachservletprogramandarefrequentlyreferredto,moststatementscannotbesplitifthedatadependencesaretobemaintained.Ingeneral,theout-of-orderexecutionisallowedforthestatementswithoutdataandcontroldependences.IgnoringthedatadependencesforthevariablesshowninTable1mayintroduceanincorrectexecutionorderofstatements.Forexample,ifS10andS12showninFigure1aresplitintoaJSPfragmentandtheJSPfragmentisincludedbeforeS11,anincorrectWebpageisgenerated.Inordertoavoidsuchincorrectexecution,ouralgorithmdoesnotallowchangesintheorderofthestatementsthathaveignoreddatadependences.3.2.AnalysisofDataDependencesforJavabeansInaJSPpage,Javabeansarefrequentlyusedtostoreandretrievedataaspropertyvalues.EachJavabeanisaJavaobjectanddeveloperscanuseJavabeansbyusingthreekindsoftagsinaJSPpage.●jsp:useBean:DeclaresanamedJavabeanwithitsscope.WhenanobjectfortheJavabeandoesnotexistwithinthedeclaredscope,thebeanisinstantiated.Javabeanscanbedeclaredwiththescopeofpage,request,sessionorapplication.●jsp:getProperty:CallsthegetmethodofaJavabeanobjectandretrievesthepropertyvalue.●jsp:setProperty:CallsthesetmethodofaJavabeanobjectandsetsthepropertyvalue.Javabeansmustbedeclaredwiththejsp:useBeantagbeforetheothertwooperations.ThismeansthatadeclarationofaJavabeanandalloftheotheroperationsfortheJavabeanmustbeincludedinthesameJSPpage.ThisstronglylimitstheextentofaJSPfragment.Inordertorelaxthelimitation,JSPsplittingallowsdeclarationsofJavabeanstobecopiedtoJSPfragments.ThereasonwhydeclarationsofJavabeanscanbecopiedisthatthedeclarationsdonothavesideeffects.EachdeclarationmerelyinstantiatesaJavabeanobjectwhentheJavabeanobjecthasnotyetbeeninstantiatedwithinitsscope.Inotherwords,aJavabeanobjectisnotinstantiatedmorethanonetimewithinitsscopeevenifthedeclarationiscopiedtoJSPfragments.Therefore,someoftheoperationsforaJavabeancanbesplitintofragments.WhenapropertyvalueissetforaJavabeanbyusingajsp:setPropertytagandretrievedfromtheJSPbeanbyusingajsp:getPropertytag,atruedatadependenceexistsbetweenthetwooperations.Whentherulethatdatadependentstatementscannotbesplitisapplied,datadependentoperationsforaJavabeanmustbeincludedinthesamefragment.However,adatadependencebetweenanoperationthatsetsapropertyvalueforaJSPbeanandanotheroperationthatretrievesthepropertyvalueismaintainedafterthetwooperationsaresplitifthefollowingtwoconditionsaresatisfied.Cond.2-1ThescopeoftheJavabeanis”request”,”session”,or”application”.Cond.2-2ThesplitJSPpagesareexecutedinthesameJSPengine.Iftheseconditionsaresatisfied,JSPsplittingallowstheoperationsamongwhichthedatadependencesexisttobesplitintodifferentJSPpages,becausetheJavabeanlivesintheJSPengineduringtheexecutionofthesplitJSPpages.Asaresult,theportionssplitalongwiththeportionsselectedbyadevelopercanbereduced.However,theWebpagefragmentsobtainedbyexecutingthesplitJSPpagessatisfyingtheseconditionsmusthavethesamecachingperiod.ThisisbecausethedatadependenceisnotmaintainedifaJSPpagewasexecutedandavalueisdefinedintheJSPpagewhileanotherJSPpage,inwhichthedefinedvalueisused,wasnotexecutedduetothevalidcachedcontentoftheWebpage.WhenaJavabeanhasthepagescope,thedependentoperationsfortheJavabeancannotbesplit.However,eachoperationthatsetsapropertyvalueforaJavabeanwiththepagescopecanbecopiedalongwithoneormoreoperationsthatretrievethesamepropertyvalue,becausetheoperationsthatsetpropertyvaluesforJavabeanswiththepagescopedonothavesideeffects.Figures3to6showthealgorithmstosplittheoperationsforJavabeans.ThesealgorithmstrytominimizethenumberoftheoperationsthataremovedorcopiedtoaJSPfragment.4.JSPSplittingToolWeimplementedJSPsplittingasaplug-inforEclipse。Figure7showsthearchitectureoftheJSPsplittingtool.TheJSPsplittingeditorpresentsthesourceviewandtheoutlineviewofaJSPpage.Developersselecttheportionsthattheywanttosplitusingeithertheeditorortheoutline.Aftertheportionsareselectedbydevelopers,themovedandcopiedportionsaredisplayedinadialogwiththeselectedportions.AlloftheportionsareputintoanewJSPpagespecifiedbydevelopers,andthemovedportionsarereplacedwiththe<jsp:include>tagintheoriginalJSPpage.WhentheeditorisinvokedwithaJSPpage,thedataandcontroldependencesexistingintheJSPpageareanalyzed.First,theJSPcompiler,whichisbasedontheApacheJaspercompiler,compilesaJSPpageintoaservletprogram.TheJSPcompilerpartitionstheJSPpageintothepartsthatarecategorizedasshowninTable2,andgeneratesoneormoreJavastatementsforeachpart.Atthistime,themappingtablebetweeneachpartoftheJSPpageandoneormorestatementsoftheservletprogramisgenerated.TheJSP-Servletmapperconvertstheoriginalgroups,eachofwhichcontainsdependentstatementsofaservletprogram,intonewgroups,eachofwhichcontainsthedependentJSPparts,byusingthemappingtablebetweenthepartsofaJSPpageandthestatementsoftheservletprogram.ThismappingtablewasgeneratedearlierduringtheJSPcompilationstage.ThegeneratedJSPgroupsarepassedtotheJSPsplitter.5.ExperimentWemeasuredtheexecutionperformanceofJSPpagessplitbyusingourtool.TheJSPpagewasexecutedonWebSphereApplicationServer,withtheDynacachemechanismenabled.Forcomparison,wesplitalloftheportionsthatdynamicallyoutputWebpagefragmentsintojustoneJSPfragment,anddidnotcachetheWebpagegeneratedfromtheJSPfragment,becausethegeneratedWebpageincludedtheprivateinformationfromthefragment.However,theothertextfragmentswerecachedfor30seconds.Wecallthiskindofdivisionthecoarse-grainsplitting.Inaddition,wemeasuredtheexecutionperformancewhentheWebpagewasnotcached.Forthesemeasurements,weusedaclientprogramthatcontinuestosendrequestsfortheJSPpagefor5minutesandcountsthenumberofthereceivedresponses.EachrequestissenttothelocalWebapplicationserverafterithasreceivedtheresponseforthepreviousrequest.6.RelatedWorkAsmentionedinSection2,theprogramslicingtechniqueissimilartoourmethod.However,theprogramslicingtechniquedoesnotassumethateachslicedprogramisexecutedasanindependentprogramthoughthetotalexecutionresultoftheslicedprogramshastobethesameastheprogrambeforeitwassliced.Therefore,theprogramslicingtechniquecannotbeappliedtothesplittingofJSPpages.TheExtractMethodisasoftwarerefactoringtechniquethatconvertsseveralprogramstatementsintoanewmethod.Thistechniqueincreasesthechancesthatothermethodscanusetheextractedmethods.Thestatementsconvertedintoamethodareselectedbydevelopers.Thistechniqueissimilartoourmethod.Afterthestatementsareselected,theparametersthatmustbepassedtothenewmethod,andthereturnvalueofthenewmethodaredetermined.7.ConclusionInthispaper,weproposedJSPsplittingasamethodofsplittingaJSPpageintofragmentsinordertoimprovetheexecutionperformanceandthereusabilityoftheJSPpages.Inthefuture,wearegoingtointroduceamethodthatcompensatesforthislackofinformationbyinteractingwithdevelopers.感應(yīng)式IC卡辦公門(mén)禁考勤一卡通管理系統(tǒng)方案計(jì)劃書(shū)PagePAGE34ofNUMPAGES49中文翻譯稿翻譯:應(yīng)用技術(shù)學(xué)院06計(jì)算機(jī)科學(xué)與技術(shù)(0616403057)傅曉燕2010年2月(中文名:改進(jìn)執(zhí)行性能的JSP切分)摘要當(dāng)網(wǎng)頁(yè)應(yīng)用服務(wù)器能分別存儲(chǔ)通過(guò)執(zhí)行JSP片段獲得的網(wǎng)頁(yè)頁(yè)面片段時(shí),把一個(gè)JSP(Java服務(wù)器頁(yè)面)頁(yè)面切分成若干個(gè)片段能改進(jìn)JSP頁(yè)面的執(zhí)行性能。如果一個(gè)JSP頁(yè)面根據(jù)通過(guò)執(zhí)行JSP頁(yè)面獲得的網(wǎng)頁(yè)頁(yè)面的每一個(gè)部分的不斷跟新被切成若干片段,所有切分的JSP片段不需要被再次執(zhí)行,只有當(dāng)需要調(diào)用的網(wǎng)頁(yè)片段在緩存中過(guò)期了。另外,一個(gè)JSP頁(yè)面的片段能夠被其他的JSP頁(yè)面再次使用。在這兩種情況下,所有的從JSP頁(yè)面中切分的JSP片段的執(zhí)行結(jié)果必須與在JSP頁(yè)面切分之前一樣。在這篇文章中,本文提出JSP切分,它是一種把JSP頁(yè)面切分成片段的方法,維持了存在于源JSP頁(yè)面的數(shù)據(jù)和控制依賴(lài)。JSP切分自動(dòng)檢測(cè)了需要維持JSP頁(yè)面的數(shù)據(jù)和控制依賴(lài)的部分,因?yàn)殚_(kāi)發(fā)者想要從JSP頁(yè)面中切分這部分。我們使用GUI工具實(shí)施JSP切分,并且證實(shí)切分的JSP片段和JSP頁(yè)面切分之前是以同一方式執(zhí)行的。實(shí)驗(yàn)結(jié)果顯示通過(guò)切分一個(gè)JSP頁(yè)面為片段和為通過(guò)執(zhí)行JSP片段獲得的網(wǎng)頁(yè)片段設(shè)置不同的存儲(chǔ)方法能夠減少訪問(wèn)網(wǎng)頁(yè)的響應(yīng)時(shí)間。1.引言當(dāng)網(wǎng)頁(yè)應(yīng)用服務(wù)器能夠分別的存儲(chǔ)通過(guò)執(zhí)行JSP頁(yè)面的片段獲得的網(wǎng)頁(yè)片段時(shí),把一個(gè)JSP頁(yè)面切分成若干片段能改善一些JSP頁(yè)面的執(zhí)行性能。由于內(nèi)容的動(dòng)態(tài)性,通過(guò)JSP引擎產(chǎn)生的存儲(chǔ)動(dòng)態(tài)網(wǎng)頁(yè)的方法是受限的。當(dāng)通過(guò)JSP引擎產(chǎn)生的網(wǎng)頁(yè)的存儲(chǔ)內(nèi)容被更新,整個(gè)JSP頁(yè)面必須在應(yīng)用服務(wù)器上再次被執(zhí)行,盡管網(wǎng)頁(yè)的改變可能很小。由于存儲(chǔ)網(wǎng)頁(yè)的不斷更新增加應(yīng)用服務(wù)器上的負(fù)載,它合理的把JSP頁(yè)面切分成為若干個(gè)片段,并且為通過(guò)執(zhí)行JSP片段獲得的網(wǎng)頁(yè)片段設(shè)置不同的存儲(chǔ)方法。當(dāng)然,網(wǎng)頁(yè)片段必須被正確的合并為一個(gè)最終的網(wǎng)頁(yè)。IBM的WebSphere應(yīng)用服務(wù)器的動(dòng)態(tài)緩存技術(shù)允許網(wǎng)頁(yè)片段有不同的存儲(chǔ)方法。由ApacheJakarta項(xiàng)目提供的存儲(chǔ)標(biāo)簽庫(kù)也為JSP片段支持不同的存儲(chǔ)方法。另外,ESI(EdgeSideIncludes)技術(shù)為使用不同的存儲(chǔ)方法存儲(chǔ)網(wǎng)頁(yè)片段提供了一個(gè)機(jī)制,并且在一個(gè)邊緣服務(wù)器上把他們合并成一個(gè)最終的網(wǎng)頁(yè)。IBM的WebSphere邊緣服務(wù)器的應(yīng)用卸載技術(shù)是改善JSP頁(yè)面執(zhí)行性能的另一種方法。這種技術(shù)允許一個(gè)或多個(gè)JSP片段在邊緣服務(wù)器上存儲(chǔ)或執(zhí)行。其余的JSP片段部署在應(yīng)用服務(wù)器上并且訪問(wèn)在邊緣服務(wù)器上執(zhí)行的JSP片段。因此,一些JSP頁(yè)面的執(zhí)行被下載到邊緣服務(wù)器上。切分一個(gè)JSP頁(yè)面便于JSP片段的重用。當(dāng)一個(gè)網(wǎng)頁(yè)應(yīng)用包含許多JSP頁(yè)面時(shí),相同的部分傾向于存在許多的JSP頁(yè)面中。例如框架,橫幅,標(biāo)題等。當(dāng)一個(gè)JSP頁(yè)面被切分發(fā)為若干個(gè)片段時(shí),所有片段的總的執(zhí)行結(jié)果必須與在切分之前是一樣的。另外,當(dāng)JSP頁(yè)面的片段在不同的服務(wù)器上執(zhí)行時(shí),每一個(gè)片段需要在沒(méi)有其他片段的時(shí)候執(zhí)行。為了滿足這些條件,我們提出了JSP切分,它是一種在本文中描述的把一個(gè)JSP頁(yè)面切分成若干片段的方法,由于為了一些特別的目的很難自動(dòng)的找到最好的方法來(lái)把JSP頁(yè)面切分成若干個(gè)片段,我們假設(shè)開(kāi)發(fā)者會(huì)選擇他們想要切分的片段的那部分。為了正確的執(zhí)行所有分開(kāi)的JSP頁(yè)面,JSP切分自動(dòng)地檢測(cè)了一些部分,那些部分必須和一些選擇的部分被移動(dòng)或復(fù)制到一個(gè)片段中。這個(gè)檢測(cè)是基于對(duì)存在于JSP頁(yè)面中的數(shù)據(jù)和控制依賴(lài)做的。JSP切分類(lèi)似于程序切片技術(shù),它是基于數(shù)據(jù)和控制依賴(lài)切一個(gè)程序的。然而,程序的切片技術(shù)沒(méi)有考慮到被切的程序能被獨(dú)立的執(zhí)行,以及切的程序的總的執(zhí)行結(jié)果必須和沒(méi)有分離以前是一致的。另外,由于數(shù)據(jù)在JSP頁(yè)面的執(zhí)行中被傳送到JSP引擎,JSP引擎的源程序,例如ApacheTomcat,為了正確的分析數(shù)據(jù)依賴(lài)是必須的。這是不切實(shí)際的,因?yàn)镴SP引擎的源程序是非常大而且復(fù)雜的。JSP切分通過(guò)利用JSP特征避免了JSP引擎的分析。這篇文章的其余編排如下。章節(jié)2解釋了把JSP頁(yè)面切分成若干個(gè)片段的難點(diǎn)。章節(jié)3給出了切分一個(gè)JSP頁(yè)面算法的詳情。章節(jié)4描述了JSP切分工具是JSP切分的實(shí)現(xiàn)工具并演示了由這個(gè)工具是如何把一個(gè)JSP例子切分的。章節(jié)5顯示了通過(guò)在IBMWebSphere應(yīng)用服務(wù)器上使用不同的存儲(chǔ)方法來(lái)執(zhí)行切分JSP片段獲得的實(shí)驗(yàn)的結(jié)果。章節(jié)6討論有關(guān)我們的貢獻(xiàn)的先前的工作。最后一章節(jié)是結(jié)論。2.切分JSP頁(yè)面的難點(diǎn)在這篇文章中,切分一個(gè)JSP頁(yè)面意味著JSP頁(yè)面的一些部分是從JSP頁(yè)面中切出來(lái)的并且保存為新的JSP頁(yè)面。這種新的創(chuàng)建JSP頁(yè)面包括使用一些如jsp(包括標(biāo)簽)的源JSP頁(yè)面。我們稱(chēng)包含的JSP頁(yè)面為JSP片段,并且稱(chēng)調(diào)用JSP片段的JSP頁(yè)面為主JSP頁(yè)面。一個(gè)主JSP頁(yè)面調(diào)用JSP片段并且接受通過(guò)執(zhí)行他們獲得的網(wǎng)頁(yè)片段。然后主JSP頁(yè)面合并它自己的網(wǎng)頁(yè)片段和從JSP片段中接收的網(wǎng)頁(yè)片段,并且創(chuàng)建了一個(gè)最終的網(wǎng)頁(yè)。JSP片段不是總是在同一服務(wù)器和同一時(shí)間執(zhí)行的。應(yīng)用卸載技術(shù)允許主JSP頁(yè)面和JSP片段在不同的服務(wù)器上執(zhí)行。當(dāng)ESI機(jī)制被使用,ESI:包括標(biāo)簽被放入通過(guò)執(zhí)行一個(gè)主JSP頁(yè)面獲得的網(wǎng)頁(yè)片段和在邊緣服務(wù)器上解釋來(lái)支持ESI機(jī)制。在這種情況下,邊緣服務(wù)器會(huì)檢查是否是由ESI指定的網(wǎng)頁(yè)片段:包括存在于它的緩存中的標(biāo)簽。如果網(wǎng)頁(yè)片段的內(nèi)容沒(méi)有被存儲(chǔ)或者已經(jīng)滿了,JSP片段會(huì)從邊緣服務(wù)器調(diào)用,并且在一個(gè)或多個(gè)應(yīng)用服務(wù)器上執(zhí)行。如果不同的存儲(chǔ)方法能夠考慮通過(guò)執(zhí)行JSP片段獲得的網(wǎng)頁(yè)片段。每一個(gè)JSP片段只有在存儲(chǔ)的內(nèi)容滿時(shí)才被執(zhí)行。這種動(dòng)態(tài)存儲(chǔ)技術(shù),ESI機(jī)制,和存儲(chǔ)標(biāo)簽庫(kù)能夠?yàn)榫W(wǎng)頁(yè)片段提供的不同的存儲(chǔ)方法。當(dāng)JSP頁(yè)面被切分成若干片段,下面的兩個(gè)條件必須滿足,即使主JSP頁(yè)面還是JSP片段沒(méi)有在同一服務(wù)器和同一時(shí)間執(zhí)行。條件.1-1主JSP頁(yè)面和JSP片段的最終執(zhí)行結(jié)果要和JSP頁(yè)面被切分之前一致。條件.1-2每一個(gè)JSP頁(yè)面,無(wú)論是一個(gè)主JSP頁(yè)面還是一個(gè)JSP片段,能夠在沒(méi)有其它JSP頁(yè)面下執(zhí)行。這些條件通過(guò)維持存在于JSP頁(yè)面被切分成片段后的數(shù)據(jù)和控制自由來(lái)滿足。然而,對(duì)開(kāi)發(fā)者來(lái)說(shuō)在一個(gè)JSP頁(yè)面中監(jiān)測(cè)數(shù)據(jù)和控制依賴(lài)是困難的,因?yàn)镴SP頁(yè)面的數(shù)據(jù)和控制流量能夠在JSP頁(yè)面中被分開(kāi),JSP引擎執(zhí)行JSP頁(yè)面,一些Javabeans在JSP頁(yè)面中被使用等等。因此,一個(gè)自然的解決方法需要自動(dòng)地檢測(cè)連接到開(kāi)發(fā)者想要切分的那部分的數(shù)據(jù)依賴(lài)和控制依賴(lài)。程序的切片技術(shù)檢測(cè)了一組程序申明,它通過(guò)分析存在于程序中的數(shù)據(jù)和控制依賴(lài)來(lái)影響程序申明S。一個(gè)程序片包含了檢測(cè)的一組程序申明和申明S。當(dāng)調(diào)試和維護(hù)大的程序時(shí),這個(gè)技術(shù)是有用的。因?yàn)镴SP頁(yè)面通過(guò)使用如ApacheJasper編譯器那樣的編譯器被編譯成servlet程序,JSP切分能夠通過(guò)應(yīng)用程序分化技術(shù)到JSP頁(yè)面中編譯的servlet中獲得。然而,程序切片技術(shù)不足以切分一個(gè)JSP頁(yè)面為片段,因?yàn)檫@個(gè)技術(shù)沒(méi)有考慮到程序切片被獨(dú)立的執(zhí)行。圖1顯示了JSP頁(yè)面例子的一部分和從JSP頁(yè)面中編譯的servlet程序的例子。圖2(a)顯示了從servlet程序中獲得的數(shù)據(jù)依賴(lài)圖表。在這個(gè)程序中,當(dāng)申明S1分配一個(gè)值到一個(gè)變量和申明S2跟S1使用那個(gè)值,一個(gè)真的數(shù)據(jù)依賴(lài)存在于S1和S2之間。這樣一個(gè)數(shù)據(jù)依賴(lài)被記為S1->S2。在圖2(a),基于數(shù)據(jù)依賴(lài),對(duì)于申明S10的程序片包含S1,S9和S10。如果程序片是從servlet程序中切的,剩下的程序申明就有錯(cuò)誤因?yàn)閿?shù)據(jù)依賴(lài)S1->S2,S11和S12和S9->S11和S12是沒(méi)有實(shí)踐。因此,程序切片技術(shù)對(duì)于切分JSP頁(yè)面沒(méi)有做的很好。(a)JSP頁(yè)面部分(b)servlet程序部分圖1.一個(gè)JSP頁(yè)面例子和一個(gè)從JSP頁(yè)面中編譯得到的servlet程序(a)正常的(b)對(duì)out忽略數(shù)據(jù)依賴(lài)圖2.數(shù)據(jù)依賴(lài)圖標(biāo)3.JSP切分在這篇文章中,本文提出JSP切分,把JSP頁(yè)面切分成若干片段的一個(gè)方法。這個(gè)提出的方法分析了從JSP頁(yè)面中編譯的servlet程序的數(shù)據(jù)和控制依賴(lài)。在分析的時(shí)候,JSP切分考慮到切分JSP頁(yè)面會(huì)被獨(dú)立的執(zhí)行,并且可能不會(huì)在同一服務(wù)器和同一時(shí)間執(zhí)行。首先,開(kāi)發(fā)者想要切分為JSP片段的那部分被選擇了。對(duì)于選擇的部分需要滿足條件1-1和1-2來(lái)被檢測(cè)。被檢測(cè)的部分要被分類(lèi)到轉(zhuǎn)移和復(fù)制的部分,并且為了滿足開(kāi)發(fā)者的意圖要被最小化。3.1不容忽略的數(shù)據(jù)依賴(lài)基本上,JSP切分不允許依賴(lài)的申明被分別的切分。然而,如果這個(gè)規(guī)則太嚴(yán)格的被應(yīng)用,在圖1(b)中顯示的申明沒(méi)有能被分化的,因?yàn)閺腟1到S9開(kāi)始有交錯(cuò)的依賴(lài)。這里,我們考慮在圖1(b)里顯示的變量out是怎樣使用的。變量out用于寫(xiě)一些網(wǎng)頁(yè)的文本數(shù)據(jù)。注意out的值能夠從一些JSP引擎中檢索。當(dāng)一個(gè)主JSP頁(yè)面(Jm)包含通過(guò)使用JSP得到的JSP片段Jf:包括標(biāo)簽和JSP引擎兩個(gè)都執(zhí)行,Jm首先檢索JSP引擎中的out的值并且寫(xiě)它自己的文本數(shù)據(jù)到這個(gè)值。接下來(lái),Jm調(diào)用Jf。在被調(diào)用后,Jf也檢索out的值并且寫(xiě)它自己的文本數(shù)據(jù)到這個(gè)值。通過(guò)Jf寫(xiě)的文本數(shù)據(jù)通過(guò)JSP引擎被返回到Jm,并且與Jm寫(xiě)的文本數(shù)據(jù)合并。這意味著out的值能夠被一些JSP頁(yè)面使用并且寫(xiě)入這個(gè)值的文本數(shù)據(jù)由JSP引擎維持。換句話說(shuō),當(dāng)JSP頁(yè)面被切分成為片段時(shí),檢索out的值申明能夠存在于從主JSP頁(yè)面編譯的servlet程序和從JSP片段編譯的servlet程序。因此,對(duì)于變量out的數(shù)據(jù)依賴(lài)在切分JSP頁(yè)面時(shí)能夠被忽略。正如在圖2(a)中顯示的,當(dāng)維持存在于圖1(b)中顯示的servlet程序的數(shù)據(jù)依賴(lài)時(shí)沒(méi)有申明能被切分。然而,如果對(duì)于變量out的數(shù)據(jù)依賴(lài)被忽略,那么數(shù)據(jù)依賴(lài)圖表就會(huì)像圖2(b)中顯示的那樣被改變。像圖2(b)中顯示的那樣使用數(shù)據(jù)依賴(lài)圖表使得從組S9,S10,S11和S12中切分S2變得可能,它不能夠依據(jù)變量book的數(shù)據(jù)依賴(lài)被分化。在被ApacheJasper編譯器編譯的servlet程序中,對(duì)于表1里顯示的變量的數(shù)據(jù)依賴(lài)能和變量out相同的原因被忽略。由于這些變量的值被定義在每個(gè)servlet程序的最高端并且被頻繁的提到,如果數(shù)據(jù)依賴(lài)能夠被保持,那么大多數(shù)申明不能被切分。一般來(lái)講,無(wú)序執(zhí)行對(duì)于沒(méi)有數(shù)據(jù)控制依賴(lài)的申明是允許的。忽略在表1里顯示的變量的數(shù)據(jù)依賴(lài)可能會(huì)產(chǎn)生申明的一個(gè)錯(cuò)誤的執(zhí)行順序。例如,如果在圖1中顯示的S10和S11被切分成一個(gè)JSP片段,并且這個(gè)JSP片段在S11之前被包含了,一個(gè)錯(cuò)誤的網(wǎng)頁(yè)就會(huì)產(chǎn)生。為了避免這種錯(cuò)誤的執(zhí)行結(jié)果,由于已經(jīng)忽略了數(shù)據(jù)依賴(lài)的申明,我們的算法不允許改變。表1.這些變量的數(shù)據(jù)依賴(lài)被忽略3.2.對(duì)于Javabeans數(shù)據(jù)依賴(lài)的分析在一個(gè)JSP頁(yè)面中,Javabeans作為屬性值被頻繁的用來(lái)存儲(chǔ)和檢索數(shù)據(jù)。每一個(gè)Javabean是一個(gè)Java項(xiàng)目并且開(kāi)發(fā)者能夠通過(guò)使用JSP頁(yè)面中的三種標(biāo)簽來(lái)使用Javabeans。●jsp:使用Bean:在它的范圍內(nèi)申明一個(gè)Javabean。當(dāng)這個(gè)Javabean的項(xiàng)目不在它申明的范圍內(nèi),這個(gè)bean就會(huì)被實(shí)例化。Javabeans能夠申明在頁(yè)面,請(qǐng)求,節(jié)或者應(yīng)用的范圍內(nèi)?!駄sp:獲得屬性:稱(chēng)為獲得Javabean項(xiàng)目的方法并且檢索屬性值?!駄sp:設(shè)置屬性:稱(chēng)為設(shè)置Javabean項(xiàng)目的方法并且設(shè)置屬性值。Javabeans必須用jsp申明:在另兩個(gè)操作之前使用Bean標(biāo)簽。這意味著Javabean的申明和Javabean的所有其他的操作必須包含在同一JSP頁(yè)面中。這大大限制了JSP片段的范圍。為了緩和這個(gè)限制。JSP切分允許Javabeans的申明復(fù)制到JSP片段中。為什么Javabeans的申明能夠被復(fù)制的原因是申明沒(méi)有副作用。當(dāng)Javabean對(duì)象在它的范圍內(nèi)還沒(méi)有被實(shí)例化每一個(gè)申明僅僅實(shí)例化了一個(gè)Javabean對(duì)象。換句話說(shuō),一個(gè)Javabean對(duì)象在它的范圍內(nèi)不超過(guò)一次被實(shí)例化,即使申明被復(fù)制到JSP片段中。因此,一些Javabean的操作能夠被切分成片段。當(dāng)一個(gè)屬性值通過(guò)使用JSP來(lái)設(shè)置javabean:設(shè)置屬性標(biāo)簽并且通過(guò)使用JSP從JSPbean中檢索:獲得屬性標(biāo)簽,一個(gè)真實(shí)的數(shù)據(jù)依賴(lài)存在于兩個(gè)操作之間。當(dāng)數(shù)據(jù)依賴(lài)申明不能被分化這個(gè)規(guī)則被應(yīng)用,對(duì)于Javabean的數(shù)據(jù)依賴(lài)操作必須被包含在同一片段中。然而,如果下面的兩個(gè)條件被滿足,當(dāng)兩個(gè)操作被切分后,在JSPbean設(shè)置一個(gè)屬性值的操作和另一個(gè)檢索屬性值的操作之間數(shù)據(jù)依賴(lài)被保持著。條件.2-1Javabean的范圍是“request”,“session”,或者是“application”。條件.2-2切分的JSP頁(yè)面在同一JSP引擎中執(zhí)行。如果這兩個(gè)條件被滿足,JSP切分允許存在于數(shù)據(jù)依賴(lài)中的操作被切分化成不同的JSP頁(yè)面,因?yàn)樵谇蟹值腏SP頁(yè)面執(zhí)行中,Javabean存在于JSP引擎中。因此,切分的部分和由開(kāi)發(fā)者選擇的部分能夠被簡(jiǎn)化。然而,通過(guò)執(zhí)行滿足這兩種條件的切分的JSP頁(yè)面獲得的網(wǎng)頁(yè)片段必須有相同的存儲(chǔ)周期。如果一個(gè)JSP頁(yè)面被執(zhí)行并且這個(gè)值在JSP頁(yè)面中被定義而這個(gè)被定義的值在另一個(gè)頁(yè)面中使用,由于網(wǎng)頁(yè)有效的存儲(chǔ)內(nèi)容沒(méi)有被使用,這是因?yàn)閿?shù)據(jù)依賴(lài)么有被保持。當(dāng)Javabean有頁(yè)面范圍,對(duì)于Javabean的依賴(lài)操作不能被切分。然而,在頁(yè)面范圍內(nèi)為Javabean設(shè)置一個(gè)屬性值的每一操作隨著一個(gè)或多個(gè)檢索相同屬性值的操作能夠被復(fù)制,因?yàn)樵陧?yè)面范圍內(nèi)為Javabean設(shè)置屬性值的操作沒(méi)有副作用。4.JSP切分工具我們作為Eclipse的一個(gè)插件來(lái)實(shí)現(xiàn)JSP切分的。圖7顯示了JSP切分工具的結(jié)構(gòu)。JSP切分編輯介紹了JSP頁(yè)面的源視圖和大綱視圖。開(kāi)發(fā)者通過(guò)或者使用editor或者使用outline選擇他們想要切分的那部分。當(dāng)那部分被開(kāi)發(fā)者選擇后,移掉的或者是復(fù)制的那部分和選擇的那部分被顯示在對(duì)話框里。所有的部分被放進(jìn)由開(kāi)發(fā)者指定的一個(gè)新的JSP頁(yè)面里,在源JSP頁(yè)面中,移掉的部分被替換為<jsp:include>標(biāo)簽。當(dāng)編輯者調(diào)用一個(gè)JSP頁(yè)面時(shí),存在于JSP頁(yè)面的數(shù)據(jù)和控制依賴(lài)被分析。首先,JSP編譯器,它是基于ApacheJasper編譯器的,把一個(gè)JSP頁(yè)面編譯成一個(gè)servlet程序。JSP編譯器把JSP頁(yè)面分成幾部分然后像表2那樣存儲(chǔ),并且為每一部分形成一個(gè)或多個(gè)Java聲明。這時(shí),在JSP頁(yè)面中的每一部分和servlet程序中的一個(gè)或多個(gè)申明之間的映射表被形成。JSP-Servlet映射器轉(zhuǎn)換源組,每一個(gè)都把servlet程序中的依賴(lài)聲明包含在新的組中,每一個(gè)都包含在依賴(lài)的JSP部分中,通過(guò)使用JSP頁(yè)面中的部分和servlet程序聲明之間的映射表。這個(gè)映射表在JSP編譯階段之前就形成了。形成的組被發(fā)送到JSP分離器。
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- DBJ51-T 190-2022 四川省裝配式支吊架抗震技術(shù)標(biāo)準(zhǔn)
- 2024年大學(xué)創(chuàng)新創(chuàng)業(yè)工作總結(jié)
- 《我的時(shí)間管理分享》課件
- 《村鎮(zhèn)銀行介紹》課件
- 新媒體春分營(yíng)銷(xiāo)策略
- 酒店前臺(tái)話務(wù)員工作總結(jié)
- 企業(yè)生涯規(guī)劃圖譜
- 2023-2024年項(xiàng)目部安全培訓(xùn)考試題及答案往年題考
- 2023年-2024年項(xiàng)目部管理人員安全教育培訓(xùn)試題及答案(各地真題)
- 化工生產(chǎn)實(shí)習(xí)報(bào)告合集十篇
- 【9道期末】安徽省宣城市2023-2024學(xué)年九年級(jí)上學(xué)期期末道德與法治試題(含解析)
- 《工程造價(jià)專(zhuān)業(yè)應(yīng)用型本科畢業(yè)設(shè)計(jì)指導(dǎo)標(biāo)準(zhǔn)》
- 倉(cāng)庫(kù)主管2025年終總結(jié)及2025工作計(jì)劃
- 2024年01月11396藥事管理與法規(guī)(本)期末試題答案
- 股權(quán)投資協(xié)議的風(fēng)險(xiǎn)控制
- 山西省晉中市2023-2024學(xué)年高一上學(xué)期期末考試 物理 含解析
- 裝卸工安全培訓(xùn)課件
- 中成藥學(xué)完整版本
- 安全與急救學(xué)習(xí)通超星期末考試答案章節(jié)答案2024年
- 2024-2025學(xué)年度廣東省春季高考英語(yǔ)模擬試卷(解析版) - 副本
- 2024電力安全工器具及小型施工機(jī)具預(yù)防性試驗(yàn)規(guī)程
評(píng)論
0/150
提交評(píng)論