ThisreferenceguideprovidesdetailedinformationabouttheSpringFramework.Itprovidescomprehensivedocumentationforallfeatures,as
wellassomebackgroundabouttheunderlyingconcepts(suchas"DependencyInjection")thatSpringhasembraced.
IfyouarejustgettingstartedwithSpring,youmaywanttobeginwiththelighter"GettingStarted"guidesthatareavailablefrom
https://spring.io.Aswellasbeingeasiertodigest,theseguideareverytaskfocused.TheyalsocoverotherprojectsfromtheSpringportfolio
thatyoumightwanttoconsiderwhensolvingaparticularproblem.
GettingStartedBuildingaRESTfulWebServicewouldbeanexcellentfirstchoicetogetyourfeetwet.
2.IntroductiontoSpringFramework
SpringFrameworkisaJavaplatformthatprovidescomprehensiveinfrastructuresupportfordevelopingJavaapplications.Springhandlesthe
infrastructuresoyoucanfocusonyourapplication.
Springenablesyoutobuildapplicationsfrom"plainoldJavaobjects"(POJOs)andtoapplyenterpriseservicesnoninvasivelytoPOJOs.This
capabilityappliestotheJavaSEprogrammingmodelandtofullandpartialJavaEE.
Examplesofhowyou,asanapplicationdeveloper,canusetheSpringplatformadvantage:
MakeaJavamethodexecuteinadatabasetransactionwithouthavingtodealwithtransactionAPIs.
MakealocalJavamethodaremoteprocedurewithouthavingtodealwithremoteAPIs.
MakealocalJavamethodamanagementoperationwithouthavingtodealwithJMXAPIs.
MakealocalJavamethodamessagehandlerwithouthavingtodealwithJMSAPIs.
2.1DependencyInjectionandInversionofControl
Background
"Thequestionis,whataspectofcontrolare[they]inverting?"MartinFowlerposedthisquestionaboutInversionofControl(IoC)onhis
sitein2004.FowlersuggestedrenamingtheprincipletomakeitmoreselfexplanatoryandcameupwithDependencyInjection.
ForinsightintoIoCandDI,refertoFowler’sarticleathttp://martinfowler.com/articles/injection.html.
Javaapplications — aloosetermthatrunsthegamutfromconstrainedappletstontierserversideenterpriseapplications — typicallyconsistof
objectsthatcollaboratetoformtheapplicationproper.Thustheobjectsinanapplicationhavedependenciesoneachother.
AlthoughtheJavaplatformprovidesawealthofapplicationdevelopmentfunctionality,itlacksthemeanstoorganizethebasicbuildingblocks
intoacoherentwhole,leavingthattasktoarchitectsanddevelopers.True,youcanusedesignpatternssuchasFactory,AbstractFactory,
Builder,Decorator,andServiceLocatortocomposethevariousclassesandobjectinstancesthatmakeupanapplication.However,these
patternsaresimplythat:bestpracticesgivenaname,withadescriptionofwhatthepatterndoes,wheretoapplyit,theproblemsitaddresses,
andsoforth.Patternsareformalizedbestpracticesthatyoumustimplementyourselfinyourapplication.
TheSpringFrameworkInversionofControl(IoC)componentaddressesthisconcernbyprovidingaformalizedmeansofcomposingdisparate
componentsintoafullyworkingapplicationreadyforuse.TheSpringFrameworkcodifiesformalizeddesignpatternsasfirstclassobjectsthat
youcanintegrateintoyourownapplication(s).NumerousorganizationsandinstitutionsusetheSpringFrameworkinthismannertoengineer
robust,maintainableapplications.
2.2Modules
TheSpringFrameworkconsistsoffeaturesorganizedintoabout20modules.ThesemodulesaregroupedintoCoreContainer,Data
Access/Integration,Web,AOP(AspectOrientedProgramming),Instrumentation,Messaging,andTest,asshowninthefollowingdiagram.
Figure2.1.OverviewoftheSpringFramework