毕业论文外文翻译-Spring 框架简介.docx
《毕业论文外文翻译-Spring 框架简介.docx》由会员分享,可在线阅读,更多相关《毕业论文外文翻译-Spring 框架简介.docx(25页珍藏版)》请在冰豆网上搜索。
IntroducingtheSpringFramework
TheSpringFramework:
apopularopensourceapplicationframeworkthataddressesmanyoftheissuesoutlinedinthisbook.ThischapterwillintroducethebasicideasofSpringanddis-cussthecentral"beanfactory"lightweightInversion-of-Control(loC)containerindetail.
Springmakesitparticularlyeasytoimplementlightweight,yetextensible,J2EEarchi-tectures.Itprovidesanout—of—the—boximplementationofthefundamentalarchitecturalbuildingblockswerecommend.Springprovidesaconsistentwayofstructuringyourapplications,andprovidesnumerousmiddletierfeaturesthatcanmakeJ2EEdevelopmentsignificantlyeasierandmoreflexiblethanintraditionalapproaches.
ThebasicmotivationsforSpringare:
Toaddressareasnotwellservedbyotherframeworks.TherearenumerousgoodsolutionstospecificareasofJ2EEinfrastructure:
webframeworks,persistencesolutions,remotingtools,andsoon.However,integratingthesetoolsintoacomprehensivearchitecturecaninvolvesignificanteffort,andcanbecomeaburden.Springaimstoprovideanend-to-endsolution,integratingspe-cializedframeworksintoacoherentoverallinfrastructure.Springalsoaddressessomeareasthatotherframeworksdon't.Forexample,fewframeworksaddressgenerictransactionmanagement,dataaccessobjectimplementation,andgluingallthosethingstogetherintoanapplication,whilestillallowingforbest-of-breedchoiceineacharea.HencewetermSpringanapplicationframework,ratherthanawebframework,loCorAOPframework,orevenmiddletierframework.
Toallowforeasyadoption.Aframeworkshouldbecleanlylayered,allowingtheuseofindi-vidualfeatureswithoutimposingawholeworldviewontheapplication.ManySpringfeatures,suchastheJDBCabstractionlayerorHibernateintegration,canbeusedinalibrarystyleoraspartoftheSpringend-to-endsolution.
Todelivereaseofuse.Aswe'venoted,J2EEoutoftheboxisrelativelyhardtousetosolvemanycommonproblems.Agoodinfrastructureframeworkshouldmakesimpletaskssimpletoachieve,withoutforcingtradeoffsforfuturecomplexrequirements(likedistributedtransactions)ontheapplicationdeveloper.ItshouldallowdeveloperstoleverageJ2EEservicessuchasJTAwhereappropriate,buttoavoiddependenceonthemincaseswhentheyareunnecessarilycomplex.
Tomakeiteasiertoapplybestpractices.Springaimstoreducethecostofadheringtobestpracticessuchasprogrammingtointerfaces,ratherthanclasses,almosttozero.However,itleavesthechoiceofarchitecturalstyletothedeveloper.
Non-invasiveness.Applicationobjectsshouldhaveminimaldependenceontheframework.IfleveragingaspecificSpringfeature,anobjectshoulddependonlyonthatparticularfeature,whetherbyimplementingacallbackinterfaceorusingtheframeworkasaclasslibrary.loCandAOParethekeyenablingtechnologiesforavoidingframeworkdependence.
Consistentconfiguration.Agoodinfrastructureframeworkshouldkeepapplicationconfigurationflexibleandconsistent,avoidingtheneedforcustomsingletonsandfactories.Asinglestyleshouldbeapplicabletoallconfigurationneeds,fromthemiddletiertowebcontrollers.
Easeoftesting.Testingeitherwholeapplicationsorindividualapplicationclassesinunittestsshouldbeaseasyaspossible.Replacingresourcesorapplicationobjectswithmockobjectsshouldbestraightforward.
Toallowforextensibility.BecauseSpringisitselfbasedoninterfaces,ratherthanclasses,itiseasytoextendorcustomizeit.
ManySpringcomponentsusestrategyinterfaces,allowingeasycustomization.
ALayeredApplicationFramework
Chapter6introducedtheSpringFrameworkasalightweightcontainer,competingwithloCcontainerssuchasPicoContainer.WhiletheSpringlightweightcontainerforJavaBeansisacoreconcept,thisisjustthefoundationforasolutionforallmiddlewarelayers.
BasicBuildingBlocks
pringisafull-featuredapplicationframeworkthatcanbeleveragedatmanylevels.Itconsistsofmulti-plesub-frameworksthatarefairlyindependentbutstillintegratecloselyintoaone-stopshop,ifdesired.Thekeyareasare:
Beanfactory.TheSpringlightweightloCcontainer,capableofconfiguringandwiringupJava-BeansandmostplainJavaobjects,removingtheneedforcustomsingletonsandadhocconfigura-1ion.Variousout-of—the—boximplementationsincludeanXML-basedbeanfactory.ThelightweightloCcontaineranditsDependencyInjectioncapabilitieswillbethemainfocusofthischapter.
Applicationcontext.ASpringapplicationcontextextendsthebeanfactoryconceptbyaddingsupportformessagesourcesandresourceloading,andprovidinghooksintoexistingenviron-ments.Variousout-of-the~boximplementationsincludestandaloneapplicationcontextsandanXML-basedwebapplicationcontext.
AO