ebook img

2.0.8 Copyright © 2004-2007 Rod Johnson, Juergen - Spring PDF

502 Pages·2010·3.61 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview 2.0.8 Copyright © 2004-2007 Rod Johnson, Juergen - Spring

2.0.8 Copyright © 2004-2007 Rod Johnson, Juergen Hoeller, Alef Arendsen, Colin Sampaleanu, Rob Harrop, Thomas Risberg, Darren Davison, Dmitriy Kopylenko, Mark Pollack, Thierry Templier, Erwin Vervaet, Portia Tung, Ben Hale, Adrian Colyer, John Lewis, Costin Leau, Rick Evans Copiesofthisdocumentmaybemadeforyourownuseandfordistributiontoothers,providedthatyoudonot chargeanyfeeforsuchcopiesandfurtherprovidedthateachcopycontainsthisCopyrightNotice,whether distributedinprintorelectronically. Preface ................................................................................................................................................ xiv 1. Introduction .................................................................................................................................. 15 1.1. Overview ............................................................................................................................. 15 1.2. Usagescenarios.................................................................................................................... 17 2. What'snewinSpring2.0? ............................................................................................................. 20 2.1. Introduction ......................................................................................................................... 20 2.2. TheInversionofControl(IoC)container ............................................................................... 20 2.2.1. EasierXMLconfiguration .......................................................................................... 20 2.2.2. Newbeanscopes ....................................................................................................... 20 2.2.3. ExtensibleXMLauthoring ......................................................................................... 21 2.3. AspectOrientedProgramming(AOP).................................................................................... 21 2.3.1. EasierAOPXMLconfiguration ................................................................................. 21 2.3.2. Supportfor@AspectJaspects .................................................................................... 21 2.4. TheMiddleTier ................................................................................................................... 21 2.4.1. EasierconfigurationofdeclarativetransactionsinXML .............................................. 22 2.4.2. JPA .......................................................................................................................... 22 2.4.3. AsynchronousJMS .................................................................................................... 22 2.4.4. JDBC........................................................................................................................ 22 2.5. TheWebTier ....................................................................................................................... 22 2.5.1. AformtaglibraryforSpringMVC............................................................................. 22 2.5.2. SensibledefaultinginSpringMVC............................................................................. 23 2.5.3. Portletframework ...................................................................................................... 23 2.6. Everythingelse .................................................................................................................... 23 2.6.1. Dynamiclanguagesupport ......................................................................................... 23 2.6.2. JMX ......................................................................................................................... 23 2.6.3. Taskscheduling......................................................................................................... 23 2.6.4. Java5(Tiger)support ................................................................................................ 23 2.7. MigratingtoSpring2.0 ......................................................................................................... 24 2.7.1. Changes .................................................................................................................... 24 2.8. Updatedsampleapplications ................................................................................................. 25 2.9. Improveddocumentation ...................................................................................................... 25 I. CoreTechnologies ........................................................................................................................... 27 3. TheIoCcontainer ................................................................................................................. 28 3.1. Introduction ................................................................................................................. 28 3.2. Basics-containersandbeans ........................................................................................ 28 3.2.1. Thecontainer .................................................................................................... 28 3.2.2. Instantiatingacontainer ..................................................................................... 30 3.2.3. Thebeans.......................................................................................................... 31 3.2.4. Usingthecontainer ............................................................................................ 35 3.3. Dependencies ............................................................................................................... 36 3.3.1. Injectingdependencies ....................................................................................... 36 3.3.2. ConstructorArgumentResolution ....................................................................... 40 3.3.3. Beanpropertiesandconstructorargumentsdetailed ............................................. 42 3.3.4. Usingdepends-on ............................................................................................. 50 3.3.5. Lazily-instantiatedbeans .................................................................................... 51 3.3.6. Autowiringcollaborators.................................................................................... 51 3.3.7. Checkingfordependencies ................................................................................. 53 3.3.8. MethodInjection ............................................................................................... 54 3.4. Beanscopes ................................................................................................................. 57 3.4.1. Thesingletonscope ........................................................................................... 57 3.4.2. Theprototypescope........................................................................................... 58 3.4.3. Singletonbeanswithprototype-beandependencies .............................................. 59 SpringFramework(2.0.8) ii TheSpringFramework-ReferenceDocumentation 3.4.4. Theotherscopes ................................................................................................ 60 3.4.5. Customscopes .................................................................................................. 64 3.5. Customizingthenatureofabean ................................................................................... 66 3.5.1. Lifecycleinterfaces ........................................................................................... 66 3.5.2. Knowingwhoyouare ........................................................................................ 69 3.6. Beandefinitioninheritance ........................................................................................... 71 3.7. Containerextensionpoints ............................................................................................ 72 3.7.1. CustomizingbeansusingBeanPostProcessors ................................................... 72 3.7.2. CustomizingconfigurationmetadatawithBeanFactoryPostProcessors............... 75 3.7.3. CustomizinginstantiationlogicusingFactoryBeans............................................ 78 3.8. TheApplicationContext ............................................................................................. 78 3.8.1. InternationalizationusingMessageSources ......................................................... 79 3.8.2. Events............................................................................................................... 81 3.8.3. Convenientaccesstolow-levelresources ............................................................ 83 3.8.4. ConvenientApplicationContextinstantiationforwebapplications ..................... 83 3.9. Gluecodeandtheevilsingleton .................................................................................... 84 3.9.1. UsingtheSingleton-helperclasses ...................................................................... 85 4. Resources .............................................................................................................................. 86 4.1. Introduction ................................................................................................................. 86 4.2. TheResourceinterface ................................................................................................. 86 4.3. Built-inResourceimplementations ............................................................................... 87 4.3.1. UrlResource ..................................................................................................... 87 4.3.2. ClassPathResource........................................................................................... 87 4.3.3. FileSystemResource ......................................................................................... 88 4.3.4. ServletContextResource .................................................................................. 88 4.3.5. InputStreamResource ....................................................................................... 88 4.3.6. ByteArrayResource........................................................................................... 88 4.4. TheResourceLoader .................................................................................................... 88 4.5. TheResourceLoaderAwareinterface ............................................................................. 89 4.6. Resourcesasdependencies ........................................................................................... 90 4.7. ApplicationcontextsandResourcepaths ....................................................................... 90 4.7.1. Constructingapplicationcontexts ....................................................................... 90 4.7.2. Wildcardsinapplicationcontextconstructorresourcepaths ................................. 91 4.7.3. FileSystemResourcecaveats ............................................................................. 93 5. Validation,Data-binding,theBeanWrapper,andPropertyEditors ......................................... 95 5.1. Introduction ................................................................................................................. 95 5.2. ValidationusingSpring'sValidatorinterface ................................................................ 95 5.3. Resolvingcodestoerrormessages................................................................................. 97 5.4. BeanmanipulationandtheBeanWrapper........................................................................ 97 5.4.1. Settingandgettingbasicandnestedproperties .................................................... 97 5.4.2. Built-inPropertyEditorimplementations ............................................................. 99 6. AspectOrientedProgrammingwithSpring .......................................................................... 105 6.1. Introduction ................................................................................................................. 105 6.1.1. AOPconcepts ................................................................................................... 105 6.1.2. SpringAOPcapabilitiesandgoals ...................................................................... 107 6.1.3. AOPProxies ..................................................................................................... 108 6.2. @AspectJsupport ........................................................................................................ 108 6.2.1. Enabling@AspectJSupport ............................................................................... 108 6.2.2. Declaringanaspect ............................................................................................ 109 6.2.3. Declaringapointcut........................................................................................... 109 6.2.4. Declaringadvice................................................................................................ 114 6.2.5. Introductions ..................................................................................................... 119 SpringFramework(2.0.8) iii TheSpringFramework-ReferenceDocumentation 6.2.6. Aspectinstantiationmodels ................................................................................ 120 6.2.7. Example ........................................................................................................... 121 6.3. Schema-basedAOPsupport .......................................................................................... 122 6.3.1. Declaringanaspect ............................................................................................ 123 6.3.2. Declaringapointcut........................................................................................... 123 6.3.3. Declaringadvice................................................................................................ 124 6.3.4. Introductions ..................................................................................................... 128 6.3.5. Aspectinstantiationmodels ................................................................................ 129 6.3.6. Advisors ........................................................................................................... 129 6.3.7. Example ........................................................................................................... 130 6.4. ChoosingwhichAOPdeclarationstyletouse ................................................................ 131 6.4.1. SpringAOPorfullAspectJ? .............................................................................. 131 6.4.2. @AspectJorXMLforSpringAOP? ................................................................... 132 6.5. Mixingaspecttypes ...................................................................................................... 132 6.6. Proxyingmechanisms ................................................................................................... 133 6.6.1. UnderstandingAOPproxies ............................................................................... 134 6.7. Programmaticcreationof@AspectJProxies .................................................................. 136 6.8. UsingAspectJwithSpringapplications ......................................................................... 136 6.8.1. UsingAspectJtodependencyinjectdomainobjectswithSpring ........................... 136 6.8.2. OtherSpringaspectsforAspectJ ........................................................................ 139 6.8.3. ConfiguringAspectJaspectsusingSpringIoC..................................................... 139 6.8.4. UsingAspectJLoad-timeweaving(LTW)withSpringapplications ...................... 140 6.9. FurtherResources ........................................................................................................ 141 7. SpringAOPAPIs .................................................................................................................. 142 7.1. Introduction ................................................................................................................. 142 7.2. PointcutAPIinSpring .................................................................................................. 142 7.2.1. Concepts ........................................................................................................... 142 7.2.2. Operationsonpointcuts ..................................................................................... 143 7.2.3. AspectJexpressionpointcuts .............................................................................. 143 7.2.4. Conveniencepointcutimplementations ............................................................... 143 7.2.5. Pointcutsuperclasses ......................................................................................... 145 7.2.6. Custompointcuts ............................................................................................... 145 7.3. AdviceAPIinSpring ................................................................................................... 145 7.3.1. Advicelifecycles ............................................................................................... 145 7.3.2. AdvicetypesinSpring ....................................................................................... 146 7.4. AdvisorAPIinSpring .................................................................................................. 151 7.5. UsingtheProxyFactoryBeantocreateAOPproxies ....................................................... 151 7.5.1. Basics ............................................................................................................... 151 7.5.2. JavaBeanproperties ........................................................................................... 152 7.5.3. JDK-andCGLIB-basedproxies ......................................................................... 153 7.5.4. Proxyinginterfaces ............................................................................................ 154 7.5.5. Proxyingclasses ................................................................................................ 155 7.5.6. Using'global'advisors ....................................................................................... 156 7.6. Conciseproxydefinitions ............................................................................................. 156 7.7. CreatingAOPproxiesprogrammaticallywiththeProxyFactory ...................................... 157 7.8. Manipulatingadvisedobjects ........................................................................................ 158 7.9. Usingthe"autoproxy"facility ....................................................................................... 159 7.9.1. Autoproxybeandefinitions ................................................................................ 159 7.9.2. Usingmetadata-drivenauto-proxying ................................................................. 161 7.10. UsingTargetSources................................................................................................... 163 7.10.1. Hotswappabletargetsources ............................................................................ 163 7.10.2. Poolingtargetsources ...................................................................................... 164 SpringFramework(2.0.8) iv TheSpringFramework-ReferenceDocumentation 7.10.3. Prototypetargetsources ................................................................................... 165 7.10.4. ThreadLocaltargetsources .............................................................................. 165 7.11. DefiningnewAdvicetypes ......................................................................................... 166 7.12. Furtherresources ........................................................................................................ 166 8. Testing .................................................................................................................................. 167 8.1. Introduction ................................................................................................................. 167 8.2. Unittesting .................................................................................................................. 167 8.3. Integrationtesting ........................................................................................................ 167 8.3.1. Contextmanagementandcaching ....................................................................... 168 8.3.2. DependencyInjectionoftestfixtures .................................................................. 168 8.3.3. Transactionmanagement.................................................................................... 170 8.3.4. Conveniencevariables ....................................................................................... 170 8.3.5. Java5+specificsupport ..................................................................................... 171 8.3.6. PetClinicexample.............................................................................................. 172 8.4. FurtherResources ........................................................................................................ 173 II. MiddleTierDataAccess ................................................................................................................. 174 9. Transactionmanagement ...................................................................................................... 175 9.1. Introduction ................................................................................................................. 175 9.2. Motivations.................................................................................................................. 175 9.3. Keyabstractions ........................................................................................................... 177 9.4. Resourcesynchronizationwithtransactions ................................................................... 179 9.4.1. High-levelapproach .......................................................................................... 179 9.4.2. Low-levelapproach ........................................................................................... 180 9.4.3. TransactionAwareDataSourceProxy .................................................................. 180 9.5. Declarativetransactionmanagement .............................................................................. 180 9.5.1. UnderstandingtheSpringFramework'sdeclarativetransactionimplementation ..... 182 9.5.2. Afirstexample .................................................................................................. 183 9.5.3. Rollingback ...................................................................................................... 186 9.5.4. Configuringdifferenttransactionalsemanticsfordifferentbeans .......................... 186 9.5.5. <tx:advice/>settings ....................................................................................... 188 9.5.6. Using@Transactional ...................................................................................... 189 9.5.7. Advisingtransactionaloperations ....................................................................... 193 9.5.8. Using@TransactionalwithAspectJ .................................................................. 195 9.6. Programmatictransactionmanagement .......................................................................... 196 9.6.1. UsingtheTransactionTemplate ........................................................................ 196 9.6.2. UsingthePlatformTransactionManager ............................................................ 198 9.7. Choosingbetweenprogrammaticanddeclarativetransactionmanagement ....................... 199 9.8. Applicationserver-specificintegration ........................................................................... 199 9.8.1. BEAWebLogic ................................................................................................. 199 9.8.2. IBMWebSphere................................................................................................ 199 9.9. Solutionstocommonproblems ..................................................................................... 199 9.9.1. UseofthewrongtransactionmanagerforaspecificDataSource .......................... 199 9.10. FurtherResources ....................................................................................................... 200 10. DAOsupport ....................................................................................................................... 201 10.1. Introduction ............................................................................................................... 201 10.2. Consistentexceptionhierarchy .................................................................................... 201 10.3. ConsistentabstractclassesforDAOsupport................................................................. 202 11. DataaccessusingJDBC ...................................................................................................... 203 11.1. Introduction ............................................................................................................... 203 11.1.1. Thepackagehierarchy ..................................................................................... 203 11.2. UsingtheJDBCCoreclassestocontrolbasicJDBCprocessinganderrorhandling ........ 204 11.2.1. JdbcTemplate.................................................................................................. 204 SpringFramework(2.0.8) v TheSpringFramework-ReferenceDocumentation 11.2.2. NamedParameterJdbcTemplate ......................................................................... 206 11.2.3. SimpleJdbcTemplate ....................................................................................... 208 11.2.4. DataSource ..................................................................................................... 209 11.2.5. SQLExceptionTranslator ................................................................................ 210 11.2.6. Executingstatements ....................................................................................... 211 11.2.7. RunningQueries .............................................................................................. 211 11.2.8. Updatingthedatabase ...................................................................................... 212 11.3. Controllingdatabaseconnections................................................................................. 213 11.3.1. DataSourceUtils ............................................................................................ 213 11.3.2. SmartDataSource ............................................................................................ 213 11.3.3. AbstractDataSource ....................................................................................... 213 11.3.4. SingleConnectionDataSource ......................................................................... 213 11.3.5. DriverManagerDataSource .............................................................................. 214 11.3.6. TransactionAwareDataSourceProxy ................................................................ 214 11.3.7. DataSourceTransactionManager ..................................................................... 214 11.4. ModelingJDBCoperationsasJavaobjects .................................................................. 214 11.4.1. SqlQuery ......................................................................................................... 215 11.4.2. MappingSqlQuery ............................................................................................ 215 11.4.3. SqlUpdate ....................................................................................................... 216 11.4.4. StoredProcedure ............................................................................................ 216 11.4.5. SqlFunction ................................................................................................... 219 12. ObjectRelationalMapping(ORM)dataaccess ................................................................... 220 12.1. Introduction ............................................................................................................... 220 12.2. Hibernate ................................................................................................................... 221 12.2.1. Resourcemanagement ..................................................................................... 221 12.2.2. SessionFactorysetupinaSpringcontainer ...................................................... 222 12.2.3. TheHibernateTemplate .................................................................................. 222 12.2.4. ImplementingSpring-basedDAOswithoutcallbacks ......................................... 224 12.2.5. ImplementingDAOsbasedonplainHibernate3API ......................................... 224 12.2.6. Programmatictransactiondemarcation .............................................................. 225 12.2.7. Declarativetransactiondemarcation .................................................................. 226 12.2.8. Transactionmanagementstrategies ................................................................... 227 12.2.9. Containerresourcesversuslocalresources ........................................................ 229 12.2.10. SpuriousapplicationserverwarningswhenusingHibernate ............................. 230 12.3. JDO ........................................................................................................................... 231 12.3.1. PersistenceManagerFactorysetup .................................................................. 231 12.3.2. JdoTemplateandJdoDaoSupport ..................................................................... 232 12.3.3. ImplementingDAOsbasedontheplainJDOAPI .............................................. 233 12.3.4. Transactionmanagement .................................................................................. 234 12.3.5. JdoDialect ..................................................................................................... 235 12.4. OracleTopLink .......................................................................................................... 236 12.4.1. SessionFactoryabstraction ............................................................................. 236 12.4.2. TopLinkTemplateandTopLinkDaoSupport ....................................................... 237 12.4.3. ImplementingDAOsbasedonplainTopLinkAPI ............................................. 238 12.4.4. Transactionmanagement .................................................................................. 239 12.5. iBATISSQLMaps ..................................................................................................... 240 12.5.1. SettinguptheSqlMapClient ............................................................................ 240 12.5.2. UsingSqlMapClientTemplateandSqlMapClientDaoSupport ............................ 241 12.5.3. ImplementingDAOsbasedonplainiBATISAPI .............................................. 242 12.6. JPA ........................................................................................................................... 243 12.6.1. JPAsetupinaSpringenvironment ................................................................... 243 12.6.2. JpaTemplateandJpaDaoSupport ..................................................................... 248 SpringFramework(2.0.8) vi TheSpringFramework-ReferenceDocumentation 12.6.3. ImplementingDAOsbasedonplainJPA ........................................................... 249 12.6.4. ExceptionTranslation ...................................................................................... 250 12.7. TransactionManagement ............................................................................................ 251 12.8. JpaDialect ................................................................................................................ 252 III. TheWeb ....................................................................................................................................... 253 13. WebMVCframework ......................................................................................................... 254 13.1. Introduction ............................................................................................................... 254 13.1.1. PluggabilityofotherMVCimplementations ...................................................... 255 13.1.2. FeaturesofSpringWebMVC .......................................................................... 255 13.2. TheDispatcherServlet ............................................................................................. 256 13.3. Controllers ................................................................................................................. 260 13.3.1. AbstractControllerandWebContentGenerator .............................................. 261 13.3.2. Othersimplecontrollers ................................................................................... 262 13.3.3. TheMultiActionController ........................................................................... 262 13.3.4. Commandcontrollers ....................................................................................... 264 13.4. Handlermappings ...................................................................................................... 265 13.4.1. BeanNameUrlHandlerMapping ........................................................................... 266 13.4.2. SimpleUrlHandlerMapping .............................................................................. 267 13.4.3. Interceptingrequests-theHandlerInterceptorinterface .................................. 268 13.5. Viewsandresolvingthem ........................................................................................... 269 13.5.1. Resolvingviews-theViewResolverinterface ................................................... 269 13.5.2. ChainingViewResolvers .................................................................................. 270 13.5.3. Redirectingtoviews ........................................................................................ 271 13.6. Usinglocales.............................................................................................................. 272 13.6.1. AcceptHeaderLocaleResolver ......................................................................... 273 13.6.2. CookieLocaleResolver ................................................................................... 273 13.6.3. SessionLocaleResolver .................................................................................. 273 13.6.4. LocaleChangeInterceptor .............................................................................. 274 13.7. Usingthemes ............................................................................................................. 274 13.7.1. Introduction..................................................................................................... 274 13.7.2. Definingthemes .............................................................................................. 274 13.7.3. Themeresolvers .............................................................................................. 275 13.8. Spring'smultipart(fileupload)support ......................................................................... 275 13.8.1. Introduction..................................................................................................... 275 13.8.2. UsingtheMultipartResolver .......................................................................... 276 13.8.3. Handlingafileuploadinaform ....................................................................... 276 13.9. UsingSpring'sformtaglibrary .................................................................................... 279 13.9.1. Configuration .................................................................................................. 279 13.9.2. Theformtag .................................................................................................... 279 13.9.3. Theinputtag .................................................................................................. 281 13.9.4. Thecheckboxtag............................................................................................. 281 13.9.5. Theradiobuttontag ....................................................................................... 282 13.9.6. Thepasswordtag............................................................................................. 283 13.9.7. Theselecttag ................................................................................................ 283 13.9.8. Theoptiontag ................................................................................................ 283 13.9.9. Theoptionstag .............................................................................................. 284 13.9.10. Thetextareatag ........................................................................................... 284 13.9.11. Thehiddentag .............................................................................................. 285 13.9.12. Theerrorstag .............................................................................................. 285 13.10. Handlingexceptions ................................................................................................. 287 13.11. Conventionoverconfiguration .................................................................................. 287 13.11.1. TheController-ControllerClassNameHandlerMapping .................................. 287 SpringFramework(2.0.8) vii TheSpringFramework-ReferenceDocumentation 13.11.2. TheModel-ModelMap(ModelAndView) ........................................................... 288 13.11.3. TheView-RequestToViewNameTranslator .................................................... 289 13.12. FurtherResources ..................................................................................................... 290 14. Integratingviewtechnologies .............................................................................................. 292 14.1. Introduction ............................................................................................................... 292 14.2. JSP&JSTL ............................................................................................................... 292 14.2.1. Viewresolvers................................................................................................. 292 14.2.2. 'Plain-old'JSPsversusJSTL ............................................................................. 292 14.2.3. Additionaltagsfacilitatingdevelopment ........................................................... 293 14.3. Tiles .......................................................................................................................... 293 14.3.1. Dependencies .................................................................................................. 293 14.3.2. HowtointegrateTiles ...................................................................................... 293 14.4. Velocity&FreeMarker ............................................................................................... 294 14.4.1. Dependencies .................................................................................................. 294 14.4.2. Contextconfiguration ...................................................................................... 295 14.4.3. Creatingtemplates ........................................................................................... 295 14.4.4. Advancedconfiguration ................................................................................... 296 14.4.5. Bindsupportandformhandling ........................................................................ 296 14.5. XSLT ........................................................................................................................ 303 14.5.1. MyFirstWords ............................................................................................... 303 14.5.2. Summary ........................................................................................................ 305 14.6. Documentviews(PDF/Excel) ..................................................................................... 305 14.6.1. Introduction..................................................................................................... 305 14.6.2. Configurationandsetup ................................................................................... 306 14.7. JasperReports ............................................................................................................. 308 14.7.1. Dependencies .................................................................................................. 308 14.7.2. Configuration .................................................................................................. 308 14.7.3. PopulatingtheModelAndView ........................................................................... 310 14.7.4. WorkingwithSub-Reports ............................................................................... 311 14.7.5. ConfiguringExporterParameters ...................................................................... 312 15. Integratingwithotherwebframeworks .............................................................................. 313 15.1. Introduction ............................................................................................................... 313 15.2. Commonconfiguration ............................................................................................... 313 15.3. JavaServerFaces ........................................................................................................ 315 15.3.1. DelegatingVariableResolver ............................................................................. 315 15.3.2. FacesContextUtils............................................................................................ 315 15.4. Struts ......................................................................................................................... 316 15.4.1. ContextLoaderPlugin ....................................................................................... 316 15.4.2. ActionSupportClasses ..................................................................................... 318 15.5. Tapestry ..................................................................................................................... 318 15.5.1. InjectingSpring-managedbeans ....................................................................... 319 15.6. WebWork .................................................................................................................. 324 15.7. FurtherResources ....................................................................................................... 325 16. PortletMVCFramework .................................................................................................... 326 16.1. Introduction ............................................................................................................... 326 16.1.1. Controllers-TheCinMVC ............................................................................. 327 16.1.2. Views-TheVinMVC .................................................................................... 327 16.1.3. Web-scopedbeans ........................................................................................... 327 16.2. TheDispatcherPortlet ............................................................................................. 327 16.3. TheViewRendererServlet ......................................................................................... 329 16.4. Controllers ................................................................................................................. 330 16.4.1. AbstractControllerandPortletContentGenerator ....................................... 331 SpringFramework(2.0.8) viii TheSpringFramework-ReferenceDocumentation 16.4.2. Othersimplecontrollers ................................................................................... 332 16.4.3. CommandControllers ...................................................................................... 332 16.4.4. PortletWrappingController ........................................................................... 333 16.5. Handlermappings ...................................................................................................... 333 16.5.1. PortletModeHandlerMapping ........................................................................... 334 16.5.2. ParameterHandlerMapping .............................................................................. 334 16.5.3. PortletModeParameterHandlerMapping ........................................................... 335 16.5.4. AddingHandlerInterceptors .......................................................................... 335 16.5.5. HandlerInterceptorAdapter ........................................................................... 336 16.5.6. ParameterMappingInterceptor ....................................................................... 336 16.6. Viewsandresolvingthem ........................................................................................... 336 16.7. Multipart(fileupload)support..................................................................................... 336 16.7.1. UsingthePortletMultipartResolver ............................................................. 337 16.7.2. Handlingafileuploadinaform ....................................................................... 337 16.8. Handlingexceptions ................................................................................................... 340 16.9. Portletapplicationdeployment .................................................................................... 340 IV. Integration .................................................................................................................................... 342 17. RemotingandwebservicesusingSpring ............................................................................. 343 17.1. Introduction ............................................................................................................... 343 17.2. ExposingservicesusingRMI ...................................................................................... 344 17.2.1. ExportingtheserviceusingtheRmiServiceExporter ........................................ 344 17.2.2. Linkingintheserviceattheclient..................................................................... 345 17.3. UsingHessianorBurlaptoremotelycallservicesviaHTTP ......................................... 345 17.3.1. WiringuptheDispatcherServletforHessian .................................................. 345 17.3.2. ExposingyourbeansbyusingtheHessianServiceExporter ............................. 346 17.3.3. Linkingintheserviceontheclient.................................................................... 346 17.3.4. UsingBurlap ................................................................................................... 346 17.3.5. ApplyingHTTPbasicauthenticationtoaserviceexposedthroughHessianor Burlap ......................................................................................................................... 346 17.4. ExposingservicesusingHTTPinvokers ...................................................................... 347 17.4.1. Exposingtheserviceobject .............................................................................. 347 17.4.2. Linkingintheserviceattheclient..................................................................... 347 17.5. Webservices .............................................................................................................. 348 17.5.1. ExposingservicesusingJAX-RPC ................................................................... 348 17.5.2. Accessingwebservices .................................................................................... 349 17.5.3. RegisterBeanMappings .................................................................................. 350 17.5.4. RegisteringourownHandler ............................................................................ 350 17.5.5. ExposingwebservicesusingXFire ................................................................... 351 17.6. JMS ........................................................................................................................... 352 17.6.1. Server-sideconfiguration ................................................................................. 353 17.6.2. Client-sideconfiguration .................................................................................. 353 17.7. Auto-detectionisnotimplementedforremoteinterfaces ............................................... 354 17.8. Considerationswhenchoosingatechnology ................................................................. 354 18. EnterpriseJavaBean(EJB)integration .............................................................................. 356 18.1. Introduction ............................................................................................................... 356 18.2. AccessingEJBs .......................................................................................................... 356 18.2.1. Concepts ......................................................................................................... 356 18.2.2. AccessinglocalSLSBs .................................................................................... 356 18.2.3. AccessingremoteSLSBs ................................................................................. 358 18.3. UsingSpring'sconvenienceEJBimplementationclasses............................................... 358 19. JMS ..................................................................................................................................... 361 19.1. Introduction ............................................................................................................... 361 SpringFramework(2.0.8) ix TheSpringFramework-ReferenceDocumentation 19.2. UsingSpringJMS ...................................................................................................... 362 19.2.1. JmsTemplate ................................................................................................... 362 19.2.2. Connections .................................................................................................... 362 19.2.3. DestinationManagement .................................................................................. 363 19.2.4. MessageListenerContainers ............................................................................ 363 19.2.5. Transactionmanagement .................................................................................. 364 19.3. SendingaMessage ...................................................................................................... 365 19.3.1. UsingMessageConverters ............................................................................... 366 19.3.2. SessionCallbackandProducerCallback ......................................................... 366 19.4. Receivingamessage ................................................................................................... 366 19.4.1. SynchronousReception .................................................................................... 367 19.4.2. AsynchronousReception-Message-DrivenPOJOs ........................................... 367 19.4.3. TheSessionAwareMessageListenerinterface ................................................... 367 19.4.4. TheMessageListenerAdapter ......................................................................... 368 19.4.5. Processingmessageswithintransactions ........................................................... 370 20. JMX .................................................................................................................................... 371 20.1. Introduction ............................................................................................................... 371 20.2. ExportingyourbeanstoJMX ...................................................................................... 371 20.2.1. CreatinganMBeanServer ................................................................................. 372 20.2.2. ReusinganexistingMBeanServer ..................................................................... 373 20.2.3. Lazy-initializedMBeans .................................................................................. 373 20.2.4. AutomaticregistrationofMBeans .................................................................... 374 20.2.5. Controllingtheregistrationbehavior ................................................................. 374 20.3. Controllingthemanagementinterfaceofyourbeans ..................................................... 375 20.3.1. TheMBeanInfoAssembler Interface ................................................................................................................ 375 20.3.2. Usingsource-Levelmetadata ............................................................................ 375 20.3.3. UsingJDK5.0Annotations .............................................................................. 377 20.3.4. Source-LevelMetadataTypes .......................................................................... 379 20.3.5. TheAutodetectCapableMBeanInfoAssembler interface ................................................................................................................ 380 20.3.6. DefiningManagementinterfacesusingJavainterfaces ....................................... 381 20.3.7. Using MethodNameBasedMBeanInfoAssembler ................................................................... 382 20.4. ControllingtheObjectNamesforyourbeans ................................................................. 382 20.4.1. ReadingObjectNamesfromProperties ............................................................ 382 20.4.2. UsingtheMetadataNamingStrategy ................................................................. 383 20.5. JSR-160Connectors ................................................................................................... 384 20.5.1. Server-sideConnectors .................................................................................... 384 20.5.2. Client-sideConnectors ..................................................................................... 385 20.5.3. JMXoverBurlap/Hessian/SOAP ...................................................................... 385 20.6. AccessingMBeansviaProxies .................................................................................... 385 20.7. Notifications .............................................................................................................. 386 20.7.1. RegisteringListenersforNotifications .............................................................. 386 20.7.2. PublishingNotifications ................................................................................... 388 20.8. FurtherResources ....................................................................................................... 389 21. JCACCI ............................................................................................................................. 391 21.1. Introduction ............................................................................................................... 391 21.2. ConfiguringCCI ........................................................................................................ 391 21.2.1. Connectorconfiguration ................................................................................... 391 21.2.2. ConnectionFactoryconfigurationinSpring ...................................................... 392 21.2.3. ConfiguringCCIconnections ........................................................................... 392 SpringFramework(2.0.8) x

Description:
Aspect Oriented Programming (AOP) . 22. 2.5.2. Sensible defaulting in Spring MVC .. 23. 2.5.3. Portlet framework .
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.