




已阅读5页,还剩30页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
外文原文Inwebapplications,mostofthetasksisdoneinatopreventtheuserfromlongtimewaitingfortheway.InGooglesearchthisexample,reducethewaitingtimeisessentialtotheuserexperience.Asolutiontotheasynchronoustaskistocreateathreadinusersubmission(tohandleasynchronoustask),butitcannotsolvetheneedtocertaintimeintervalrepeatoperationtasks,orataspecifiedtimerunningtaskeverydaysituations.Letusfromadatabaseofexamplesofstatementstohavealookthetaskschedulingcandotohelpimprovethesystemdesign.Thereportmaybeperplexing,dependingontheuserfordatatypes,andiftheyneedfromoneormoredatabasecollectlargeamountsofdata.Theusermaytakealongtimetorunsuchanon-demandreport.Therefore,weextendthisreportexampleaddtaskschedulingmechanism,sothattheusercanbearrangedinanytheyneedtimetogenerateareport,andinthePDForotherformatinemailtransmission.Userscanmakereportoneverydayinthemorning2:22,thesystemisrunningatlowload;alsocanchoosetoonlyrunataspecifictimeatatime.Bytheadditionoftaskschedulinginreportapplication,wecanaddausefulfunctionfortheproduct,andimprovetheuserexperience.Fortunately,thereisapowerfulopensourcesolutionscanletusinastandardwayintheapplicationofweb(oranyJavaapplication)intheimplementationoftaskscheduling.Thefollowingexampleshowstheapplicationofweb,howtouseQuartztocreateataskschedulingframework.ThisexamplealsousestheStrutsActionframeworkplug-in,sothatinthewebapplicationstartupinitializationtaskschedulingmechanism.StrutsisthemostcommonMVCframework,familiartomostdevelopers.Ofcourse,inadditiontomanyframeworkscanhelptherealizationofMVCmodelinWebapplication.StartupinitializationtaskschedulerwefirstneedtodoiscreateaStrutsplugin,letitcreatetaskschedulerweinthecontainerstartup.Inthefollowingexample,wechooseTomcatasthewebapplicationcontainer,buttheseexamplesinothercontainershouldalsocanrun.WewanttocreateaStrutsplug-inclass,andaddingafewlinesofcodeinstruts-config.xmlinordertomakeitwork.Thispluginhastwoconfigurableparameters:startOnLoadspecifieswhethertostartthetaskschedulerimmediatelyinthecontainerstartup,andstartupDelayspecifiesthewaitingtimebeforestartingthetaskscheduler.Startdelayisveryuseful,becausewemayneedtoperformsomeofthemoreimportantinitializationsteps.Inaddition,youcanalsousethelistenermechanism,inamorecomplicatedwaytonotifySchedulerPlugInwhentostartQuartzScheduler.WewanttocreateaStrutsplug-ininterfacelistoforg.apache.struts.action.PlugInclassSchedulerPlugIn.Strutswillappearintheorderaccordingtotheconfigurationfileinitializeseachplug-in.Specialattentionshouldbepaidtotheinit()methodinthecode,weinitializetherequiredQuartzobjects,andScheduler.Thetaskinformationwewillsubmittoaorg.quartz.Schedulerobject,whichwillbediscussedinthesubsequent.TheSchedulerobjectbyQuartzservletaccordingtoitsinitialconfiguration,theActionServletclassastheStrutsinitialization.JDKprovidesanumberofclasslibraryforprogrammers,andinordertokeepthelibraryreusability,scalabilityandflexibility,whichusealotofdesignpatterns,thispaperwillintroducetouseJDKI/OpackageintheDecoratormode,andusingthismodel,therealizationofanewoutputstreamclass.DecoratormodeDecoratormodeorwrapper(Wrapper),itsmainpurposeistoaddsomeadditionalresponsibilitiestoanobjectdynamically.Comparedwiththesubclass,ithasmoreflexibility.Sometimes,weneedanobjectandnotthewholeclasstoaddsomenewfunctions,forexample,addascrollbarfunctionalitytoatextarea.Wecanusetheinheritancemechanismtoachievethisfunction,butthismethodisnotflexibleenough,wecannotcontrolthetextareaandthescrollbarmodeandtime.Andwhenthetextareaneedtoaddmorefeatures,suchastheborder,youneedtocreateanewclass,andwhenthecombineduseofthesefunctionswillundoubtedlycausedanexplosionrequired.Wecanuseamoreflexibleapproach,istomaketextareaintoascrollbar.Thescrollbarclassisequivalenttoadecorativetextarea.Thisdecoration(scroll)mustanddecoratedcomponent(text)inheritedfromthesameinterface,sothatusersdontneedtocare,decoration,becauseitistransparent.Decorationwillforwardtheuserrequesttotheappropriatecomponent(thatis,calltheappropriatemethod),andmaydosomeextraactionintheforwardingand(suchasaddscroll).Bythismethod,wecanaccordingtodifferentcombinationsoftextregionnesteddecoration,soastoaddanymorefunction.Themethodofaddingfunctionswillnotobjectthisdynamiccausedanexplosion,alsohasmoreflexibility.TheabovemethodistheDecoratormodel,whichdynamicallyaddnewfunctionalitybyaddingdecorativeobjects.Componentcomponentsanddecorativepublicclass,whichdefinesthemethodsofsubclassesmustimplementthe.ConcreteComponentisaspecificcomponentclass,youcanaddnewfeaturesbyaddingdecorationtoit.Decoratorisallthedecorationofpublicclass,whichdefinesthemethod,allthedecorationmustachieveatthesametime,italsoholdsareferencetoComponent,inordertotransmitusersrequesttotheComponent,andpossiblyinforwardingrequestsandperformsomeadditionalaction.ConcreteDecoratorAandConcreteDecoratorBarespecificdecoration,canusethemtodecoratetheconcreteComponent.JDKDecoratorJavaIOpackageprovidesthejava.iopackageusingDecoratormodetorealizeallkindsofinputandoutputstreampackage.Thefollowingexampleofjava.io.OutputStreamanditssubclasses,usedtodiscusstheDecoratormodeinIOsystem.TheOutputStreamisanabstractclass,itisalltheoutputstreampublicclass.ItimplementsOutputStreaminwrite(intb)method,sowecanbeusedtocreateobjectsofoutputcurrent,outputandcompletethespecificformat.ItisequivalenttotheDecoratormodelintheConcreteComponentclass.Similarly,itisalsoinheritfromOutputStream.However,theconstructorisveryspecial,needtopassaOutputStreamreferencetoit,anditwillsaveareferencetothisobject.AndifthereisnospecificOutputStreamobjects,wewillnotbeabletocreateFilterOutputStream.BecauseoutcanbeareferencetotheFilterOutputStreamtype,canalsobeareferencetotheByteArrayOutputStreamandotherspecificoutputstreamclass,sotheuseofmulti-layernestedmanner,wecanaddavarietyofdecorationforByteArrayOutputStream.TheFilterOutputStreamclassisequivalenttotheDecoratormodelintheDecoratorclass,thewrite(intb)methodisasimplecallincomingflowwrite(intb)method,andnottodomore,sothereisnonatureconvectionfordecoration,soitssubclassesmustoverridethismethod,totoachievethepurposeofdecoration.BufferedOutputStreamandDataOutputStreamaretwosubclassofFilterOutputStream,whichcorrespondstotheDecoratormodeofConcreteDecorator,andtheoutputoftheincomingflowofthedifferentdecoration.TakingBufferedOutputStreamasanexample:Thisclassprovidesacachemechanism,whenthecachecapacityreachedthenumberofbyteswrittentotheoutputstreamwillonly.First,itinheritedFilterOutputStream,andcoverstheparentclasswrite(intb)method,inthecalltotheoutputstreamtowritedatachecksthecacheisfull,ifnotfull,dontwrite.Soastorealizethenewfunctionisaddedtotheoutputstreamobjectdynamicpurpose.Below,willusetheDecoratormode,writeanewoutputcurrentisIO.WriteanewoutputflowtounderstandthestructureandprincipleofOutputStreamanditssubclasses,wecanwriteanewoutputstream,toaddthenewfunction.Thispartwillgiveanewoutputflowexample,itwillfiltertobesymbolicspaceoutputstatement.SuchastheneedtooutputJavaIOOutputStream,theoutputisfilteredforjavaioOutputStream.Inthejava.iopackage,notonlytheOutputStreamusestheDecoratordesignpattern,InputStream,Reader,Writerareusedinthismodel.Asaflexible,extensibleclasslibrary,manydesignpatternsareusedinJDK,suchasintheSwingpackageintheMVCmodel,RMIProxymodeletc.ResearchontheJDKmodecannotonlydeepentheunderstandingofthemodel,butalsotoamorethoroughunderstandingofthestructureandcompositionofthelibrary.ProtocoladaptorandconnectorProgramMBeanserverdependsontheprotocoladaptorandconnectorandruntheproxyJavavirtualmachinemanagementforcommunicationapplications.TheprotocoladapterprovidesaregisteredinamanagementcomponentofMBeanserverbyspecificprotocolview.Forexample,aHTMLadaptercanbemanagementcomponentallregistereddisplayedonaWebpage.Adifferentprotocol,providesadifferentview.Theconnectormustalsoprovidemanagementapplicationononesideoftheinterfacetomakeagentandmanageapplicationcommunication,namelyaccordingtodifferentprotocols,theconnectormustprovidetheremoteinterfacesimilartoencapsulatethecommunicationprocess.Whenaremoteapplicationusingthisinterface,youcanthroughthenetworktransparentandagenttointeractwith,andignoretheprotocolitself.AdaptorandconnectorfortheMBeanserverandmanagementapplicationscancommunicate.Therefore,anagenttobemanaged,itmustprovideatleastoneprotocoladapterorconnector.Facingvariousmanagementapplication,theagentcancontainavarietyofdifferentprotocoladaptorandconnector.Thecurrenthasbeenachievedandwillachievetheprotocoladaptorandconnectorincludes:1)RMI2SNMPprotocoladapterconnector)3)IIOPprotocoladapter4)HTMLprotocoladapter5)HTTPconnectorProxyserviceAgentservicecanmanagementcomponentforregisteredtoperformadministrativefunctions.Throughtheintroductionofintelligentmanagement,JMXcanhelpusbuildastrongmanagementsolutions.Agentserviceitselfisamanagementcomponent,canalsobeaMBeanservercontrol.TheJMXspecificationdefinestheproxyserviceare:1)dynamicclassloading,andinstantiateanewclassbymanagementprogramservices,alsocanmakeinlibrarylocalnetwork.2)monitoringservice-monitoringmanagementcomponentpropertyvaluechanges,andthenotificationtoalllistenersthesechanges.3)time-timetosendamessageorasaschedulerusing.4)therelationshipbetweenservice-definitionandmaintaintherelationshipmanagementbetweencomponents.1dynamicclassloadingdynamicclassloadingisobtainedbym-let(managementapplet)servicestodoso,itcanbeseenfromthenetworkonanyURLdownloadandinstantiatethemanagementcomponent,andthenregisteredtotheMBeanserver.InaM-letserviceprocess,firstofallistodownloadam-letfile,thefileisaXMLfile,thecontentsofthefileidentifiesallinformationmanagementcomponent,suchascomponentname,intheMBeanserverobjectthatuniquelyidentifiesthecomponentname.Thenaccordingtothecontentsofthisdocument,them-letservicetocompletetheremainingtasks.Thisprocessistheinstantiation:2monitoringservicesthroughtheuseofmonitoringservice,managementcomponentpropertyvaluewillberegularmonitoring,whichisalwaysinaspecificscope.Changewhenmonitoringtheattributevalueexceededexpectationsdefinedscope,aspecificnotificationwillbeissued.ThecurrentJMXspecificationdefinesthreemonitor:1)countermonitor,monitorcountertypeattributevalue,usuallyasinteger,andonlyaccordingtoacertainlawofincreasing.2)measurementmonitor,monitoringmeasurementtypeattributevalue,usuallyforreal,valuecanbeincreasedorreduced.3)stringmonitor,monitorthestringtypeattributevalue.Eachmonitorisastandardmanagementcomponent,theneedtoprovideservices,canbecreatedbymanagementcomponentcorrespondingorremotemanagementapplicationsdynamicallyandconfigurationregister.3timebusinesshoursservicecanbeissuedacircularintheformulationofthedateandtime,canalsobeperiodicregularnotice,relyonmanagementapplicationconfiguration.Thetimeserviceisalsoamanagementcomponent,itcanhelpthemanagementapplicationproceduresfortheestablishmentofaconfigurationofthememorandum,soastorealizeintelligentmanagementservice.4therelationshipbetweenserviceJMXspecificationdefinestherelationshipmodelbetweenthemanagementcomponent.ArelationshipisNdimensionalrelationshipbetweenmanagementcomponentuserdefined.Relationmodelisdefinedasfollows:1)theroleofsometerms:isisamemberofarelationshipbetweentheidentity,itcontainsacharactervalue.2)roleinformation:describearoleinarelationship.3)relationshiptypes:composedofcharacterinformation,tocreateandsustainarelationshipastemplate.4)relationship:therelationshipmanagementamongmembers,andmustmeettherequirementsofarelationshiptype.5)rolevalue:inarelationshipinthecurrentlistmanagementcomponentcansatisfythegivenrole.6)therelationshipbetweenservice:isamanagementcomponent,cancontactandmaintainconsistencybetweenalltypesofrelationshipandrelationshipinstances.Intherelationshipbetweenservices,relationshipmanagementbetweencomponentsbyinstancerelationshiptypeisdeterminedtomaintain.OnlyregisteredtotheMBeanserverandcanbethenameoftheobjectidentifiermanagementcomponentcanbecomeamemberofarelationship.Therelationshipbetweenserviceneverdirectly-managementcomponentofit,inordertofacilitatethesearchitonlyprovidesthenameoftheobject.Therelationshipbetweenservicecancreate,lockingisnotreasonablerelationshiptypessimilarly,creatingunreasonablerelationswillbelocked.Correctionrolevaluealsoshouldobeytheconsistencycheck.Becausetherelationshipisdefinedbetweenthemanagementcomponentregistrationcontact,sowhenthemanagementcomponentwhichisunloaded,willchangearelationship.Therelationshipbetweenservicewillautomaticallychangetherolevalue.Alltherelationshipinstanceoperationssuchascreate,update,deleteandsoonwillmaketherelationshipbetweenserviceissuedanotice,notificationwillprovideinformationabouttheoperation.OnlymodelJMXrelationshiptoensuremanagementcomponentallmeetthedesigncharacterofit,thatistosay,doesnotpermitamanagementcomponentappearsinmanyrelationshipsatthesametime.DistributedservicelayerAtpresent,theSUNandthereisnospecificnormsgiventhislayer,onlyabriefdescriptionisgivenbelow.ThislayerspecifiestheimplementationofJMXapplicationmanagementplatforminterface.Thislayerdefinesthemanagementinterfaceandcomponentcanoperateontheagentlayer.Thesecomponentscanbe:1)providesaninterfaceformanagingapplication,soitthroughaconnectorcanbetransparentandagentlayerorJMXmanagementresourcesinteract.2)mappingthroughvariousprotocols(suchasSNMP,HTMLetc.),providesaJMXagentandallthemanagementcomponentview.3)distributionmanagementinformation,inordertoconstructadistributedsystem,therewillbeJMXagentmanagementinformationmanagementplatformtothelargenumberofrelease.4)managementinformationcollectedanumberofJMXproxyclientandscreeningareofinteresttotheuseraccordingtotheneedsofmanagementofuserinformationandtheformationofterminaluserstotheappropriatelogicalview.5)providessecurityassurance.Throughthejointmanagementapplicationlayerandamanagementagentandhisequipmentlayer,canprovideacompletenetworkmanagementsolutionstoour.Thissolutionbringssomeadvantagesoftheoneandonlyforus:light,accordingtotheneedsofthedeployment,dynamicservices,andsecurity.TheJavaServerPages(JSP)isakindofaccordingtowebofthescriptplaitdistancetechnique,similarcarriesthescriptlanguageofJavaintheserveroftheNetscapecompanyofserver-sideJavaScript(SSJS)andtheActiveServerPages(ASP)oftheMicrosoft.JSPcomparestheSSJSandASPtohavebettercanexpandsex,anditisnomoreexclusivethananyfactoryorsomeoneparticularserverofWeb.ThoughthenormofJSPistobedrawupbytheSuncompanyof,anyfactorycancarryouttheJSPonownsystem.IfJavais,infact,yetanothercomputerprogramminglanguage,youmayquestionwhyitissoimportantandwhyitisbeingpromotedasarevolutionarystepincomputerprogramming.Theanswerisntimmediatelyobviousifyourecomingfromatraditionalprogrammingperspective.AlthoughJavaisveryusefulforsolvingtraditionalstand-aloneprogrammingproblems,itisalsoimportantbecauseitwillsolveprogrammingproblemsontheWorldWideWeb.TheWebsinitialserver-browserdesignprovidedforinteractivecontent,buttheinteractivitywascompletelyprovidedbytheserver.Theserverproducedstaticpagesfortheclientbrowser,whichwouldsimplyinterpretanddisplaythem.BasicHTMLcontainssimplemechanismsfordatagathering:text-entryboxes,checkboxes,radioboxes,listsanddrop-downlists,aswellasabuttonthatcanonlybeprogrammedtoresetthedataontheformor“submit”thedataontheformbacktotheserver.ThissubmissionpassesthroughtheCommonGatewayInterface(CGI)providedonallWebservers.ThetextwithinthesubmissiontellsCGIwhattodowithit.Themostcommonactionistorunaprogramlocatedontheserverinadirectorythatstypicallycalled“cgi-bin.”(IfyouwatchtheaddresswindowatthetopofyourbrowserwhenyoupushabuttononaWebpage,youcansometimessee“cgi-bin”withinallthegobbledygookthere.)Theseprogramscanbewritteninmostlanguages.Perlisacommonchoicebecauseitisdesignedfortextmanipulationandisinterpreted,soitcanbeinstalledonanyserverregardlessofprocessororoperatingsystem.ManypowerfulWebsitestodayarebuiltstrictlyonCGI,andyoucaninfactdonearlyanythingwithit.However,WebsitesbuiltonCGIprogramscanrapidlybecomeoverlycomplicatedtomaintain,andthereisalsotheproblemofresponsetime.TheresponseofaCGIprogramdependsonhowmuchdatamustbesent,aswellastheloadonboththeserverandtheInternet.(Ontopofthis,startingaCGIprogramtendstobeslow.)TheinitialdesignersoftheWebdidnotforeseehowrapidlythisbandwidthwouldbeexhaustedforthekindsofapplicationspeopledeveloped.Forexample,anysortofdynamicgraphingisnearlyimpossibletoperformwithconsistencybecauseaGIFfilemustbecreatedandmovedfromtheservertotheclientforeachversionofthegraph.Andyouvenodoubthaddirectexperiencewithsomethingassimpleasvalidatingthedataonaninputform.Youpressthesubmitbuttononapage;thedataisshippedbacktotheserver;theserverstartsaCGIprogramthatdiscoversanerror,formatsanHTMLpageinformingyouoftheerror,andthensendsthepagebacktoyou;youmustthenbackupapageandtryagain.Notonlyisthisslow,itsinelegant.Thesolutionisclient-sideprogramming.MostmachinesthatrunWebbrowsersarepowerfulenginescapableofdoingvastwork,andwiththeoriginalstaticHTMLapproachtheyaresittingthere,justidlywaitingfortheservertodishupthenextpage.Client-sideprogrammingmeansthattheWebbrowserisharnessedtodowhateverworkitcan,andtheresultfortheuserisamuchspeedierandmoreinteractiveexperienceatyourWebsite.Theproblemwithdiscussionsofclient-sideprogrammingisthattheyarentverydifferentfromdiscussionsofprogrammingingeneral.Theparametersarealmostthesame,buttheplatformisdifferent:aWebbrowserislikealimitedoperatingsystem.Intheend,youmuststillprogram,andthisaccountsforthedizzyingarrayofproblemsandsolutionsproducedbyclient-sideprogramming.Therestofthissectionprovidesanoverviewoftheissuesandapproachesinclient-sideprogramming.Oneofthemostsignificantstepsforwardinclient-sideprogrammingisthedevelopmentoftheplug-in.Thisisawayforaprogrammertoaddnewfunctionalitytothebrowserbydownloadingapieceofcodethatplugsitselfintotheappropriatespotinthebrowser.Ittellsthebrowser“fromnowonyoucanperformthisnewactivity.”(Youneedtodownloadtheplug-inonlyonce.)Somefastandpowerfulbehaviorisaddedtobrowsersviaplug-ins,butwritingaplug-inisnotatrivialtask,andisntsomethingyoudwanttodoaspartoftheprocessofbuildingaparticularsite.Thevalueoftheplug-inforclient-sideprogrammingisthatitallowsanexpertprogrammertodevelopanewlanguageandaddthatlanguagetoabrowserwithoutthepermissionofthebrowsermanufacturer.Thus,plug-insprovidea“backdoor”thatallowsthecreation
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 健美操与健身市场的跨界融合趋势
- 高效能抽水蓄能技术的突破方向
- 2025欧元借款合同范文
- 跨学科协同模式在医学教育中的应用
- 小麦抗白粉病性状的遗传基础研究
- 幼儿多元智能激活
- 答辩秘籍模板
- 公司绿色行动深度解析
- 塑造健康生活模式
- 手工艺术探秘
- 河南省南阳市邓州市2023-2024学年七年级下学期期末生物试题(解析版)
- emc能源管理合同
- 湖北省襄阳樊城区七校联考2025届化学九上期中统考模拟试题含解析
- 幼儿园语言故事《一顶大草帽》课件
- 2024年云南省中考历史试卷(附答案)
- +期末测试卷(试题)-2023-2024学年四年级下册数学人教版
- 人工智能设计伦理智慧树知到期末考试答案章节答案2024年浙江大学
- 2024春期国开电大本科《经济学(本)》在线形考(形考任务1至6)试题及答案
- 银行保安员管理考核办法
- 特殊感染手术处理流程
- 【特殊场景条款】物流运输车辆租赁合同(标准版)
评论
0/150
提交评论