introduction to spring framework
DESCRIPTION
Presentation of CityGrid internal developer training.TRANSCRIPT
![Page 1: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/1.jpg)
Developer Training
Introduction to Spring FrameworkWhat’s New in 3.0 & 3.1?
![Page 2: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/2.jpg)
Who am I?
• Andy Chan• Software Architect• Co-Author of Apress Pro Spring Integration• ISBN: 978-1-4302-3345-9• Twitter: iceycake• Skype: achan1218
![Page 3: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/3.jpg)
• Pro Spring 3• Clarence Ho, Rob Harrop• Published April 18, 2012• ISBN: 978-1-4302-4107-2• Spring 3.0 & 3.1
![Page 4: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/4.jpg)
What is Spring?
“Most Popular Application Development Framework for Enterprise Java.”
http://www.springsource.org
![Page 5: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/5.jpg)
History
![Page 6: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/6.jpg)
Spring Overview
• Spring Framework• Spring Batch• Spring Integration• Spring Security• Spring Web Service• Spring Data• Spring Hadoop
• Spring Mobile• Spring Social• Spring Web Flow• Spring BlazeDS• Spring Roo• Spring .NET• Spring Python• …
![Page 7: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/7.jpg)
Spring Overview
• Spring Framework• Spring Batch• Spring Integration• Spring Security• Spring Web Service• Spring Data• Spring Hadoop
• Spring Mobile• Spring Social• Spring Web Flow• Spring BlazeDS• Spring Roo• Spring .NET• Spring Python• …
![Page 8: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/8.jpg)
Spring Overview
• Spring Framework• Spring Batch• Spring Integration• Spring Security• Spring Web Service• Spring Data• Spring Hadoop
• Spring Mobile• Spring Social• Spring Web Flow• Spring BlazeDS• Spring Roo• Spring .NET• Spring Python• …
![Page 9: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/9.jpg)
Spring FrameworkOverview
![Page 10: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/10.jpg)
Spring FrameworkOverview
• Foundation of Spring Extentions• Inversion of Control (IoC) and Containers• Spring Profile• Abstractions for JDBC, JPA, JTA, JMS, WS• MVC Framework
![Page 11: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/11.jpg)
Inversion of Control (IoC)
![Page 12: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/12.jpg)
Inversion of Control (IoC)
• Java EE: EJB and EJB Container• Spring: POJO and POJO Container• Spring vs Java EE => Lightweight• Object Creation• Object Lookup• Object Life Cycle Management
![Page 13: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/13.jpg)
Inversion of Control (IoC)
![Page 14: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/14.jpg)
Inversion of Control (IoC)
![Page 15: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/15.jpg)
Inversion of Control (IoC)
![Page 16: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/16.jpg)
Inversion of Control (IoC)
![Page 17: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/17.jpg)
Inversion of Control (IoC)
![Page 18: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/18.jpg)
Spring IoC Container
![Page 19: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/19.jpg)
Maven & Spring 2.5
![Page 20: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/20.jpg)
Maven & Spring 2.5
![Page 21: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/21.jpg)
Maven & Spring 3.0/3.1
![Page 22: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/22.jpg)
Maven & Spring 3.0/3.1
![Page 23: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/23.jpg)
Spring IoC Container
![Page 24: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/24.jpg)
Spring IoC Container
![Page 25: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/25.jpg)
Bean Scopes
![Page 26: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/26.jpg)
Spring IoC Container
![Page 27: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/27.jpg)
Spring IoC Container
![Page 28: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/28.jpg)
Auto Wiring
![Page 29: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/29.jpg)
Auto Wiring (Cont’d)
![Page 30: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/30.jpg)
Auto Discovery
![Page 31: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/31.jpg)
Auto Discovery (Cont’d)
![Page 32: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/32.jpg)
Auto Discovery (Cont’d)
![Page 33: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/33.jpg)
Constructor
![Page 34: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/34.jpg)
Constructor (Cont’d)
![Page 35: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/35.jpg)
XML Based Configuration
• “XML Programming”• No Unit Testing• Error Message is not Helpful• Difficult to Catch Typo• Difficult to Troubleshoot
![Page 36: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/36.jpg)
JavaConfig
• Spring 3.0+• Answer to Google’s Guice• Annotation/Java Based DI• Same Level of Isolation as XML Configuration • Work with XML Configuration• Constructor is Useful again – Immutable• Unit Testing?
![Page 37: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/37.jpg)
JavaConfig (Cont’d)
![Page 38: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/38.jpg)
JavaConfig (Cont’d)
![Page 39: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/39.jpg)
JavaConfig (Cont’d)
![Page 40: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/40.jpg)
Property Management
![Page 41: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/41.jpg)
Maven Profile
![Page 42: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/42.jpg)
Maven Profile (Cont’d)
![Page 43: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/43.jpg)
Maven Profile (Cont’d)
• Package Time Substitute• Security Concern– Exposing Username/Password
• Rebuild if Configuration Changes
![Page 44: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/44.jpg)
Spring & Properties
![Page 45: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/45.jpg)
Spring & Properties (Cont’d)
![Page 46: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/46.jpg)
Spring & Properties (Cont’d)
• Managed Properties File Safely• No Rebuild if Configurations Need Change• Can Use JavaConfig & Auto Wiring
![Page 47: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/47.jpg)
Spring Profile
![Page 48: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/48.jpg)
Spring Profile (Cont’d)
![Page 49: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/49.jpg)
Spring Profile (Cont’d)
![Page 50: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/50.jpg)
Spring Profile (Cont’d)
![Page 51: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/51.jpg)
Spring Profile (Cont’d)
• Different implementations based on Profile• Use Cases– Integration Testing vs Production Deployment– Embedding RDBMS vs Oracle– Embedding ActiveMQ vs Standalone ActiveMQ
![Page 52: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/52.jpg)
Spring Framework
![Page 53: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/53.jpg)
Data Access
• Transaction Management• JDBC & DAO– DataSource– JDBCTemplate
• ORM Support– Hibernate– Spring Data (JPA)
![Page 54: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/54.jpg)
Integration Framework
• Web Services– RestTemplate– WebServiceTemplate
• Message Queue– JmsTemplate– AmqpTemplate (Requires Amqp Extension)
• JMX
![Page 55: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/55.jpg)
Task Management & Scheduling
• Task Management– Task Executors• ConcurrentTaskExecutor• ThreadPoolTaskExecutor• TimerTaskExecutor
• Scheduling– Quartz Based– Spring 3.0+• @Scheduled, @Async
![Page 56: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/56.jpg)
Dynamic Language Support
• Not Java 6 Scripting Engine (javascript)• JRuby• Groovy• BeanShell• Spring Hadoop (Extension)– PIG– HIVE
![Page 57: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/57.jpg)
Cache Abstraction
• Spring 3.1+• @Cacheable(“cacheName”)• @Cacheable({“cache1”, “cache2”})• @Cacheable(value=“cache1”, key=“#id”)• Spring Expression Language (SpEL)• Cache Storage– ConcurrentMap– Ehcache
![Page 58: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/58.jpg)
Example Codes
• https://github.com/iceycake/intro-spring
![Page 59: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/59.jpg)
References
• http://www.springsource.org/spring-framework
![Page 60: Introduction to Spring Framework](https://reader033.vdocuments.us/reader033/viewer/2022061616/554f5d67b4c905b9508b552b/html5/thumbnails/60.jpg)
Questions