Spring core v3 x
This presentation is the property of its rightful owner.
Sponsored Links
1 / 20

Spring core v3.x PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Spring core v3.x. Prepared by: Nhan Le. History. Agenda. IoC vs DI IOC Container Validation, Data Binding & Type conversion Spring Expression Language Testing Spring AOP Cache Abstraction. IoC vs DI.

Download Presentation

Spring core v3.x

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Spring core v3 x

Spring core v3.x

Prepared by: Nhan Le





IoCvs DI

IOC Container

Validation, Data Binding & Type conversion

Spring Expression Language


Spring AOP

Cache Abstraction

Ioc vs di

IoCvs DI

Inversion of control is a design principle that it decouplesobjects from specific lookup mechanisms and implementations of the objects it depends on

Dependency injection is a form of IoC, where removes hard-coded dependencies and make it possible to change them at Compile time or Run Time

Advantages of ioc

Advantages of IoC

Reduce coupling

Both constructor and setter dependency injection reduce coupling.

Improves testability

Replace actual object with mock object which improves testability by writing simple JUnit tests which uses mock object.


As side benefit of loose coupling, because of DI you can replace non effective implementation with better one later



  • Dependency Injection

    • Constructor based

    • Setter based

    • Interface Injection

  • Dependency resolution process

  • Circular dependencies



type matching

argument index

argument name

Ioc container

IOC Container

The interface org.springframework.context.ApplicationContext represents the Spring IOC container and is responsible for instantiating, configuring, and assembling the beans by reading configuration metadata

Configuration Metadata

- XML based

- Annotation based

- Java based

Ioc bean lifecycle

IOC – Bean Lifecycle

Ioc bean

<bean id="exampleBean" class="examples.ExampleBean"/>

<bean id="exampleBean" class="examples.ExampleBean"/>

IOC – Bean

<bean id="exampleBean" class="examples.ExampleBean"/>

  • Naming beans

    • Id, name and alias

  • Instantiating beans

    • Constructor

    • Static factory

    • Method factory

  • Inner beans

    • Inject able?

    • Scope?

Instantiating beans

Instantiating Beans


Static Factory method

Instance Factory method

Inner beans

Inner Beans

<bean id="exampleBean" class="examples.ExampleBean"/>

  • Can we inject Person class into others than outer class ?

  • Scope of Person class ? Can we change scope ?

Ioc bean1

IOC – Bean

  • Lifecycle callbacks

    • @PostConstruct& @PreDestroy

    • InitializingBean & DisposableBean

    • Default initialization and destroy methods

  • Callback order

Ioc bean2

IOC – Bean

Aware interfaces




@Inject private UserDAOuserDao;


public booleanauth(String user, String pass){

String encryptedPass = encrypt(pass);

User user = userDao.find(user, encryptedPass);

if (user != null){

return true;


return false;


Spring expression language

Spring Expression Language

● Querying and manipulating an object graph at runtime

● Can be used independently

● Support implementation via

  • API

  • XML

  • Annotation

Spring core v3 x


● Aspect-Oriented Programming

● Spring AOP

● Schema-based VS @AspectJ annotation type

Spring core v3 x



● Aspect

● Join Point

● Advice

● Pointcut

● Introduction

● Target object

● AOP proxy

● Weaving

Spring core v3 x


Type of advice

  • Before advice

  • After returning advice

  • After throwing advice

  • After (finally) advice

  • Around advice

Spring core v3 x


  • Pointcut types (Spring AOP)

    • [email protected]

    • [email protected]

    • [email protected]

    • [email protected]

  • Login