SlideShare a Scribd company logo
Накрайников Олег
uchonyy@gmail.com
Spring 4. Part 1
Java. The well-known and not well-known
IoC, AOP
Пролог. А что если скоро наступит
spring?
О чем поговорим сегодня
▪ IoC принцип
▪ Beans life cycle
▪ AOP
▪ Spring proxy
Spring Framework Runtime
Inversion of Control (IoC) –
основные понятия
▪ BeanFactory и ApplicationContext
▪ Bean и BeanDefinition
▪ BeanFactory и FactoryBean
▪ BeanFactoryPostProcessor и BeanPostProcessor
Этапы инициализации контекста
Парсинг
конфигурации и
создание
BeanDefinition
Настройка созданных
BeanDefinition
(BeanFactoryPostProce
ssor )
Создание бинов
(BeanFactory и
FactoryBean)
Настройка
созданных
BeanDefinition
BeanPostProcessor
Жизненный цикл бина
1. Вызов default конструктора
2. Запуск autowiring
3. Вызов
postProcessBeforeInitialization
интерфейса BeanPostProcessor
4. Вызов init-method
5. Вызов
postProcessAfterInitialization
Приложение запущено и готово к работе
8. Вызов destroy()
9. Вызов custom destroy-method
Definition
Pre-initialized
Ready
Destroyed
Области видимости(scopes) бинов
▪ singleton, prototype - Spring IoC
▪ request, session, global session, application -
web-aware ApplicationContext
Слушатели
▪ @PostConstruct и @PreDestroy
▪ BeanPostProcessor.postProcessBeforeInitialization() и
BeanPostProcessor.postProcessAfterInitialization()
▪ @EventListener
(AOP)– сквозная функциональность
public void doing() {
try {
connection.setAutoCommit(false);
// To do
connection.commit();
} catch (SQLException e ) {
connection.rollback();
} catch (Exception e ) {
//
}
}
@Transactional(rollbackFor = SQLException.class)
public void doing() {
// To do
}
Spring AOP
▪ Aspect (аспект)
▪ Advice (cовет): before advice, after returning
advice, after throwing advice, after (finally)
advice, around advice
▪ Join point (точка соединения)
▪ Pointcut (Срез)
▪ Introduction (Внедрение)
Spring Proxy
Использованные источники
▪ http://docs.spring.io/spring/docs/current/spring-framework-
reference/htmlsingle/
▪ http://spring-projects.ru/guides/lessons/lesson-2/
▪ https://habrahabr.ru/post/222579/
▪ https://www.youtube.com/watch?v=U8MtGYa04v8
Спасибо за внимание!

More Related Content

What's hot

Event driven programming amazeballs
Event driven programming amazeballsEvent driven programming amazeballs
Event driven programming amazeballs
MsWillcox
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
M Ahsan Khan
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
Surbhi Panhalkar
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
Wayne Tun Myint
 
Spring ioc
Spring iocSpring ioc
Spring ioc
Lhouceine OUHAMZA
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
Ming-Ying Wu
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
sapdocs. info
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
James Bayer
 
Les nouveautés de Java 21 - Devoxx MA 2023.pdf
Les nouveautés de Java 21 - Devoxx MA 2023.pdfLes nouveautés de Java 21 - Devoxx MA 2023.pdf
Les nouveautés de Java 21 - Devoxx MA 2023.pdf
Jean-Michel Doudoux
 
Ibm cognos10 bi_セルフスタディーキットのご紹介
Ibm cognos10 bi_セルフスタディーキットのご紹介Ibm cognos10 bi_セルフスタディーキットのご紹介
Ibm cognos10 bi_セルフスタディーキットのご紹介
Shinsuke Yamamoto
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Address Spaces Education
Address Spaces EducationAddress Spaces Education
Address Spaces Education
Daniel FitzGerald
 
CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...
CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...
CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...
Extra Technology
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
Kranthi Kumar
 
Control structures
Control structuresControl structures
Control structures
M Vishnuvardhan Reddy
 
Chap5 RE management
Chap5 RE managementChap5 RE management
Chap5 RE management
Ian Sommerville
 
Support programmation orientée aspect mohamed youssfi (aop)
Support programmation orientée aspect mohamed youssfi (aop)Support programmation orientée aspect mohamed youssfi (aop)
Support programmation orientée aspect mohamed youssfi (aop)
ENSET, Université Hassan II Casablanca
 
jdbc document
jdbc documentjdbc document
jdbc document
Yamuna Devi
 

What's hot (20)

Event driven programming amazeballs
Event driven programming amazeballsEvent driven programming amazeballs
Event driven programming amazeballs
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Les applications-web-avec-javafx
Les applications-web-avec-javafxLes applications-web-avec-javafx
Les applications-web-avec-javafx
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 
Spring ioc
Spring iocSpring ioc
Spring ioc
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
 
Les nouveautés de Java 21 - Devoxx MA 2023.pdf
Les nouveautés de Java 21 - Devoxx MA 2023.pdfLes nouveautés de Java 21 - Devoxx MA 2023.pdf
Les nouveautés de Java 21 - Devoxx MA 2023.pdf
 
