140 likes | 267 Views
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
E N D
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo
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 • Dependency Injection(Inversion Of Control) • Application High Level Architecture Diagram • Demo of RefAppApplication • Questions and Answers Spring Overview, Application demo
Spring Framework Spring Overview, Application demo
Roadmap –Spring Releases • 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+) Spring Overview, Application demo
Spring Features • IOC and Dependency Injection • Annotations • Spring Core and Beans (POJOs) • AOP Support • Declarative Transaction • JDBC Template • O/R Integration • Exception Handling • MVC Framework • Spring Web Services • Spring Security • Expression Language • Comprehensive REST Spring Overview, Application demo
New features of Spring 3.X 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 Spring Overview, Application demo
Spring BeanFactory • 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) The bean’s fully- qualified classname The bean’s ID <beans> <bean id=“widgetService” class=“com.zabada.base.WidgetService”> <property name=“poolSize”> <!—-property value here--> </property> </bean> </beans> Maps to a setPoolSize() call Spring Overview, Application demo
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 concept of 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 demo
"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 Dependency Injection(Inversion Of Control) IoC / Dependency Injection Spring Overview, Application demo
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 demo
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 SpringOverview, Application demo 11 10/12/2014
Dependency Injection Pattern cont.. • There are 3 types of dependency injection • Method injection • Constructor injection • Interface injection Spring Overview, Application demo
Application High level Architecture Spring Overview, Application demo
Discussion, Q & A Spring Overview, Application demo