Spring Framework - An Introduction TABLE OF CONTENTS 1
Objective..................................................................................................3
2
Introduction..............................................................................................4
3
Spring Framework.....................................................................................5 3.1
4
Spring Architecture Modules.................................................................6
References................................................................................................7
OBJECTIVE 1. This document is briefly introduces various features of Spring Framework. 2. It provides references to Spring Framework resources.
1
INTRODUCTION Spring is an open source project since February 2003, a relative modern framework. However, in a short time-span, it has created quite enthusiasm in the Java community. Spring's main aim is to make J2EE easier to use and promote good programming practice. It does this by adopting three design ideologies: 1. POJO-based programming model. 2. Inversion of Control (a.k.a. Dependency Injection) design pattern. 3. Aspect Oriented Programming (AOP). In addition, wherever possible, it leverages existing solutions. Examples of such leverage include Struts for the Web Tier and Hibernate/iBatis for the Data Tier. Spring has been one of the first frameworks to offer a Business Tier solution.
SPRING FRAMEWORK Spring is Java based open source framework • Developed by Rod Johnson and Team
•
Based on book Expert One-on-One J2EE Design and Development by Rod Johnson
Spring addresses the complexity of enterprise application development • Use plain vanilla java beans • Focus on simplicity, testability and loose coupling Lightweight framework • Single jar file • No processing overhead • Non intrusive – application code and spring code are independent IoC based framework • Object dependencies are passively injected using inversion of control. AOP based framework • Provides rich AOP support • Separates business logic from system services like logging and transactions. Spring Container • Spring creates and manages the life cycle and configurations of application objects • Objects are composed declaratively in XML files. Spring is a great framework for reducing the lines of code (LOC) in the application development. It promotes good programming practices. Make existing technologies easier to use. Foster interface based programming. Leverage benefits of Object Oriented Technology. Promote integration with existing solutions (like Log4j, Hibernate, JDO, Struts, iBatis etc) rather than competing with them or reinventing the wheel. Spring is easy to use Spring is based on DRY (Don’t Repeat Yourself) principle. 1.1
Spring Architecture Modules
1. 2. 3. 4. 5. 6. 7.
Spring Spring Spring Spring Spring Spring Spring
Core Context DAO/JCBC AOP ORM Web Web MVC
Spring Core: •
Fundamental part of Spring
•
Provides Dependency Injection
•
Based on factory pattern
•
Provides loose coupling between objects
Spring Context: •
Layer above the Spring Core
•
Provides support for resource bundles, event-propagation, resourceloading and transparent creation of contexts
Spring DAO: •
Provides a JDBC-abstraction layer
•
Supports programmatic as well as declarative transaction management
Spring ORM: •
Provides seamless integration with popular O/R mappers like Hiberante, Toplink, JDO
•
Integrates with iBatis
Spring AOP:
•
Spring's AOP component provides an Aop Alliance compliant aspectoriented programming
•
Supports source-level metadata, a little like .NET attributes
Spring Web:
•
Spring's Web component provides the basic web-oriented integration features
•
Integrates with Struts and Webwork
Spring Web MVC: • Spring Web MVC component provides implementation for web-applications
a
Model-View-Controller
REFERENCES
1. Spring Home 2. Spring Documentation: http://www.springframework.org/documentation 3. IOC and DI – 4. 5. 6. 7.
Explained:http://timothyfisher.javadevelopersjournal.com/read/1232766.htm Spring in Nut shell http://www.theserverside.com/articles/article.tss?l=SpringFramework Technical Articles on Spring: http://www.springframework.org/articles Presentation on Spring: http://www.springframework.org/presentations JPetClinic: Demo Application bundled with Spring Installation