爱问 爱问共享资料 爱问分类
首页 > > > Spring in Action 2.pdf

Spring in Action 2.pdf

Spring in Action 2.pdf

上传者: bosshida
638次下载 0人收藏 暂无简介 简介 2012-03-04 举报

简介:in action 系列,spring

PraisefortheFirstEdition“Thisisoneofthoserarebooksthatconnectatutorialforusingacertainsoftwareproductwithaplethoraofideasongoodsoftwaredesignanddesignpatterns.Ienjoyedthisbookverymuch...”—ComputingReviews“Coversalorganized“...easyto“WhileSpSpringmuentertainin“Trulyagenterpriseservicesthaaccessprogme,thereisandeditedpaidatten“Acompletmeanitis...[it]explmakesthemimplementabouttheframeworkSpringinhlthebaseswithextensiveexamplesandexplicitinstructions...asuperblyandfluentlywritteninstructionandreferencemanual.”—InternetBookwatchread...andhasjustenoughhumormixedin...”—Books-On-Linering’sreferencedocumentationishighquality,thisbookmakeslearningchmoreenjoyable.Thebookinjectsafairamountofhumorthatkeepsitg.IfyouwanttolearnSpring,youcan’tgowrongwiththisoffering.”—BillSiggelkow’sWeblogAuthorofJakartaStrutsCookbookreatresource...ThebookclearlydefinesthepowerthatSpringbringstoprogrammersandhowSpringabstractsawaymanyofthetougherJ2EEtmostseriousapplicationsuse.Thebookhasbeenthrougharigorousearlyram,sothankfullygrammarandcodeerrorsareallbutnon-existent.Tonothingworsethantryingtolearnanewtechnologyfromapoorlywrittentechnicalbook.Thankfully,Craig,Ryan,andtheManningteamhavetiontodetailandproducedabookthatIhighlyrecommend.”—JavaLobby.orgereferencemanualthatcoversnearlyeveryaspectofSpring.Thisdoesn’tcomplicated:everyexplanationisclearandtherearealotofcodeexamples.ainsclearlywhat“InversionofControl”andAOPmeanandhowSpringpossible....howyoucanwriteservicesandDaos,andhowyoucansimplytransactionmanagementandserviceremoting....thethirdparttalksWeblayercoveringSpringMVCaswellasothertechnologiesands....Overallanexcellentresourceforanydeveloperinterestedinusingisproject.”—JavaUserGroupMilanoSpringinActionSecondEditionCRAIGWALLSwithRyanBreidenbachMANNINGGreenwich(74w.long.)ForonlineinformationandorderingofthisandotherManningbooks,pleasevisitwww.manning.com.Thepublisheroffersdiscountsonthisbookwhenorderedinquantity.Formoreinformation,pleasecontact:SpecialSalesDepartmentManningPublicationsCo.SoundViewCourt3BFax:(609)877-8256Greenwick,CT06830Email:orders@manning.com2008byManninNopartofthispuanyformorbymepermissionoftheManyofthedesigclaimedastrademPublicationswasaorallcaps.RecognizingtheithebookswepubManningPuSoundViewGreenwich,ISBN1-933988-13PrintedintheUn12345678gPublicationsCo.Allrightsreserved.blicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanselectronic,mechanical,photocopying,orotherwise,withoutpriorwrittenpublisher.nationsusedbymanufacturersandsellerstodistinguishtheirproductsarearks.Wherethosedesignationsappearinthebook,andManningwareofatrademarkclaim,thedesignationshavebeenprintedininitialcapsmportanceofpreservingwhathasbeenwritten,itisManning’spolicytohavelishprintedonacid-freepaper,andweexertourbesteffortstothatend.blicationsCo.Copyeditor:LizWelchCourt3BTypesetter:DottieMarsicoCT06830Coverdesigner:LeslieHaimes-4itedStatesofAmerica910–MAL–13121110090807FormywifeRaymieandmydaughtersMaisyandMadisonIamendlesslymystifiedastohowImerittheloveoftheworld’sthreemostbeautifulgirls.PART1COPART2ENbriefcontentsRESPRING...............................................................11Springingintoaction32Basicbeanwiring313Advancedbeanwiring724Advisingbeans116TERPRISESPRING.................................................1535Hittingthedatabase1556Managingtransactions2207SecuringSpring2478SpringandPOJO-basedremoteservices3059Buildingcontract-firstwebservicesinSpring34310Springmessaging38411SpringandEnterpriseJavaBeans423vii12Accessingenterpriseservices441viiiBRIEFCONTENTSPART3CLIENT-SIDESPRING..................................................48713Handlingwebrequests48914Renderingwebviews533apap15UsingSpringWebFlow58016Integratingwithotherwebframeworks623pendixASettingupSpring667pendixBTestingwith(andwithout)Spring678PART11contentsprefacexixprefacetothefirsteditionxxiiacknowledgmentsxxvaboutthisbookxxviiaboutthetitlexxxiiiaboutthecoverillustrationxxxivCORESPRING................................................1Springingintoaction31.1WhatisSpring?5Springmodules61.2ASpringjumpstart111.3Understandingdependencyinjection14Injectingdependencies14Dependencyinjectioninaction15Dependencyinjectioninenterpriseapplications211.4Applyingaspect-orientedprogramming24ixIntroducingAOP24AOPinaction261.5Summary30xCONTENTS2Basicbeanwiring312.1Containingyourbeans33IntroducingtheBeanFactory34Workingwithanapplication3context35Abean’slife372.2Creatingbeans40Declaringasimplebean40Injectingthroughconstructors422.3Injectingintobeanproperties46Injectingsimplevalues47Referencingotherbeans48Wiringcollections52Wiringnothing(null)582.4Autowiring58Thefourtypesofautowiring59Mixingautowithexplicitwiring63Toautowireornottoautowire632.5Controllingbeancreation64Beanscoping65Creatingbeansfromfactorymethods66Initializinganddestroyingbeans682.6Summary71Advancedbeanwiring723.1Declaringparentandchildbeans73Abstractingabasebeantype74Abstractingcommonproperties763.2Applyingmethodinjection79Basicmethodreplacement80Usinggetterinjection833.3Injectingnon-Springbeans853.4Registeringcustompropertyeditors883.5WorkingwithSpring’sspecialbeans92Postprocessingbeans93Postprocessingthebeanfactory95Externalizingconfigurationproperties96Resolvingtextmessages99Decouplingwithapplicationevents101Makingbeansaware1033.6Scriptingbeans106Puttingthelimeinthecoconut107Scriptingabean108Injectingpropertiesofscriptedbeans111Refreshingscriptedbeans112Writingscriptedbeansinline1133.7Summary114CONTENTSxi4Advisingbeans1164.1IntroducingAOP118DefiningAOPterminology119Spring’sAOPsupport122PART254.2CreatingclassicSpringaspects125Creatingadvice127Definingpointcutsandadvisors132UsingProxyFactoryBean1364.3Autoproxying139CreatingautoproxiesforSpringaspects140Autoproxying@AspectJaspects1414.4Declaringpure-POJOaspects1454.5InjectingAspectJaspects1494.6Summary152ENTERPRISESPRING.................................153Hittingthedatabase1555.1LearningSpring’sdataaccessphilosophy157GettingtoknowSpring’sdataaccessexceptionhierarchy158Templatingdataaccess161UsingDAOsupportclasses1635.2Configuringadatasource165UsingJNDIdatasources165Usingapooleddatasource167JDBCdriver-baseddatasource1685.3UsingJDBCwithSpring170TacklingrunawayJDBCcode170WorkingwithJDBCtemplates173UsingSpring’sDAOsupportclassesforJDBC1805.4IntegratingHibernatewithSpring183ChoosingaversionofHibernate185UsingHibernatetemplates186BuildingHibernate-backedDAOs190UsingHibernate3contextualsessions1925.5SpringandtheJavaPersistenceAPI194UsingJPAtemplates194Configuringanentitymanagerfactory197BuildingaJPA-backedDAO202xiiCONTENTS5.6SpringandiBATIS203ConfiguringaniBATISclienttemplate204BuildinganiBATIS-backedDAO2075.7Caching20867Configuringacachingsolution210Proxyingbeansforcaching215Annotation-drivencaching2175.8Summary218Managingtransactions2206.1Understandingtransactions222Explainingtransactionsinonlyfourwords223UnderstandingSpring’stransactionmanagementsupport2246.2Choosingatransactionmanager225JDBCtransactions226Hibernatetransactions227JavaPersistenceAPItransactions227JavaDataObjectstransactions228JavaTransactionAPItransactions2296.3ProgrammingtransactionsinSpring2296.4Declaringtransactions232Definingtransactionattributes233Proxyingtransactions238DeclaringtransactionsinSpring2.0241Definingannotation-driventransactions2436.5Summary245SecuringSpring2477.1IntroducingSpringSecurity2487.2Authenticatingusers252Configuringaprovidermanager253Authenticatingagainstadatabase256AuthenticatingagainstanLDAPrepository2647.3Controllingaccess271Votingaccessdecisions272Castinganaccessdecisionvote273Handlingvoterabstinence275CONTENTSxiii7.4Securingwebapplications275ProxyingSpringSecurity’sfilters278Handlingthesecuritycontext285Promptingtheusertologin286Handlingsecurityexceptions291Enforcingwebsecurity293Ensuringasecurechannel294897.5View-layersecurity297Conditionallyrenderingcontent298Displayinguserauthenticationinformation2997.6Securingmethodinvocations300Creatingasecurityaspect301Securingmethodsusingmetadata3037.7Summary304SpringandPOJO-basedremoteservices3058.1AnoverviewofSpringremoting3068.2WorkingwithRMI309WiringRMIservices310ExportingRMIservices3128.3RemotingwithHessianandBurlap316AccessingHessian/Burlapservices317ExposingbeanfunctionalitywithHessian/Burlap3188.4UsingSpring’sHttpInvoker322AccessingservicesviaHTTP323ExposingbeansasHTTPServices3248.5Springandwebservices326ExportingbeansaswebservicesusingXFire326DeclaringwebserviceswithJSR-181annotations330Consumingwebservices333ProxyingwebserviceswithanXFireclient3408.6Summary341Buildingcontract-firstwebservicesinSpring3439.1IntroducingSpring-WS3459.2Definingthecontract(first!)347CreatingsampleXMLmessages348xivCONTENTS9.3Handlingmessageswithserviceendpoints353BuildingaJDOM-basedmessageendpoint355Marshalingmessagepayloads35810119.4Wiringitalltogether361Spring-WS:Thebigpicture361Mappingmessagestoendpoints363Wiringtheserviceendpoint364Configuringamessagemarshaler364Handlingendpointexceptions367ServingWSDLfiles369Deployingtheservice3739.5ConsumingSpring-WSwebservices373Workingwithwebservicetemplates374Usingwebservicegatewaysupport3819.6Summary382Springmessaging38410.1AbriefintroductiontoJMS386ArchitectingJMS387AssessingthebenefitsofJMS390SettingupActiveMQinSpring39210.2UsingJMSwithSpring393TacklingrunawayJMScode393WorkingwithJMStemplates395Convertingmessages402UsingSpring’sgatewaysupportclassesforJMS40510.3Creatingmessage-drivenPOJOs407Creatingamessagelistener408Writingpure-POJOMDPs41210.4Usingmessage-basedRPC416IntroducingLingo417Exportingtheservice418ProxyingJMS42010.5Summary422SpringandEnterpriseJavaBeans42311.1WiringEJBsinSpring425Proxyingsessionbeans(EJB2.x)426WiringEJBsintoSpringbeans43011.2DevelopingSpring-enabledEJBs(EJB2.x)431CONTENTSxv11.3SpringandEJB3434IntroducingPitchfork435GettingstartedwithPitchfork436Injectingresourcesbyannotation437Declaringinterceptorsusingannotations43812PART31311.4Summary440Accessingenterpriseservices44112.1WiringobjectsfromJNDI442WorkingwithconventionalJNDI443InjectingJNDIobjects446WiringJNDIobjectsinSpring244912.2Sendingemail450Configuringamailsender451Constructingtheemail45312.3Schedulingtasks456SchedulingwithJava’sTimer457UsingtheQuartzscheduler460Invokingmethodsonaschedule46412.4ManagingSpringbeanswithJMX466ExportingSpringbeansasMBeans467RemotingMBeans477Handlingnotifications48212.5Summary485CLIENT-SIDESPRING..................................487Handlingwebrequests48913.1GettingstartedwithSpringMVC490Adayinthelifeofarequest491ConfiguringDispatcherServlet492SpringMVCinanutshell49513.2Mappingrequeststocontrollers502UsingSimpleUrlHandlerMapping503UsingControllerClassNameHandlerMapping504Usingmetadatatomapcontrollers505Workingwithmultiplehandlermappings50513.3Handlingrequestswithcontrollers506Processingcommands509Processingformsubmissions512Processingcomplexformswithwizards520Workingwiththrowawaycontrollers528xviCONTENTS13.4Handlingexceptions53113.5Summary53214Renderingwebviews5331514.1Resolvingviews534Usingtemplateviews535Resolvingviewbeans537Choosingaviewresolver54014.2UsingJSPtemplates542Bindingformdata542Renderingexternalizedmessages544Displayingerrors54714.3LayingoutpageswithTiles549Tileviews550CreatingTilecontrollers55414.4WorkingwithJSPalternatives556UsingVelocitytemplates557WorkingwithFreeMarker56414.5Generatingnon-HTMLoutput569ProducingExcelspreadsheets570GeneratingPDFdocuments573Developingcustomviews57614.6Summary578UsingSpringWebFlow58015.1GettingstartedwithSpringWebFlow582InstallingSpringWebFlow584SpringWebFlowessentials589Creatingaflow59115.2Layingtheflowgroundwork591Flowvariables591Startandendstates593Gatheringcustomerinformation594Buildingapizzaorder601Completingtheorder605Afewfinishingtouches60815.3Advancedwebflowtechniques611Usingdecisionstates612Extractingsubflowsandusingsubstates61415.4IntegratingSpringWebFlowwithotherframeworks619JakartaStruts619JavaServerFaces62015.5Summary622CONTENTSxvii16Integratingwithotherwebframeworks62316.1UsingSpringwithStruts624RegisteringtheSpringplug-inwithStruts626WritingSpring-awareStrutsactions627DelegatingtoSpring-configuredappendixAappendixBwebcontentwebchappenappenappenappenactions629WhataboutStruts2?63216.2WorkingSpringintoWebWork2/Struts263316.3IntegratingSpringwithTapestry636IntegratingSpringwithTapestry3637IntegratingSpringwithTapestry464116.4PuttingafaceonSpringwithJSF643ResolvingJSF-managedproperties644ResolvingSpringbeans646UsingSpringbeansinJSFpages646ExposingtheapplicationcontextinJSF64816.5Ajax-enablingapplicationsinSpringwithDWR648Directwebremoting650AccessingSpring-managedbeansDWR65916.6Summary664SettingupSpring667Testingwith(andwithout)Spring678index707apterBuildingportletapplicationsdixCSpringXMLconfigurationreferencedixDSpringJSPtaglibraryreferencedixESpringWebFlowdefinitionreferencedixFCustomizingSpringconfigurationItwasDinMiamworldwforasinWhasurf,wemoreaOnRodJohofSprinbersofinthenHecaughtavailablRodinSpringThemadeliversionIndeedcapabilprefaceecember7,2005.IwasstandingatthesideofalargehotelmeetingroomiBeach,Florida.TheroomwasfilledwithdevelopersfromalloverthehohaddescendeduponthebeautifulsandybeachesofsouthernFloridaglepurpose:totalkaboutSpring.tcanIsay?Itwasaroomfullofnerds.Ratherthansoakinthesunandallgatheredinsidetobaskinthewarmglowofourlaptopscreenstolearnboutourbelovedframeworkfromthosewhoknowitbest.thatparticularnight,wewerehangingonthewordsofSpring’screator,nson,ashepresentedtheopeningkeynotefortheconference.Hespokeg’soriginsandthesuccessesithadenjoyed.Thenheinvitedafewmem-theSpringteamtothepodiumtointroducenewfeaturesthatweretobeextversion.wasn’tfarintohispresentationwhenRodmadeanannouncementthateveryone’sattention.WewereallexpectingthesegreatnewfeaturestobeeinSpring1.3,thesupposednextversionofSpring.Muchtooursurprise,formedusthattherewouldbenoSpring1.3;thenextversionwouldbe2.0.decisiontobumpupthemajorversionnumberofthenextreleaseisn’tghtly.SuchanactionconnotesasignificantadvanceinSpring.IfthenextxixofSpringwouldbe2.0,thenwecouldexpectmajorenhancements.,tenmonthslater,Spring2.0wouldbereleasedwithanabundanceofnewities,including:xxPREFACESimplifiedXMLconfigurationandtheoptiontocreatecustomconfigura-tionelementsGreatlysimplifiedAOPandtransactionsSupportforJava5annotationsfordeclaringaspects,transactions,andrTSNImcASoSEwTcAtoneintrodua2.0reThawork,stionalcSoXSSaDLrequiredbeanpropertiesheabilitytocreatebeansfromscriptswritteninJRuby,Groovy,orBean-hellewJDBCtemplatestosupportnamedparametersandJava5featuresprovedJMSsupport,includingreceivingmessagesasynchronously(forreatingmessage-drivenPOJOs)newform-bindingJSPtaglibraryeveralconvention-over-configurationimprovementstoreducetheamountfXMLrequiredtoconfigureSpringupportfortheJavaPersistenceAPI(JPA)nhancedbeanscoping,includingrequestandsessionscopingofbeansforebapplicationsheabilitytoperformdependencyinjectiononobjectsthatSpringdoesn’treate(suchasdomainobjects)pointinhiskeynote,Rodsaidthatifthewealthofnewfeaturesbeingceddidn’tjustifyajumpto2.0,thenhowwouldtheyeverbeabletojustifylease?t’snotall.InadditiontotheworkbeingdoneonthecoreSpringFrame-everalinterestingSpring-relatedprojectswereunderwaytoprovideaddi-apabilitiesontopofSpring.Amongthem:pringWebFlow,whichisbasedonSpringMVCandenablesdevelopmentfflow-basedwebapplicationsFire,forexportingyourSpringbeansasSOAPwebservicespring-WSforcreatingcontract-firstwebservicespringModules,whichprovides(amongotherthings)declarativecachingndvalidationirectWebRemoting(DWR)forAjax-enablingSpringbeansingo,whichmakesitpossibletoasynchronouslyinvokemethodsonemotebeansPREFACExxiThenitoccurredtome:ifallofthesenewadvancesinSpringdidn’tjustifyasec-ondeditionofSpringinAction,thenwhatwould?Asitturnedout,Manningwasthinkingthesamething.Andnow,welloverayearlater,here’sthelong-awaitedupdatetoSpringinActiontlongerforthisSpring.hatcoversmanyofthenewfeaturesofSpring2.0.IthastakenmealottofinishthanIhadplanned,butIhopethatitwasworththewait.Mygoaleditionisthesameaswiththefirst:tosharethejoyofdevelopinginIhopethisbookwillservetoenhanceyourenjoymentofSpring.SoftwarcraftwdevelopThisreativesoTheingtargnewmebemastbetteraThethatmoofeffortieswenewwaThisJavacolandscaneeds—functioextendprefacetothefirsteditionedevelopersneedtohaveanumberoftraitsinordertopracticetheirell.First,theymustbegoodanalyticalthinkersandproblemsolvers.Aer’sprimaryroleistocreatesoftwarethatsolvesbusinessproblems.quiresanalyzingcustomerneedsandcomingupwithsuccessful,cre-lutions.yalsoneedtobecurious.Developments

