spring overview, application demo
DESCRIPTION
Spring Overview, Application demo. -Midhila Paineni 09/23/2011. The goal of this session is to provide the Overview of the Spring framework and Demo the application built in Spring 3.X. Key Topics To Be Covered. Spring Framework Roadmap Spring Features New Features in Spring 3.X - PowerPoint PPT PresentationTRANSCRIPT
Spring Overview, Application demo
-Midhila Paineni09/23/2011
Spring Overview, Application demo04/20/23 1
The goal of this session is to provide the Overview of the Spring framework and Demo the application built in Spring 3.X
Spring Framework
Roadmap
Spring Features
New Features in Spring 3.X
Dependency Injection(Inversion Of Control)
Application High Level Architecture Diagram
Demo of RefApp Application
Questions and Answers
Key Topics To Be Covered
Spring Overview, Application demo04/20/23 2
Spring Framework
Spring Overview, Application demo04/20/23 3
• Spring Framework 1.0 24.03.04• Spring Framework 2.0 05.10.05• Spring Framework 2.5 19.11.07• Spring Framework 3.0 July 2009• Spring Framework 3.0.6. RELEASE is the current production
release (requires Java 1.5+)
Roadmap –Spring Releases
Spring Overview, Application demo04/20/23 4
Spring Features
Spring Overview, Application demo04/20/23 5
This is a list of new features for Spring 3.X. We will discuss later more details of each feature.• Spring Expression Language• IoC enhancements• General-purpose type conversion system and field formatting system• Object to XML mapping functionality (OXM) moved from Spring Web Services project• Comprehensive REST support• @MVC additions• Declarative model validation• Early support for Java EE 6• Embedded database support
New features of Spring 3.X
Spring Overview, Application demo04/20/23 6
• BeanFactory is core to the Spring framework• Responsible for lifecycle methods.• It is typically configured in an XML file with the root element: <beans>• XML based component deployment contains one or more <bean> elements
id (or name) attribute to identify the bean class attribute to specify the fully qualified class
• Create object graphs and configure data• Inversion of Control (Dependency Injection)
<beans> <bean id=“widgetService” class=“com.zabada.base.WidgetService”> <property name=“poolSize”> <!—-property value here--> </property> </bean></beans>
The bean’s fully-qualified classname
Maps to a setPoolSize() call
The bean’s ID
Spring BeanFactory
Spring Overview, Application demo04/20/23 7
Property Values for BeanFactories (continued)
The real magic comes in when you can set a property on a bean that refers to another bean in the configuration:
This is the basic conceptof Inversion of Control
<bean name=“widgetService” class=“com.zabada.base.WidgetServiceImpl”> <property name=“widgetDAO”> <ref bean=“myWidgetDAO”/> </property></bean>
calls setWidgetDAO(myWidgetDAO)where myWidgetDAO is another bean defined in the configuration
Spring Overview, Application demo04/20/23 8
Dependency Injection(Inversion Of Control)
• "Inversion of Control"
• configuration and lifecycle of application objects
• objects do not configure themselves, but get configured from the outside
• objects don't know the origin of their configuration• Eliminates lookup code from within your application• Allows for plugability and hot swapping• Promotes good OO design• Enables reuse of existing code• Makes your application extremely testable
IoC / Dependency Injection
Spring Overview, Application demo04/20/23 9
Dependency Injection Pattern
class MovieLister... public Movie[] moviesDirectedBy(String arg) { List allMovies = finder.findAll(); for (Iterator it = allMovies.iterator(); it.hasNext();) { Movie movie = (Movie) it.next(); if (!movie.getDirector().equals(arg)) it.remove(); } return (Movie[]) allMovies.toArray(new Movie[allMovies.size()]); }
public interface MovieFinder {
List findAll();
}
Spring Overview, Application demo04/20/23 10
Dependency Injection Pattern cont..
class MovieLister...
private MovieFinder finder;
public MovieLister() {
finder = new ColonDelimitedMovieFinder("movies1.txt");
}
The dependencies using a simple creation in the lister class
04/20/23 11Spring Overview, Application demo
Dependency Injection Pattern cont..
There are 3 types of dependency injection
• Method injection
• Constructor injection
• Interface injection
Spring Overview, Application demo04/20/23 12
Application High level Architecture
Spring Overview, Application demo04/20/23 13
• Discussion, Q & A
Spring Overview, Application demo04/20/23 14