Ibm cognos10 bi_セルフスタディーキットのご紹介
Ibm cognos10 bi_セルフスタディーキットのご紹介Ibm cognos10 bi_セルフスタディーキットのご紹介
Ibm cognos10 bi_セルフスタディーキットのご紹介
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Address Spaces Education
Address Spaces EducationAddress Spaces Education
Address Spaces Education
 
CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...
CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...
CA 7 r11.3 to r12 DB Conversion Presentation - CA Workload Automation Technol...
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
 
Control structures
Control structuresControl structures
Control structures
 
Chap5 RE management
Chap5 RE managementChap5 RE management
Chap5 RE management
 
Support programmation orientée aspect mohamed youssfi (aop)
Support programmation orientée aspect mohamed youssfi (aop)Support programmation orientée aspect mohamed youssfi (aop)
Support programmation orientée aspect mohamed youssfi (aop)
 
jdbc document
jdbc documentjdbc document
jdbc document
 

Viewers also liked

Java threads - part 1
Java threads - part 1Java threads - part 1
Java threads - part 1
Nakraynikov Oleg
 
Java threads - part 3
Java threads - part 3Java threads - part 3
Java threads - part 3
Nakraynikov Oleg
 
Java threads - part 2
Java threads - part 2Java threads - part 2
Java threads - part 2
Nakraynikov Oleg
 
Java 8. Lambdas
Java 8. LambdasJava 8. Lambdas
Java 8. Lambdas
Nakraynikov Oleg
 
Java persistence api
Java persistence api Java persistence api
Java persistence api
Luis Goldster
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
Jeevesh Pandey
 
20160523 hibernate persistence_framework_and_orm
20160523 hibernate persistence_framework_and_orm20160523 hibernate persistence_framework_and_orm
20160523 hibernate persistence_framework_and_orm
Kenan Sevindik
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
Carol McDonald
 
Spring Boot Update
Spring Boot UpdateSpring Boot Update
Spring Boot Update
Sergi Almar i Graupera
 
Cassandra for mission critical data
Cassandra for mission critical dataCassandra for mission critical data
Cassandra for mission critical data
Oleksandr Semenov
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
Rakesh K. Cherukuri
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
NarayanaMurthy Ganashree
 
Second Level Cache in JPA Explained
Second Level Cache in JPA ExplainedSecond Level Cache in JPA Explained
Second Level Cache in JPA Explained
Patrycja Wegrzynowicz
 
DBM專案環境建置
DBM專案環境建置DBM專案環境建置
DBM專案環境建置
Guo Albert
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2
Sam Brannen
 
JPA - Beyond copy-paste
JPA - Beyond copy-pasteJPA - Beyond copy-paste
JPA - Beyond copy-paste
Jakub Kubrynski
 
Spring Data Jpa
Spring Data JpaSpring Data Jpa
Spring Data Jpa
Ivan Queiroz
 
Spring.Boot up your development
Spring.Boot up your developmentSpring.Boot up your development
Spring.Boot up your development
Strannik_2013
 
Google Web Toolkit: a case study
Google Web Toolkit: a case studyGoogle Web Toolkit: a case study
Google Web Toolkit: a case study
Bryan Basham
 
Spring
SpringSpring

Viewers also liked (20)

Java threads - part 1
Java threads - part 1Java threads - part 1
Java threads - part 1
 
Java threads - part 3
Java threads - part 3Java threads - part 3
Java threads - part 3
 
Java threads - part 2
Java threads - part 2Java threads - part 2
Java threads - part 2
 
Java 8. Lambdas
Java 8. LambdasJava 8. Lambdas
Java 8. Lambdas
 
Java persistence api
Java persistence api Java persistence api
Java persistence api
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
20160523 hibernate persistence_framework_and_orm
20160523 hibernate persistence_framework_and_orm20160523 hibernate persistence_framework_and_orm
20160523 hibernate persistence_framework_and_orm
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
 
Spring Boot Update
Spring Boot UpdateSpring Boot Update
Spring Boot Update
 
Cassandra for mission critical data
Cassandra for mission critical dataCassandra for mission critical data
Cassandra for mission critical data
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
 
Second Level Cache in JPA Explained
Second Level Cache in JPA ExplainedSecond Level Cache in JPA Explained
Second Level Cache in JPA Explained
 
DBM專案環境建置
DBM專案環境建置DBM專案環境建置
DBM專案環境建置
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2
 
JPA - Beyond copy-paste
JPA - Beyond copy-pasteJPA - Beyond copy-paste
JPA - Beyond copy-paste
 
Spring Data Jpa
Spring Data JpaSpring Data Jpa
Spring Data Jpa
 
Spring.Boot up your development
Spring.Boot up your developmentSpring.Boot up your development
Spring.Boot up your development
 
Google Web Toolkit: a case study
Google Web Toolkit: a case studyGoogle Web Toolkit: a case study
Google Web Toolkit: a case study
 
Spring
SpringSpring
Spring
 

Spring 4. Part 1 - IoC, AOP