您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 国内外标准规范 > 计算机专业论文译文Spring框架
英文原文Springcontainsalotoffunctionalityandfeatures,whicharewell-organizedinsevenmodulesshowninthediagrambelow.Thissectiondiscusseseachtheofmodulesinturn.TheCorepackageisthemostfundamentalpartoftheframeworkandprovidestheDependencyInjectionfeaturesallowingyoutomanagebeancontainerfunctionality.ThebasicconcepthereistheBeanFactory,whichprovidesafactorypatternremovingtheneedforprogrammaticsingletonsandallowingyoutodecoupletheconfigurationandspecificationofdependenciesfromyouractualprogramlogic.OntopoftheCorepackagesitstheContextpackage,providingawaytoaccessbeansinaframework-stylemanner,somewhatresemblingaJNDI-registry.Thecontextpackageinheritsitsfeaturesfromthebeanspackageandaddssupportfortextmessagingusinge.g.resourcebundles,event-propagation,resource-loadingandtransparentcreationofcontextsby,forexample,aservletcontainer.TheDAOpackageprovidesaJDBC-abstractionlayerthatremovestheneedtodotediousJDBCcodingandparsingofdatabase-vendorspecificerrorcodes.Also,theJDBCpackageprovidesawaytodoprogrammaticaswellasdeclarativetransactionmanagement,notonlyforclassesimplementingspecialinterfaces,butforallyourPOJOs(plainoldjavaobjects).TheORMpackageprovidesintegrationlayersforpopularobject-relationalmappingAPIs,includingJDO,HibernateandiBatis.UsingtheORMpackageyoucanuseallthoseO/R-mappersincombinationwithalltheotherfeaturesSpringoffers,likesimpledeclarativetransactionmanagementmentionedbefore.Spring'sAOPpackageprovidesanAOPAlliancecompliantaspect-orientedprogrammingimplementationallowingyoutodefine,forexample,method-interceptorsandpointcutstocleanlydecouplecodeimplementingfunctionalitythatshouldlogicallyspeakingbeseparated.Usingsource-levelmetadatafunctionalityyoucanincorporateallkindsofbehavioralinformationintoyourcode,alittlelike.NETattributes.Spring'sWebpackageprovidesbasicweb-orientedintegrationfeatures,suchasmultipartfunctionality,initializationofcontextsusingservletlistenersandaweb-orientedapplicationcontext.WhenusingSpringtogetherwithWebWorkorStruts,thisisthepackagetointegratewith.Spring'sWebMVCpackageprovidesaModel-View-Controllerimplementationforweb-applications.Spring'sMVCimplementationisnotjustanyimplementation,itprovidesacleanseparationbetweendomainmodelcodeandwebformsandallowsyoutousealltheotherfeaturesoftheSpringFrameworklikevalidation.Spring'swebMVCframeworkisdesignedaroundaDispatcherServletthatdispatchesrequeststohandlers,withconfigurablehandlermappings,viewresolution,localeandthemeresolutionaswellassupportforuploadfiles.ThedefaulthandlerisaverysimpleControllerinterface,justofferingaModelAndViewhandleRequest(request,response)method.Thiscanalreadybeusedforapplicationcontrollers,butyouwillprefertheincludedimplementationhierarchy,consistingof,forexampleAbstractController,AbstractCommandControllerandSimpleFormController.Applicationcontrollerswilltypicallybesubclassesofthose.Notethatyoucanchooseanappropriatebaseclass:Ifyoudon'thaveaform,youdon'tneedaFormController.ThisisamajordifferencetoStruts.Youcanuseanyobjectasacommandorformobject-there'snoneedtoimplementaninterfaceorderivefromabaseclass.Spring'sdatabindingishighlyflexible,forexample,ittreatstypemismatchesasvalidationerrorsthatcanbeevaluatedbytheapplication,notassystemerrors.Soyoudon'tneedtoduplicateyourbusinessobjects'propertiesasStringsinyourformobjects,justtobeabletohandleinvalidsubmissions,ortoconverttheStringsproperly.Instead,itisoftenpreferabletobinddirectlytoyourbusinessobjects.ThisisanothermajordifferencetoStrutswhichisbuiltaroundrequiredbaseclasseslikeActionandActionForm-foreverytypeofaction.ComparedtoWebWork,Springhasmoredifferentiatedobjectroles.ItsupportsthenotionofaController,anoptionalcommandorformobject,andamodelthatgetspassedtotheview.Themodelwillnormallyincludethecommandorformobjectbutalsoarbitraryreferencedata.Instead,aWebWorkActioncombinesallthoserolesintoonesingleobject.WebWorkdoesallowyoutouseexistingbusinessobjectsaspartofyourform,butonlybymakingthembeanpropertiesoftherespectiveActionclass.Finally,thesameActioninstancethathandlestherequestisusedforevaluationandformpopulationintheview.Thus,referencedataneedstobemodeledasbeanpropertiesoftheActiontoo.Thesearearguablytoomanyrolesforoneobject.Spring'sviewresolutionisextremelyflexible.AControllerimplementationcanevenwriteaviewdirectlytotheresponse,returningnullasModelAndView.Inthenormalcase,aModelAndViewinstanceconsistsofaviewnameandamodelMap,containingbeannamesandcorrespondingobjects(likeacommandorform,containingreferencedata).Viewnameresolutionishighlyconfigurable,eitherviabeannames,viaapropertiesfile,orviayourownViewResolverimplementation.TheabstractmodelMapallowsforcompleteabstractionoftheviewtechnology,withoutanyhassle.Anyrenderercanbeintegrateddirectly,whetherJSP,Velocity,oranyotherrenderingtechnology.ThemodelMapissimplytransformedintoanappropriateformat,suchasJSPrequestattributesoraVelocitytemplatemodel..PluggabilityofotherMVCimplementationsThereareseveralreasonswhysomeprojectswillprefertouseotherMVCimplementations.Manyteamsexpecttoleveragetheirexistinginvestmentinskillsandtools.Inaddition,ther
本文标题:计算机专业论文译文Spring框架
链接地址:https://www.777doc.com/doc-6074594 .html