14
Introduction to Spring By Vinay Prajapati

Spring core

Embed Size (px)

Citation preview

Introduction to Spring

By Vinay Prajapati

We’ll Cover

Evolution of Spring.Why Spring?Application Contexts.Survey of Spring Landscape.Getting Started

Evolution of Spring

First release of JavaBeans Spec in Dec, 1996.

Enterprise Java Beans Spec in March, 1998.

Dependency Injection and AOP

Simplification of java development in demand.

Spring meets the demands.

Why Spring?

Spring Simplifies Java Development.

Lightweight and minimally invasive development with POJOs.

Loose coupling using DI and Interface Orientation.

Declarative programming using Aspects and common convention.

Boilerplate reduction using Aspects and templates.

Application Contexts

ClassPathXmlApplicationContext: treats context definition files as classpath resources.

FileSystemXmlApplicationContext: looks for file in filesystem.

XmlWebApplicationContext: Loads context definition from an xml file within a web application.

- Survey of Spring Landscape -

“Spring simplifies java development.”

Fig.:The Spring Framework modules

Fig.: different modules in spring

A Bean’s Life

Spring instantiates the bean.

Spring injects bean refs and values into the bean’s properties.

Call to aware implementations. e.g. If BeanNameAware is implemented, Spring passes the bean’s ID to the setBeanName method.

BeanPostProcessor if implemented Spring calls postProcessBeforeInitialization.

InitializingBean interface if implemented, Spring call afterPropertiesSet method.

BeanPostProcessor if implemented Spring calls postProcessAfterInitialization.

Bean is ready here and getting used in the application iteratively.

DisposableBean if implemented, Spring calls destroy method of bean.

Getting Started

Prefer learning core spring and then associated plugins like spring security, web, transaction etc.

Spring is not constrained to a web application.

Creating a project with Intelli J idea.

Learn by scenarios together with other methodologies.

Examples

With different application contexts.

With different scopes.Prototype and singleton

With init and destroy methods(global and local).

Important Links

http://www.springsource.org/spring-integration.

http://www.tutorialspoint.com/spring/

http://www.javatpoint.com/spring-tutorial

http://www.springframework.net.

https://spring.io/docs

http://www.mkyong.com/tutorials/spring-tutorials/

http://static.springsource.com/projects/documentation/index.html

Thanks!! To be Continued…