This is first session about high-level overview of Spring 4 framework
Size: 192.9 KB
Language: en
Added: Jan 20, 2016
Slides: 11 pages
Slide Content
Spring
in
Practice
Version 4.0
[ Overview | Design | Architecture | DI & IoC ]
By: SAURABH SHARMA | TechShareZone Community
Source: http://javazone.techsharezone.com | +91 810 591 1711
Session: 1
Created by Rod Jhonson
An open source framework
Spring is an light weight Dependency Injection and Aspect
Oriented Container and framework.
- Spring Overview
- Spring framework architecture
- Deprecated Methods and Packages
- Java 8 Support
- Groovy Bean Definition DSL
- Spring Core Changes
- Spring Web Module Features
Currently Spring 4.2 is the latest version and they have
enhanced event listener, hibernate, jetty and modern Java
component design with spring framework.
- Spring 4.0 Release and Features
Dependency Injection
Also known as IoC (Inversion of Control)
Aspect Oriented Programming
Runtime injection-based
Portable Service Abstractions
The rest of spring
ORM, DAO, Web MVC, Web, etc.
Allows access to these without knowing how they actually
work
- What does Spring offer?
Dependency Injection (DI) is a design pattern that removes the dependency
from the programming code so that it can be easy to manage and test the
application.
Constructor-based dependency injection
Constructor-based DI is accomplished when the container invokes a class constructor
with a number of arguments, each representing a dependency on other class.
Setter-based dependency injection
Setter-based DI is accomplished by the container calling setter methods on your
beans after invoking a no-argument constructor or no-argument static factory
method to instantiate your bean.
- Dependency Injection in Spring
- IoC is all about Object dependencies.
- Traditional "Pull" approach:
- Direct instantiation
- Looking up a service via JNDI
"Push" approach:
- Something outside of the Object "pushes" its
dependencies into it.
The Object has no knowledge of how it gets its dependencies, it
just assumes they are there.
- The "Push" approach is called "Dependency Injection".
- What is Inversion of Control (IoC)?
Typical java bean with a unique id
Beans are normally created by Spring as late as possible
- What is a bean?
Scope Description
Singleton Single instance spring IoC
Prototype Single bean definition to have any number of object instance
Request A bean definition to an HTTP request. Only valid in the context of a web
aware spring applicationContext.
Session A bean definition to an HTTP session. Only valid in the context of a web
aware spring applicationContext.
Global-sessionA bean definition to an global HTTP session. Only valid in the context of a
web aware spring applicationContext.
Defines a bean for Spring to manage
Key attributes
class (required): fully qualified java class name
id: the unique identifier for this bean
configuration: (singleton, init-method, etc.)
constructor-arg: arguments to pass to the constructor at creation
time
property: arguments to pass to the bean setters at creation time
Collaborators: other beans needed in this bean (a.k.a
dependencies), specified in property or constructor-arg
Typically defined in an XML file
- What is a bean definition?