Reference Documentation Version 1.2.9 (Work in progress) Copyright (c) 2004-2007 Rod Johnson, Juergen Hoeller, Alef Arendsen, Colin Sampaleanu, Rob Harrop, Thomas Risberg, Darren Davison, Dmitriy Kopylenko, Mark Pollack, Thierry Templier, Erwin Vervaet Copiesofthisdocumentmaybemadeforyourownuseandfordistributiontoothers,providedthatyoudonot chargeanyfeeforsuchcopiesandfurtherprovidedthateachcopycontainsthisCopyrightNotice,whether distributedinprintorelectronically. Preface ................................................................................................................................................ xi 1. Introduction .................................................................................................................................. 12 1.1. Overview ............................................................................................................................. 12 1.2. Usagescenarios.................................................................................................................... 13 2. Backgroundinformation ............................................................................................................... 16 2.1. InversionofControl/DependencyInjection .......................................................................... 16 3. Beans,BeanFactoryandtheApplicationContext .......................................................................... 17 3.1. Introduction ......................................................................................................................... 17 3.2. BeanFactoryandBeanDefinitions-thebasics ........................................................................ 17 3.2.1. TheBeanFactory ....................................................................................................... 17 3.2.2. TheBeanDefinition ................................................................................................... 19 3.2.3. Thebeanclass ........................................................................................................... 19 3.2.4. Thebeanidentifiers(idand name) ............................................................................................................................. 21 3.2.5. Tosingletonornottosingleton .................................................................................. 21 3.3. Properties,collaborators,autowiringanddependency checking .................................................................................................................................. 22 3.3.1. Settingbeanpropertiesandcollaborators .................................................................... 22 3.3.2. ConstructorArgumentResolution ............................................................................... 25 3.3.3. Beanpropertiesandconstructorargumentsdetailed ..................................................... 26 3.3.4. MethodInjection ....................................................................................................... 30 3.3.5. Usingdepends-on ..................................................................................................... 32 3.3.6. Autowiringcollaborators............................................................................................ 33 3.3.7. Checkingfordependencies ......................................................................................... 34 3.4. Customizingthenatureofabean ........................................................................................... 34 3.4.1. Lifecycleinterfaces ................................................................................................... 35 3.4.2. Knowingwhoyouare ................................................................................................ 36 3.4.3. FactoryBean .............................................................................................................. 37 3.5. Abstractandchildbeandefinitions ........................................................................................ 37 3.6. InteractingwiththeBeanFactory ........................................................................................... 38 3.6.1. ObtainingaFactoryBean,notitsproduct ..................................................................... 39 3.7. CustomizingbeanswithBeanPostProcessors ......................................................................... 39 3.8. CustomizingbeanfactorieswithBeanFactoryPostProcessors .................................................. 39 3.8.1. ThePropertyPlaceholderConfigurer ....................................................................... 40 3.8.2. ThePropertyOverrideConfigurer ............................................................................ 41 3.9. RegisteringadditionalcustomPropertyEditors ....................................................................... 41 3.10. Usingthealiaselementtoaddaliasesforexistingbeans ....................................................... 42 3.11. IntroductiontotheApplicationContext.............................................................................. 43 3.12. Addedfunctionalityofthe ApplicationContext ............................................................................................................... 43 3.12.1. UsingtheMessageSource ......................................................................................... 43 3.12.2. Propagatingevents ................................................................................................... 44 3.12.3. Low-levelresourcesandtheapplicationcontext ........................................................ 45 3.13. CustomizedbehaviorintheApplicationContext ................................................................... 46 3.13.1. ApplicationContextAwaremarker interface ........................................................................................................................ 46 3.13.2. TheBeanPostProcessor .......................................................................................... 46 3.13.3. TheBeanFactoryPostProcessor .............................................................................. 46 3.13.4. ThePropertyPlaceholderConfigurer ..................................................................... 47 3.14. RegisteringadditionalcustomPropertyEditors ..................................................................... 47 3.15. Settingabeanpropertyorconstructorargfromaproperty expression ............................................................................................................................... 48 SpringFrameworkVersion1.2.9 ii Spring-Java/J2EEApplicationFramework 3.16. Settingabeanpropertyorconstructorargfromafield value ....................................................................................................................................... 49 3.17. Invokinganothermethodandoptionallyusingthereturn value. ...................................................................................................................................... 49 3.18. ImportingBeanDefinitionsfromOneFileIntoAnother ....................................................... 50 3.19. CreatinganApplicationContextfromawebapplication ........................................................ 51 3.20. Gluecodeandtheevilsingleton .......................................................................................... 52 3.20.1. UsingSingletonBeanFactoryLocatorand ContextSingletonBeanFactoryLocator ............................................................................. 52 4. AbstractingAccesstoLow-LevelResources .................................................................................. 54 4.1. Overview ............................................................................................................................. 54 4.2. TheResourceinterface ......................................................................................................... 54 4.3. Built-inResourceimplementations ........................................................................................ 55 4.3.1. UrlResource ............................................................................................................. 55 4.3.2. ClassPathResource................................................................................................... 55 4.3.3. FileSystemResource ................................................................................................. 56 4.3.4. ServletContextResource .......................................................................................... 56 4.3.5. InputStreamResource ............................................................................................... 56 4.3.6. ByteArrayResource................................................................................................... 56 4.4. TheResourceLoaderInterface .............................................................................................. 56 4.5. TheResourceLoaderAwareinterface ..................................................................................... 57 4.6. SettingResourcesasproperties ............................................................................................. 57 4.7. ApplicationcontextsandResourcepaths ............................................................................... 58 4.7.1. Constructingapplicationcontexts ............................................................................... 58 4.7.2. Theclasspath*:prefix ............................................................................................. 58 4.7.3. UnexpectedapplicationcontexthandlingofFileSystemResource absolutepaths ................................................................................................................ 59 5. PropertyEditors,databinding,validationandtheBeanWrapper ................................................. 61 5.1. Introduction ......................................................................................................................... 61 5.2. BindingdatausingtheDataBinder ........................................................................................ 61 5.3. BeanmanipulationandtheBeanWrapper................................................................................ 61 5.3.1. Settingandgettingbasicandnestedproperties ............................................................ 62 5.3.2. Built-inPropertyEditors,converting types ............................................................................................................................. 63 5.3.3. Otherfeaturesworthmentioning................................................................................. 65 5.4. ValidationusingSpring'sValidatorinterface .......................................................................... 65 5.5. TheErrorsinterface .............................................................................................................. 66 5.6. Resolvingcodestoerrormessages......................................................................................... 66 6. SpringAOP:AspectOrientedProgrammingwithSpring ............................................................. 67 6.1. Concepts .............................................................................................................................. 67 6.1.1. AOPconcepts ........................................................................................................... 67 6.1.2. SpringAOPcapabilitiesandgoals .............................................................................. 68 6.1.3. AOPProxiesinSpring ............................................................................................... 69 6.2. PointcutsinSpring ............................................................................................................... 69 6.2.1. Concepts ................................................................................................................... 70 6.2.2. Operationsonpointcuts ............................................................................................. 70 6.2.3. Conveniencepointcutimplementations ....................................................................... 71 6.2.4. Pointcutsuperclasses ................................................................................................. 72 6.2.5. Custompointcuts ....................................................................................................... 73 6.3. AdvicetypesinSpring.......................................................................................................... 73 6.3.1. Advicelifecycles ....................................................................................................... 73 6.3.2. AdvicetypesinSpring ............................................................................................... 73 SpringFrameworkVersion1.2.9 iii Spring-Java/J2EEApplicationFramework 6.4. AdvisorsinSpring................................................................................................................ 78 6.5. UsingtheProxyFactoryBeantocreateAOPproxies ............................................................... 78 6.5.1. Basics ....................................................................................................................... 78 6.5.2. JavaBeanproperties ................................................................................................... 79 6.5.3. Proxyinginterfaces .................................................................................................... 80 6.5.4. Proxyingclasses ........................................................................................................ 81 6.5.5. Using'global'advisors ............................................................................................... 82 6.6. Convenientproxycreation .................................................................................................... 82 6.6.1. TransactionProxyFactoryBean .................................................................................... 82 6.6.2. EJBproxies ............................................................................................................... 83 6.7. Conciseproxydefinitions ..................................................................................................... 84 6.8. CreatingAOPproxiesprogrammaticallywiththeProxyFactory .............................................. 85 6.9. Manipulatingadvisedobjects ................................................................................................ 85 6.10. Usingthe"autoproxy"facility ............................................................................................. 86 6.10.1. Autoproxybeandefinitions ...................................................................................... 87 6.10.2. Usingmetadata-drivenauto-proxying ....................................................................... 88 6.11. UsingTargetSources........................................................................................................... 90 6.11.1. Hotswappabletargetsources .................................................................................... 90 6.11.2. Poolingtargetsources .............................................................................................. 91 6.11.3. Prototypetargetsources ........................................................................................... 92 6.11.4. ThreadLocaltargetsources ....................................................................................... 92 6.12. DefiningnewAdvicetypes ................................................................................................. 93 6.13. Furtherreadingandresources .............................................................................................. 93 7. AspectJIntegration ....................................................................................................................... 94 7.1. Overview ............................................................................................................................. 94 7.2. ConfiguringAspectJaspectsusingSpringIoC ....................................................................... 94 7.2.1. "Singleton"aspects .................................................................................................... 94 7.2.2. Non-singletonaspects ................................................................................................ 95 7.2.3. Gotchas .................................................................................................................... 95 7.3. UsingAspectJpointcutstotargetSpringadvice ..................................................................... 95 7.4. SpringaspectsforAspectJ .................................................................................................... 96 8. Transactionmanagement .............................................................................................................. 97 8.1. TheSpringtransactionabstraction ......................................................................................... 97 8.2. Transactionstrategies ........................................................................................................... 98 8.3. Resourcesynchronizationwithtransactions ........................................................................... 100 8.3.1. High-levelapproach .................................................................................................. 100 8.3.2. Low-levelapproach ................................................................................................... 100 8.3.3. TransactionAwareDataSourceProxy............................................................................ 101 8.4. Programmatictransactionmanagement .................................................................................. 101 8.4.1. UsingtheTransactionTemplate ................................................................................ 102 8.4.2. UsingthePlatformTransactionManager .................................................................... 102 8.5. Declarativetransactionmanagement ...................................................................................... 103 8.5.1. SourceAnnotationsforTransactionDemarcation ........................................................ 105 8.5.2. BeanNameAutoProxyCreator, anotherdeclarativeapproach ........................................................................................... 108 8.5.3. AOPandTransactions ............................................................................................... 110 8.6. Choosingbetweenprogrammaticanddeclarativetransaction management ............................................................................................................................ 110 8.7. Doyouneedanapplicationserverfortransaction management?........................................................................................................................... 110 8.8. AppServer-specificintegration .............................................................................................. 110 8.8.1. BEAWebLogic ......................................................................................................... 111 SpringFrameworkVersion1.2.9 iv Spring-Java/J2EEApplicationFramework 8.8.2. IBMWebSphere........................................................................................................ 111 8.9. Commonproblems ............................................................................................................... 111 8.9.1. Useofthewrongtransactionmanagerforaspecific DataSource .................................................................................................................... 111 8.9.2. SpuriousAppServerwarningsaboutthetransactionorDataSource nolongerbeingactive .................................................................................................... 111 9. SourceLevelMetadataSupport .................................................................................................... 113 9.1. Source-levelmetadata........................................................................................................... 113 9.2. Spring'smetadatasupport ..................................................................................................... 114 9.3. IntegrationwithJakartaCommonsAttributes ......................................................................... 115 9.4. MetadataandSpringAOPautoproxying ................................................................................ 116 9.4.1. Fundamentals ............................................................................................................ 116 9.4.2. Declarativetransactionmanagement ........................................................................... 117 9.4.3. Pooling ..................................................................................................................... 117 9.4.4. Custommetadata ....................................................................................................... 118 9.5. UsingattributestominimizeMVCwebtierconfiguration ....................................................... 119 9.6. Otherusesofmetadataattributes ........................................................................................... 121 9.7. AddingsupportforadditionalmetadataAPIs ......................................................................... 121 10. DAOsupport ............................................................................................................................... 122 10.1. Introduction ....................................................................................................................... 122 10.2. ConsistentExceptionHierarchy........................................................................................... 122 10.3. ConsistentAbstractClassesforDAOSupport ...................................................................... 123 11. DataAccessusingJDBC.............................................................................................................. 124 11.1. Introduction ....................................................................................................................... 124 11.2. UsingtheJDBCCoreclassestocontrolbasicJDBCprocessingand errorhandling .......................................................................................................................... 124 11.2.1. JdbcTemplate .......................................................................................................... 124 11.2.2. DataSource.............................................................................................................. 125 11.2.3. SQLExceptionTranslator .......................................................................................... 125 11.2.4. ExecutingStatements ............................................................................................... 126 11.2.5. RunningQueries ...................................................................................................... 126 11.2.6. Updatingthedatabase .............................................................................................. 127 11.3. Controllinghowweconnecttothedatabase ......................................................................... 128 11.3.1. DataSourceUtils ...................................................................................................... 128 11.3.2. SmartDataSource ..................................................................................................... 128 11.3.3. AbstractDataSource ................................................................................................. 128 11.3.4. SingleConnectionDataSource ................................................................................... 128 11.3.5. DriverManagerDataSource ....................................................................................... 128 11.3.6. TransactionAwareDataSourceProxy .......................................................................... 129 11.3.7. DataSourceTransactionManager ............................................................................... 129 11.4. ModelingJDBCoperationsasJavaobjects .......................................................................... 129 11.4.1. SqlQuery ................................................................................................................. 129 11.4.2. MappingSqlQuery ................................................................................................... 130 11.4.3. SqlUpdate ............................................................................................................... 131 11.4.4. StoredProcedure ...................................................................................................... 131 11.4.5. SqlFunction ............................................................................................................. 132 12. DataAccessusingO/RMappers .................................................................................................. 133 12.1. Introduction ....................................................................................................................... 133 12.2. Hibernate ........................................................................................................................... 134 12.2.1. Resourcemanagement ............................................................................................. 134 12.2.2. SessionFactorysetupinaSpringapplicationcontext .................................................. 135 12.2.3. InversionofControl:HibernateTemplateand SpringFrameworkVersion1.2.9 v Spring-Java/J2EEApplicationFramework HibernateCallback .......................................................................................................... 136 12.2.4. ImplementingSpring-basedDAOswithoutcallbacks ................................................. 137 12.2.5. ImplementingDAOsbasedonplainHibernate3API .................................................. 137 12.2.6. Programmatictransactiondemarcation ...................................................................... 138 12.2.7. Declarativetransactiondemarcation .......................................................................... 139 12.2.8. Transactionmanagementstrategies ........................................................................... 141 12.2.9. Containerresourcesversuslocalresources ................................................................ 142 12.2.10. SpuriousAppServerwarningsaboutthetransactionorDataSource nolongerbeingactive .................................................................................................... 143 12.3. JDO ................................................................................................................................... 144 12.3.1. PersistenceManagerFactorysetup ............................................................................. 144 12.3.2. JdoTemplateandJdoDaoSupport .............................................................................. 145 12.3.3. ImplementingDAOsbasedonplainJDOAPI ........................................................... 146 12.3.4. Transactionmanagement .......................................................................................... 148 12.3.5. JdoDialect ............................................................................................................... 148 12.4. OracleTopLink .................................................................................................................. 149 12.4.1. SessionFactoryabstraction ....................................................................................... 149 12.4.2. TopLinkTemplateandTopLinkDaoSupport .............................................................. 150 12.4.3. ImplementingDAOsbasedonplainTopLinkAPI ..................................................... 151 12.4.4. Transactionmanagement .......................................................................................... 153 12.5. ApacheOJB ....................................................................................................................... 153 12.5.1. OJBsetupinaSpringenvironment ........................................................................... 154 12.5.2. PersistenceBrokerTemplateandPersistenceBrokerDaoSupport ................................... 154 12.5.3. Transactionmanagement .......................................................................................... 155 12.6. iBATISSQLMaps ............................................................................................................. 156 12.6.1. OverviewanddifferencesbetweeniBATIS1.xand2.x .............................................. 156 12.6.2. iBATISSQLMaps1.x ............................................................................................. 157 12.6.3. iBATISSQLMaps2.x ............................................................................................. 158 13. WebMVCframework ................................................................................................................. 162 13.1. IntroductiontothewebMVCframework ............................................................................. 162 13.1.1. PluggabilityofotherMVCimplementations .............................................................. 162 13.1.2. FeaturesofSpringMVC .......................................................................................... 163 13.2. TheDispatcherServlet ..................................................................................................... 163 13.3. Controllers ......................................................................................................................... 166 13.3.1. AbstractControllerandWebContentGenerator ........................................................... 166 13.3.2. Othersimplecontrollers ........................................................................................... 167 13.3.3. TheMultiActionController ................................................................................... 167 13.3.4. CommandControllers ............................................................................................... 169 13.4. Handlermappings .............................................................................................................. 170 13.4.1. BeanNameUrlHandlerMapping ................................................................................... 171 13.4.2. SimpleUrlHandlerMapping ...................................................................................... 171 13.4.3. AddingHandlerInterceptors ................................................................................. 172 13.5. Viewsandresolvingthem ................................................................................................... 173 13.5.1. ViewResolvers ........................................................................................................ 174 13.5.2. ChainingViewResolvers .......................................................................................... 175 13.5.3. Redirectingtoviews ................................................................................................ 176 13.6. Usinglocales...................................................................................................................... 177 13.6.1. AcceptHeaderLocaleResolver ................................................................................. 177 13.6.2. CookieLocaleResolver ........................................................................................... 177 13.6.3. SessionLocaleResolver .......................................................................................... 178 13.6.4. LocaleChangeInterceptor ...................................................................................... 178 13.7. Usingthemes ..................................................................................................................... 178 SpringFrameworkVersion1.2.9 vi Spring-Java/J2EEApplicationFramework 13.7.1. Introduction............................................................................................................. 179 13.7.2. Definingthemes ...................................................................................................... 179 13.7.3. Themeresolvers ...................................................................................................... 179 13.8. Spring'smultipart(fileupload)support ................................................................................. 180 13.8.1. Introduction............................................................................................................. 180 13.8.2. UsingtheMultipartResolver .................................................................................. 180 13.8.3. Handlingafileuploadinaform ................................................................................ 181 13.9. Handlingexceptions ........................................................................................................... 182 14. Integratingviewtechnologies ...................................................................................................... 184 14.1. Introduction ....................................................................................................................... 184 14.2. JSP&JSTL ....................................................................................................................... 184 14.2.1. Viewresolvers......................................................................................................... 184 14.2.2. 'Plain-old'JSPsversusJSTL ..................................................................................... 184 14.2.3. Additionaltagsfacilitatingdevelopment ................................................................... 185 14.3. Tiles .................................................................................................................................. 185 14.3.1. Dependencies .......................................................................................................... 185 14.3.2. HowtointegrateTiles .............................................................................................. 185 14.4. Velocity&FreeMarker ....................................................................................................... 186 14.4.1. Dependencies .......................................................................................................... 186 14.4.2. Contextconfiguration .............................................................................................. 187 14.4.3. Creatingtemplates ................................................................................................... 187 14.4.4. Advancedconfiguration ........................................................................................... 187 14.4.5. Bindsupportandformhandling ................................................................................ 188 14.5. XSLT ................................................................................................................................ 194 14.5.1. MyFirstWords ....................................................................................................... 194 14.5.2. Summary ................................................................................................................ 196 14.6. Documentviews(PDF/Excel) ............................................................................................. 197 14.6.1. Introduction............................................................................................................. 197 14.6.2. Configurationandsetup ........................................................................................... 197 14.7. JasperReports ..................................................................................................................... 199 14.7.1. Dependencies .......................................................................................................... 199 14.7.2. Configuration .......................................................................................................... 200 14.7.3. PopulatingtheModelAndView ................................................................................... 202 14.7.4. WorkingwithSub-Reports ....................................................................................... 202 14.7.5. ConfiguringExporterParameters .............................................................................. 203 15. Integratingwithotherwebframeworks ...................................................................................... 205 15.1. Introduction ....................................................................................................................... 205 15.2. JavaServerFaces ................................................................................................................ 206 15.2.1. DelegatingVariableResolver ..................................................................................... 206 15.2.2. FacesContextUtils.................................................................................................... 206 15.3. Struts ................................................................................................................................. 207 15.3.1. ContextLoaderPlugin ............................................................................................... 207 15.3.2. ActionSupportClasses ............................................................................................. 209 15.4. Tapestry ............................................................................................................................. 209 15.4.1. Architecture ............................................................................................................ 210 15.4.2. Implementation ....................................................................................................... 211 15.4.3. Summary ................................................................................................................ 216 15.5. WebWork .......................................................................................................................... 216 16. RemotingandwebservicesusingSpring ..................................................................................... 218 16.1. Introduction ....................................................................................................................... 218 16.2. ExposingservicesusingRMI .............................................................................................. 219 16.2.1. ExportingtheserviceusingtheRmiServiceExporter ................................................ 219 SpringFrameworkVersion1.2.9 vii Spring-Java/J2EEApplicationFramework 16.2.2. Linkingintheserviceattheclient............................................................................. 220 16.3. UsingHessianorBurlaptoremotelycallservicesviaHTTP ................................................. 220 16.3.1. WiringuptheDispatcherServletforHessian ............................................................. 220 16.3.2. ExposingyourbeansbyusingtheHessianServiceExporter ......................................... 221 16.3.3. Linkingintheserviceontheclient............................................................................ 221 16.3.4. UsingBurlap ........................................................................................................... 221 16.3.5. ApplyingHTTPbasicauthenticationtoaserviceexposedthroughHessianorBurlap ............................................................................................................................................ 221 16.4. ExposingservicesusingHTTPinvokers .............................................................................. 222 16.4.1. Exposingtheserviceobject ...................................................................................... 222 16.4.2. Linkingintheserviceattheclient............................................................................. 222 16.5. WebServices ..................................................................................................................... 223 16.5.1. ExposingservicesusingJAX-RPC ........................................................................... 223 16.5.2. AccessingWebServices .......................................................................................... 224 16.5.3. RegisterBeanMappings .......................................................................................... 225 16.5.4. RegisteringourownHandler .................................................................................... 226 16.5.5. ExposingwebservicesusingXFire ........................................................................... 226 16.6. Auto-detectionisnotimplementedforremoteinterfaces ....................................................... 227 16.7. Considerationswhenchoosingatechnology ......................................................................... 228 17. AccessingandimplementingEJBs .............................................................................................. 229 17.1. AccessingEJBs .................................................................................................................. 229 17.1.1. Concepts ................................................................................................................. 229 17.1.2. AccessinglocalSLSBs ............................................................................................ 229 17.1.3. AccessingremoteSLSBs ......................................................................................... 231 17.2. UsingSpringconvenienceEJBimplementationclasses ......................................................... 231 18. JMS ............................................................................................................................................. 234 18.1. Introduction ....................................................................................................................... 234 18.2. Domainunification ............................................................................................................. 234 18.3. JmsTemplate ...................................................................................................................... 234 18.3.1. ConnectionFactory................................................................................................... 235 18.3.2. TransactionManagement ......................................................................................... 235 18.3.3. DestinationManagement .......................................................................................... 236 18.4. UsingtheJmsTemplate ....................................................................................................... 236 18.4.1. Sendingamessage ................................................................................................... 237 18.4.2. SynchronousReceiving ............................................................................................ 237 18.4.3. UsingMessageConverters ....................................................................................... 238 18.4.4. SessionCallbackandProducerCallback ..................................................................... 238 19. JMXSupport .............................................................................................................................. 240 19.1. Introduction ....................................................................................................................... 240 19.2. ExportingyourBeanstoJMX ............................................................................................. 240 19.2.1. CreatinganMBeanServer ........................................................................................ 241 19.2.2. Lazy-InitializedMBeans .......................................................................................... 242 19.2.3. AutomaticRegistrationofMBeans ........................................................................... 242 19.3. ControllingtheManagementInterfaceofYourBeans ........................................................... 242 19.3.1. TheMBeanInfoAssemblerInterface .......................................................................... 242 19.3.2. UsingSource-LevelMetadata ................................................................................... 242 19.3.3. UsingJDK5.0Annotations ...................................................................................... 244 19.3.4. Source-LevelMetadataTypes .................................................................................. 245 19.3.5. TheAutodetectCapableMBeanInfoAssembler Interface ........................................................................................................................ 247 19.3.6. DefiningManagementInterfacesusingJavaInterfaces............................................... 247 19.3.7. Using SpringFrameworkVersion1.2.9 viii Spring-Java/J2EEApplicationFramework MethodNameBasedMBeanInfoAssembler ..................................................................................................................... 249 19.4. ControllingtheObjectNamesforyour Beans ...................................................................................................................................... 249 19.4.1. ReadingObjectNamesfrom Properties ..................................................................................................................... 249 19.4.2. UsingtheMetadataNamingStrategy ..................................................................................................................... 250 19.5. ExportingyourBeanswithJSR-160Connectors ................................................................... 250 19.5.1. Server-sideConnectors ............................................................................................ 250 19.5.2. Client-sideConnectors ............................................................................................. 251 19.5.3. JMXoverBurlap/Hessian/SOAP .............................................................................. 251 19.6. AccessingMBeansviaProxies ............................................................................................ 252 20. JCACCI ..................................................................................................................................... 253 20.1. Introduction ....................................................................................................................... 253 20.2. ConfiguringCCI ................................................................................................................ 253 20.2.1. Connectorconfiguration ........................................................................................... 253 20.2.2. ConnectionFactoryconfigurationinSpring ............................................................... 254 20.2.3. ConfiguringCCIconnections ................................................................................... 254 20.2.4. UsingasingleCCIconnection .................................................................................. 255 20.3. UsingSpring'sCCIaccesssupport ....................................................................................... 255 20.3.1. Recordconversion ................................................................................................... 255 20.3.2. CciTemplate ............................................................................................................ 256 20.3.3. DAOsupport ........................................................................................................... 258 20.3.4. Automaticoutputrecordgeneration .......................................................................... 258 20.3.5. Summary ................................................................................................................ 258 20.3.6. UsingaCCIConnectionandInteractiondirectly ....................................................... 259 20.3.7. ExampleforCciTemplateusage ............................................................................... 260 20.4. ModelingCCIaccessasoperationobjects ............................................................................ 261 20.4.1. MappingRecordOperation ........................................................................................ 262 20.4.2. MappingCommAreaOperation .................................................................................. 262 20.4.3. Automaticoutputrecordgeneration .......................................................................... 263 20.4.4. Summary ................................................................................................................ 263 20.4.5. ExampleforMappingRecordOperationusage ............................................................ 263 20.4.6. ExampleforMappingCommAreaOperationusage ..................................................... 265 20.5. Transactions ....................................................................................................................... 266 21. SendingEmailwithSpringmailabstractionlayer....................................................................... 267 21.1. Introduction ....................................................................................................................... 267 21.2. Springmailabstractionstructure ......................................................................................... 267 21.3. UsingSpringmailabstraction.............................................................................................. 268 21.3.1. PluggableMailSenderimplementations ..................................................................... 270 21.4. UsingtheJavaMailMimeMessageHelper ............................................................................ 270 21.4.1. CreatingasimpleMimeMessageandsendingit ......................................................... 270 21.4.2. Sendingattachmentsandinlineresources .................................................................. 271 22. SchedulingjobsusingQuartzorTimer ....................................................................................... 272 22.1. Introduction ....................................................................................................................... 272 22.2. UsingtheOpenSymphonyQuartzScheduler ........................................................................ 272 22.2.1. UsingtheJobDetailBean .......................................................................................... 272 22.2.2. UsingtheMethodInvokingJobDetailFactoryBean ...................................................... 273 22.2.3. WiringupjobsusingtriggersandtheSchedulerFactoryBean ...................................... 273 22.3. UsingJDKTimersupport ................................................................................................... 274 SpringFrameworkVersion1.2.9 ix Spring-Java/J2EEApplicationFramework 22.3.1. Creatingcustomtimers ............................................................................................ 274 22.3.2. UsingtheMethodInvokingTimerTaskFactoryBean .................................................... 275 22.3.3. Wrappingup:settingupthetasksusingtheTimerFactoryBean ................................... 275 23. Testing......................................................................................................................................... 277 23.1. Unittesting ........................................................................................................................ 277 23.2. Integrationtesting ............................................................................................................... 277 23.2.1. Contextmanagementandcaching ............................................................................. 278 23.2.2. DependencyInjectionoftestclassinstances .............................................................. 278 23.2.3. Transactionmanagement .......................................................................................... 278 23.2.4. Conveniencevariables ............................................................................................. 279 23.2.5. Example .................................................................................................................. 279 23.2.6. Runningintegrationtests .......................................................................................... 281 A. spring-beans.dtd ......................................................................................................................... 282 SpringFrameworkVersion1.2.9 x
Description: