2. INTRODUCTION TO SPRING
A Container:
Creates objects and makes them available to your
application
A Framework:
Provides an infrastructure of classes that make it easier to
accomplish tasks
Gowdanar Technologies Pvt Ltd
3. SPRING FRAMEWORK
first version was written by Rod Johnson October 2002
The framework was first released under the Apache 2.0 license in
June 2003
Official 1.0 release in 2004
Spring 3.1 in December 2011
Gowdanar Technologies Pvt Ltd
4. What does Spring provide?
Lightweight container and framework
Layered Architecture
Well designed
Easy to extend
Many reusable classes
Easily integrated with our existing frameworks
It reduces the complexity of many enterprise application
development
Gowdanar Technologies Pvt Ltd
5. What does Spring provide?
It is a layered architecture
It supports Hibernate , Ajax , Struts.
It supports Pojo class.
IOC, dependency injection, loose coupling
Gowdanar Technologies Pvt Ltd
8. MultiActionController
Controller implementation that allows multiple request types to be handled by the
same class
Generally we have mapping in xml file for dispatcher servlet to decide which
controller to use as per URL mapping but if we have to take decision on basis of
request parameters then MultiActionController can be used.
Spring offers a multi-action controller with which multiple actions can be
aggregated into one controller, grouping functionality together.
The multi-action controller is capable of mapping requests to method names and
then invoking the right method name.
Using the multi-action controller is especially handy when you have a lot of
common functionality in one controller, but want to have multiple entry points to
the controller.
Gowdanar Technologies Pvt Ltd
In this introduction to Spring, I’m going to cover these topics. Spring provides much more then just what’s shown here, these are just some of the basic capabilities Spring provides.Spring is a lightweight framework. Most of your Java classes will have nothing about Spring in their source code. This means that you can easily transition your application from the Spring framework to something else. It also means that transferring an existing application to use the Spring framework doesn’t have to mean a complete code rewrite.All Java applications that consist of multiple classes have inter-dependencies or coupling between classes. Spring helps us develop applications that minimize the negative effects of coupling and encourages the use of interfaces in application development. Using interfaces in our applications to specify type helps make our applications easier to maintain and enhance later.The Spring framework helps developers clearly separate responsibilities. Many Java applications suffer from class bloat – that is a class that has too many responsibilities. For example a service class that is also logging information about what its doing. Think of two situations – one is you’ve been told by your supervisor to do your normal work but also to write down everything you do and how long it takes you. You’d be even busier and less responsive. A better situation would be you do your normal work, but another person observers what you’re doing and records it and measures how long it took. Even better would be if you were totally unaware of that other person and that other person was able to also observe and record other people’s work and time. That’s separation of responsibilities.Lastly, I’ll introduce how Spring can greatly simplify database integration. Manipulating information stored in a database is cumbersome using just the JDBC API. Spring adds a suite of features that make database integration much simpler and less error prone.
his diagram is from the Spring Documentation - http://static.springframework.org/spring/docs/2.5.x/reference/introduction.htmlIt shows the different modules that Spring provides. You can pick which modules you want to use without have to configure or import the other modules. For example you could still use Struts 2 for the web part, but use the Spring core, AOP, and DAO for the data and business tiers of your application.The Core package is the most fundamental part of the framework and provides the IoC and Dependency Injection features. The basic concept here is the BeanFactory, which provides a sophisticated implementation of the factory pattern which removes the need for programmatic singletons and allows you to decouple the configuration and specification of dependencies from your actual program logic.The Context package build on the solid base provided by the Core package: it provides a way to access objects in a framework-style manner in a fashion somewhat reminiscent of a JNDI-registry. The context package inherits its features from the beans package and adds support for internationalization (I18N) (using for example resource bundles), event-propagation, resource-loading, and the transparent creation of contexts by, for example, a servlet container.The DAO package provides a JDBC-abstraction layer that removes the need to do tedious JDBC coding and parsing of database-vendor specific error codes. Also, the JDBC package provides a way to do programmatic as well as declarative transaction management, not only for classes implementing special interfaces, but for all your POJOs (plain old Java objects).The ORM package provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis. Using the ORM package you can use all those O/R-mappers in combination with all the other features Spring offers, such as the simple declarative transaction management feature mentioned previously.Spring's AOP package provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define, for example, method-interceptors and pointcuts to cleanly decouple code implementing functionality that should logically speaking be separated. Using source-level metadata functionality you can also incorporate all kinds of behavioral information into your code, in a manner similar to that of .NET attributes.Spring's Web package provides basic web-oriented integration features, such as multipart file-upload functionality, the initialization of the IoC container using servlet listeners and a web-oriented application context. When using Spring together with WebWork or Struts, this is the package to integrate with.Spring's MVC package provides a Model-View-Controller (MVC) implementation for web-applications. Spring's MVC framework is not just any old implementation; it provides a clean separation between domain model code and web forms, and allows you to use all the other features of the Spring Framework.