Spring Overview, Application demo

emptyslowInternet και Εφαρμογές Web

12 Νοε 2013 (πριν από 4 χρόνια)

109 εμφανίσεις

Spring

Overview,

Application

demo

-
Midhila Paineni

09/23/2011

Spring Overview, Application demo

11/12/2013

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 demo

11/12/2013

2

Spring Framework

Spring Overview, Application demo

11/12/2013

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 demo

11/12/2013

4


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 demo

11/12/2013

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 demo

11/12/2013

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 demo

11/12/2013

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 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

11/12/2013

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 demo

11/12/2013

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 demo

11/12/2013

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


11/12/2013

11

Spring

Overview, Application demo

Dependency Injection Pattern cont..

There are 3 types of dependency injection



Method injection



Constructor injection



Interface injection

Spring Overview, Application demo

11/12/2013

12

Application High level Architecture

Spring Overview, Application demo

11/12/2013

13




Discussion, Q & A

Spring Overview, Application demo

11/12/2013

14