Spring in Action 2.pdf

Spring in Action 2.pdf

上传者: bosshida
638次下载 0人收藏 暂无简介 简介 2012-03-04 举报

简介:in action 系列,spring

PraisefortheFirstEdition“Thisisoneofthoserarebooksthatconnectatutorialforusingacertainsoftwareproductwithaplethoraofideasongoodsoftwaredesignanddesignpatterns.Ienjoyedthisbookverymuch...”—ComputingReviews“Coversalorganized“...easyto“WhileSpSpringmuentertainin“Trulyagenterpriseservicesthaaccessprogme,thereisandeditedpaidatten“Acompletmeanitis...[it]explmakesthemimplementabouttheframeworkSpringinhlthebaseswithextensiveexamplesandexplicitinstructions...asuperblyandfluentlywritteninstructionandreferencemanual.”—InternetBookwatchread...andhasjustenoughhumormixedin...”—Books-On-Linering’sreferencedocumentationishighquality,thisbookmakeslearningchmoreenjoyable.Thebookinjectsafairamountofhumorthatkeepsitg.IfyouwanttolearnSpring,youcan’tgowrongwiththisoffering.”—BillSiggelkow’sWeblogAuthorofJakartaStrutsCookbookreatresource...ThebookclearlydefinesthepowerthatSpringbringstoprogrammersandhowSpringabstractsawaymanyofthetougherJ2EEtmostseriousapplicationsuse.Thebookhasbeenthrougharigorousearlyram,sothankfullygrammarandcodeerrorsareallbutnon-existent.Tonothingworsethantryingtolearnanewtechnologyfromapoorlywrittentechnicalbook.Thankfully,Craig,Ryan,andtheManningteamhavetiontodetailandproducedabookthatIhighlyrecommend.”—JavaLobby.orgereferencemanualthatcoversnearlyeveryaspectofSpring.Thisdoesn’tcomplicated:everyexplanationisclearandtherearealotofcodeexamples.ainsclearlywhat“InversionofControl”andAOPmeanandhowSpringpossible....howyoucanwriteservicesandDaos,andhowyoucansimplytransactionmanagementandserviceremoting....thethirdparttalksWeblayercoveringSpringMVCaswellasothertechnologiesands....Overallanexcellentresourceforanydeveloperinterestedinusingisproject.”—JavaUserGroupMilanoSpringinActionSecondEditionCRAIGWALLSwithRyanBreidenbachMANNINGGreenwich(74w.long.)ForonlineinformationandorderingofthisandotherManningbooks,pleasevisitwww.manning.com.Thepublisheroffersdiscountsonthisbookwhenorderedinquantity.Formoreinformation,pleasecontact:SpecialSalesDepartmentManningPublicationsCo.SoundViewCourt3BFax:(609)877-8256Greenwick,CT06830Email:orders@manning.com2008byManninNopartofthispuanyformorbymepermissionoftheManyofthedesigclaimedastrademPublicationswasaorallcaps.RecognizingtheithebookswepubManningPuSoundViewGreenwich,ISBN1-933988-13PrintedintheUn12345678gPublicationsCo.Allrightsreserved.blicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanselectronic,mechanical,photocopying,orotherwise,withoutpriorwrittenpublisher.nationsusedbymanufacturersandsellerstodistinguishtheirproductsarearks.Wherethosedesignationsappearinthebook,andManningwareofatrademarkclaim,thedesignationshavebeenprintedininitialcapsmportanceofpreservingwhathasbeenwritten,itisManning’spolicytohavelishprintedonacid-freepaper,andweexertourbesteffortstothatend.blicationsCo.Copyeditor:LizWelchCourt3BTypesetter:DottieMarsicoCT06830Coverdesigner:LeslieHaimes-4itedStatesofAmerica910–MAL–13121110090807FormywifeRaymieandmydaughtersMaisyandMadisonIamendlesslymystifiedastohowImerittheloveoftheworld’sthreemostbeautifulgirls.PART1COPART2ENbriefcontentsRESPRING...............................................................11Springingintoaction32Basicbeanwiring313Advancedbeanwiring724Advisingbeans116TERPRISESPRING.................................................1535Hittingthedatabase1556Managingtransactions2207SecuringSpring2478SpringandPOJO-basedremoteservices3059Buildingcontract-firstwebservicesinSpring34310Springmessaging38411SpringandEnterpriseJavaBeans423vii12Accessingenterpriseservices441viiiBRIEFCONTENTSPART3CLIENT-SIDESPRING..................................................48713Handlingwebrequests48914Renderingwebviews533apap15UsingSpringWebFlow58016Integratingwithotherwebframeworks623pendixASettingupSpring667pendixBTestingwith(andwithout)Spring678PART11contentsprefacexixprefacetothefirsteditionxxiiacknowledgmentsxxvaboutthisbookxxviiaboutthetitlexxxiiiaboutthecoverillustrationxxxivCORESPRING................................................1Springingintoaction31.1WhatisSpring?5Springmodules61.2ASpringjumpstart111.3Understandingdependencyinjection14Injectingdependencies14Dependencyinjectioninaction15Dependencyinjectioninenterpriseapplications211.4Applyingaspect-orientedprogramming24ixIntroducingAOP24AOPinaction261.5Summary30xCONTENTS2Basicbeanwiring312.1Containingyourbeans33IntroducingtheBeanFactory34Workingwithanapplication3context35Abean’slife372.2Creatingbeans40Declaringasimplebean40Injectingthroughconstructors422.3Injectingintobeanproperties46Injectingsimplevalues47Referencingotherbeans48Wiringcollections52Wiringnothing(null)582.4Autowiring58Thefourtypesofautowiring59Mixingautowithexplicitwiring63Toautowireornottoautowire632.5Controllingbeancreation64Beanscoping65Creatingbeansfromfactorymethods66Initializinganddestroyingbeans682.6Summary71Advancedbeanwiring723.1Declaringparentandchildbeans73Abstractingabasebeantype74Abstractingcommonproperties763.2Applyingmethodinjection79Basicmethodreplacement80Usinggetterinjection833.3Injectingnon-Springbeans853.4Registeringcustompropertyeditors883.5WorkingwithSpring’sspecialbeans92Postprocessingbeans93Postprocessingthebeanfactory95Externalizingconfigurationproperties96Resolvingtextmessages99Decouplingwithapplicationevents101Makingbeansaware1033.6Scriptingbeans106Puttingthelimeinthecoconut107Scriptingabean108Injectingpropertiesofscriptedbeans111Refreshingscriptedbeans112Writingscriptedbeansinline1133.7Summary114CONTENTSxi4Advisingbeans1164.1IntroducingAOP118DefiningAOPterminology119Spring’sAOPsupport122PART254.2CreatingclassicSpringaspects125Creatingadvice127Definingpointcutsandadvisors132UsingProxyFactoryBean1364.3Autoproxying139CreatingautoproxiesforSpringaspects140Autoproxying@AspectJaspects1414.4Declaringpure-POJOaspects1454.5InjectingAspectJaspects1494.6Summary152ENTERPRISESPRING.................................153Hittingthedatabase1555.1LearningSpring’sdataaccessphilosophy157GettingtoknowSpring’sdataaccessexceptionhierarchy158Templatingdataaccess161UsingDAOsupportclasses1635.2Configuringadatasource165UsingJNDIdatasources165Usingapooleddatasource167JDBCdriver-baseddatasource1685.3UsingJDBCwithSpring170TacklingrunawayJDBCcode170WorkingwithJDBCtemplates173UsingSpring’sDAOsupportclassesforJDBC1805.4IntegratingHibernatewithSpring183ChoosingaversionofHibernate185UsingHibernatetemplates186BuildingHibernate-backedDAOs190UsingHibernate3contextualsessions1925.5SpringandtheJavaPersistenceAPI194UsingJPAtemplates194Configuringanentitymanagerfactory197BuildingaJPA-backedDAO202xiiCONTENTS5.6SpringandiBATIS203ConfiguringaniBATISclienttemplate204BuildinganiBATIS-backedDAO2075.7Caching20867Configuringacachingsolution210Proxyingbeansforcaching215Annotation-drivencaching2175.8Summary218Managingtransactions2206.1Understandingtransactions222Explainingtransactionsinonlyfourwords223UnderstandingSpring’stransactionmanagementsupport2246.2Choosingatransactionmanager225JDBCtransactions226Hibernatetransactions227JavaPersistenceAPItransactions227JavaDataObjectstransactions228JavaTransactionAPItransactions2296.3ProgrammingtransactionsinSpring2296.4Declaringtransactions232Definingtransactionattributes233Proxyingtransactions238DeclaringtransactionsinSpring2.0241Definingannotation-driventransactions2436.5Summary245SecuringSpring2477.1IntroducingSpringSecurity2487.2Authenticatingusers252Configuringaprovidermanager253Authenticatingagainstadatabase256AuthenticatingagainstanLDAPrepository2647.3Controllingaccess271Votingaccessdecisions272Castinganaccessdecisionvote273Handlingvoterabstinence275CONTENTSxiii7.4Securingwebapplications275ProxyingSpringSecurity’sfilters278Handlingthesecuritycontext285Promptingtheusertologin286Handlingsecurityexceptions291Enforcingwebsecurity293Ensuringasecurechannel294897.5View-layersecurity297Conditionallyrenderingcontent298Displayinguserauthenticationinformation2997.6Securingmethodinvocations300Creatingasecurityaspect301Securingmethodsusingmetadata3037.7Summary304SpringandPOJO-basedremoteservices3058.1AnoverviewofSpringremoting3068.2WorkingwithRMI309WiringRMIservices310ExportingRMIservices3128.3RemotingwithHessianandBurlap316AccessingHessian/Burlapservices317ExposingbeanfunctionalitywithHessian/Burlap3188.4UsingSpring’sHttpInvoker322AccessingservicesviaHTTP323ExposingbeansasHTTPServices3248.5Springandwebservices326ExportingbeansaswebservicesusingXFire326DeclaringwebserviceswithJSR-181annotations330Consumingwebservices333ProxyingwebserviceswithanXFireclient3408.6Summary341Buildingcontract-firstwebservicesinSpring3439.1IntroducingSpring-WS3459.2Definingthecontract(first!)347CreatingsampleXMLmessages348xivCONTENTS9.3Handlingmessageswithserviceendpoints353BuildingaJDOM-basedmessageendpoint355Marshalingmessagepayloads35810119.4Wiringitalltogether361Spring-WS:Thebigpicture361Mappingmessagestoendpoints363Wiringtheserviceendpoint364Configuringamessagemarshaler364Handlingendpointexceptions367ServingWSDLfiles369Deployingtheservice3739.5ConsumingSpring-WSwebservices373Workingwithwebservicetemplates374Usingwebservicegatewaysupport3819.6Summary382Springmessaging38410.1AbriefintroductiontoJMS386ArchitectingJMS387AssessingthebenefitsofJMS390SettingupActiveMQinSpring39210.2UsingJMSwithSpring393TacklingrunawayJMScode393WorkingwithJMStemplates395Convertingmessages402UsingSpring’sgatewaysupportclassesforJMS40510.3Creatingmessage-drivenPOJOs407Creatingamessagelistener408Writingpure-POJOMDPs41210.4Usingmessage-basedRPC416IntroducingLingo417Exportingtheservice418ProxyingJMS42010.5Summary422SpringandEnterpriseJavaBeans42311.1WiringEJBsinSpring425Proxyingsessionbeans(EJB2.x)426WiringEJBsintoSpringbeans43011.2DevelopingSpring-enabledEJBs(EJB2.x)431CONTENTSxv11.3SpringandEJB3434IntroducingPitchfork435GettingstartedwithPitchfork436Injectingresourcesbyannotation437Declaringinterceptorsusingannotations43812PART31311.4Summary440Accessingenterpriseservices44112.1WiringobjectsfromJNDI442WorkingwithconventionalJNDI443InjectingJNDIobjects446WiringJNDIobjectsinSpring244912.2Sendingemail450Configuringamailsender451Constructingtheemail45312.3Schedulingtasks456SchedulingwithJava’sTimer457UsingtheQuartzscheduler460Invokingmethodsonaschedule46412.4ManagingSpringbeanswithJMX466ExportingSpringbeansasMBeans467RemotingMBeans477Handlingnotifications48212.5Summary485CLIENT-SIDESPRING..................................487Handlingwebrequests48913.1GettingstartedwithSpringMVC490Adayinthelifeofarequest491ConfiguringDispatcherServlet492SpringMVCinanutshell49513.2Mappingrequeststocontrollers502UsingSimpleUrlHandlerMapping503UsingControllerClassNameHandlerMapping504Usingmetadatatomapcontrollers505Workingwithmultiplehandlermappings50513.3Handlingrequestswithcontrollers506Processingcommands509Processingformsubmissions512Processingcomplexformswithwizards520Workingwiththrowawaycontrollers528xviCONTENTS13.4Handlingexceptions53113.5Summary53214Renderingwebviews5331514.1Resolvingviews534Usingtemplateviews535Resolvingviewbeans537Choosingaviewresolver54014.2UsingJSPtemplates542Bindingformdata542Renderingexternalizedmessages544Displayingerrors54714.3LayingoutpageswithTiles549Tileviews550CreatingTilecontrollers55414.4WorkingwithJSPalternatives556UsingVelocitytemplates557WorkingwithFreeMarker56414.5Generatingnon-HTMLoutput569ProducingExcelspreadsheets570GeneratingPDFdocuments573Developingcustomviews57614.6Summary578UsingSpringWebFlow58015.1GettingstartedwithSpringWebFlow582InstallingSpringWebFlow584SpringWebFlowessentials589Creatingaflow59115.2Layingtheflowgroundwork591Flowvariables591Startandendstates593Gatheringcustomerinformation594Buildingapizzaorder601Completingtheorder605Afewfinishingtouches60815.3Advancedwebflowtechniques611Usingdecisionstates612Extractingsubflowsandusingsubstates61415.4IntegratingSpringWebFlowwithotherframeworks619JakartaStruts619JavaServerFaces62015.5Summary622CONTENTSxvii16Integratingwithotherwebframeworks62316.1UsingSpringwithStruts624RegisteringtheSpringplug-inwithStruts626WritingSpring-awareStrutsactions627DelegatingtoSpring-configuredappendixAappendixBwebcontentwebchappenappenappenappenactions629WhataboutStruts2?63216.2WorkingSpringintoWebWork2/Struts263316.3IntegratingSpringwithTapestry636IntegratingSpringwithTapestry3637IntegratingSpringwithTapestry464116.4PuttingafaceonSpringwithJSF643ResolvingJSF-managedproperties644ResolvingSpringbeans646UsingSpringbeansinJSFpages646ExposingtheapplicationcontextinJSF64816.5Ajax-enablingapplicationsinSpringwithDWR648Directwebremoting650AccessingSpring-managedbeansDWR65916.6Summary664SettingupSpring667Testingwith(andwithout)Spring678index707apterBuildingportletapplicationsdixCSpringXMLconfigurationreferencedixDSpringJSPtaglibraryreferencedixESpringWebFlowdefinitionreferencedixFCustomizingSpringconfigurationItwasDinMiamworldwforasinWhasurf,wemoreaOnRodJohofSprinbersofinthenHecaughtavailablRodinSpringThemadeliversionIndeedcapabilprefaceecember7,2005.IwasstandingatthesideofalargehotelmeetingroomiBeach,Florida.TheroomwasfilledwithdevelopersfromalloverthehohaddescendeduponthebeautifulsandybeachesofsouthernFloridaglepurpose:totalkaboutSpring.tcanIsay?Itwasaroomfullofnerds.Ratherthansoakinthesunandallgatheredinsidetobaskinthewarmglowofourlaptopscreenstolearnboutourbelovedframeworkfromthosewhoknowitbest.thatparticularnight,wewerehangingonthewordsofSpring’screator,nson,ashepresentedtheopeningkeynotefortheconference.Hespokeg’soriginsandthesuccessesithadenjoyed.Thenheinvitedafewmem-theSpringteamtothepodiumtointroducenewfeaturesthatweretobeextversion.wasn’tfarintohispresentationwhenRodmadeanannouncementthateveryone’sattention.WewereallexpectingthesegreatnewfeaturestobeeinSpring1.3,thesupposednextversionofSpring.Muchtooursurprise,formedusthattherewouldbenoSpring1.3;thenextversionwouldbe2.0.decisiontobumpupthemajorversionnumberofthenextreleaseisn’tghtly.SuchanactionconnotesasignificantadvanceinSpring.IfthenextxixofSpringwouldbe2.0,thenwecouldexpectmajorenhancements.,tenmonthslater,Spring2.0wouldbereleasedwithanabundanceofnewities,including:xxPREFACESimplifiedXMLconfigurationandtheoptiontocreatecustomconfigura-tionelementsGreatlysimplifiedAOPandtransactionsSupportforJava5annotationsfordeclaringaspects,transactions,andrTSNImcASoSEwTcAtoneintrodua2.0reThawork,stionalcSoXSSaDLrequiredbeanpropertiesheabilitytocreatebeansfromscriptswritteninJRuby,Groovy,orBean-hellewJDBCtemplatestosupportnamedparametersandJava5featuresprovedJMSsupport,includingreceivingmessagesasynchronously(forreatingmessage-drivenPOJOs)newform-bindingJSPtaglibraryeveralconvention-over-configurationimprovementstoreducetheamountfXMLrequiredtoconfigureSpringupportfortheJavaPersistenceAPI(JPA)nhancedbeanscoping,includingrequestandsessionscopingofbeansforebapplicationsheabilitytoperformdependencyinjectiononobjectsthatSpringdoesn’treate(suchasdomainobjects)pointinhiskeynote,Rodsaidthatifthewealthofnewfeaturesbeingceddidn’tjustifyajumpto2.0,thenhowwouldtheyeverbeabletojustifylease?t’snotall.InadditiontotheworkbeingdoneonthecoreSpringFrame-everalinterestingSpring-relatedprojectswereunderwaytoprovideaddi-apabilitiesontopofSpring.Amongthem:pringWebFlow,whichisbasedonSpringMVCandenablesdevelopmentfflow-basedwebapplicationsFire,forexportingyourSpringbeansasSOAPwebservicespring-WSforcreatingcontract-firstwebservicespringModules,whichprovides(amongotherthings)declarativecachingndvalidationirectWebRemoting(DWR)forAjax-enablingSpringbeansingo,whichmakesitpossibletoasynchronouslyinvokemethodsonemotebeansPREFACExxiThenitoccurredtome:ifallofthesenewadvancesinSpringdidn’tjustifyasec-ondeditionofSpringinAction,thenwhatwould?Asitturnedout,Manningwasthinkingthesamething.Andnow,welloverayearlater,here’sthelong-awaitedupdatetoSpringinActiontlongerforthisSpring.hatcoversmanyofthenewfeaturesofSpring2.0.IthastakenmealottofinishthanIhadplanned,butIhopethatitwasworththewait.Mygoaleditionisthesameaswiththefirst:tosharethejoyofdevelopinginIhopethisbookwillservetoenhanceyourenjoymentofSpring.SoftwarcraftwdevelopThisreativesoTheingtargnewmebemastbetteraThethatmoofeffortieswenewwaThisJavacolandscaneeds—functioextendprefacetothefirsteditionedevelopersneedtohaveanumberoftraitsinordertopracticetheirell.First,theymustbegoodanalyticalthinkersandproblemsolvers.Aer’sprimaryroleistocreatesoftwarethatsolvesbusinessproblems.quiresanalyzingcustomerneedsandcomingupwithsuccessful,cre-lutions.yalsoneedtobecurious.Developments
  • 相关资料
  • 该用户的其他资料
  • 名称/格式
  • 下载次数
  • 资料大小
  • 名称/格式
  • 下载次数
  • 资料大小

用户评论(1)

0/200
  • 10.44.7.248 2013-04-03 09:55:05

    感谢分享,资料很不错

上传我的资料
关闭

请选择举报的类型

关闭

提示

提交成功!

感谢您对爱问共享资料的支持,我们将尽快核实并处理您的举报信息。

关闭

提示

提交失败!

您的举报信息提交失败,请重试!

关闭

提示

重复举报!

亲爱的用户!感觉您对爱问共享资料的支持,请勿重复举报噢!

全屏 缩小 放大
收藏
资料评价:

/ 765
所需积分:0 立即下载
返回
顶部
举报
资料
关闭

温馨提示

感谢您对爱问共享资料的支持,精彩活动将尽快为您呈现,敬请期待!