Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151
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 demo9/8/20152
Spring Framework Spring Overview, Application demo9/8/20153
Spring Framework Spring Framework Spring Framework Spring Framework 3.0 July 2009 Spring Framework RELEASE is the current production release (requires Java 1.5+) Roadmap –Spring Releases Spring Overview, Application demo9/8/20154
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 Features Spring Overview, Application demo9/8/20155
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 additions Declarative model validation Early support for Java EE 6 Embedded database support New features of Spring 3.X Spring Overview, Application demo9/8/20156
BeanFactory is core to the Spring framework Responsible for lifecycle methods. It is typically configured in an XML file with the root element: XML based component deployment contains one or more 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) <bean id=“widgetService” class=“com.zabada.base.WidgetService”> The bean’s fully- qualified classname Maps to a setPoolSize() call The bean’s ID Spring BeanFactory Spring Overview, Application demo9/8/20157
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 calls setWidgetDAO(myWidgetDAO) where myWidgetDAO is another bean defined in the configuration Spring Overview, Application demo9/8/20158
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 demo9/8/20159
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 demo9/8/201510
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 9/8/ Spring Overview, Application demo
Dependency Injection Pattern cont.. There are 3 types of dependency injection Method injection Constructor injection Interface injection Spring Overview, Application demo9/8/201512
Application High level Architecture Spring Overview, Application demo9/8/201513
Discussion, Q & A Spring Overview, Application demo9/8/201514