SPRING REFERENCE CHAPTER 3 THE IOC CONTAINER Index

  • Slides: 50
Download presentation
SPRING REFERENCE CHAPTER 3. THE IOC CONTAINER 백기선

SPRING REFERENCE CHAPTER 3. THE IOC CONTAINER 백기선

Index 1. Introduction 2. Basics – containers and beans 3. Dependencies 4. Bean scopes

Index 1. Introduction 2. Basics – containers and beans 3. Dependencies 4. Bean scopes 5. Customizing the nature of a bean 6. Bean definition inheritance 7. Container extension points 8. The Application. Context 9. Glue code and the evil singleton

1. Introduction

1. Introduction

Io. C Inversion of Control http: //younghoe. info/128 Io. C Container Bean. Factory Application.

Io. C Inversion of Control http: //younghoe. info/128 Io. C Container Bean. Factory Application. Context http: //whiteship. tistory. com/518

2. Basics – containers and beans

2. Basics – containers and beans

Containers Container Bean. Factory Application. Context Configuration Metadata XML Java. Config

Containers Container Bean. Factory Application. Context Configuration Metadata XML Java. Config

예제 1(simple configuration) XML based Configuration metadata Using Container Application. Context context = new

예제 1(simple configuration) XML based Configuration metadata Using Container Application. Context context = new Class. Path. Xml. Application. Context(new String []{"bean. Configuration. xml"}); Member member = (Member)context. get. Bean(“member”);

Beans Naming beans id, name, alias Bean. Definition Name Aliasing 주의할 것 빈(bean)의 이름

Beans Naming beans id, name, alias Bean. Definition Name Aliasing 주의할 것 빈(bean)의 이름 지정 Spring의 naming/aliasing 정책에 대한 수사 (상) Spring의 naming/aliasing 정책에 대한 수사 (중) Spring의 naming/aliasing 정책에 대한 수사 (하) Aliasing Beans (4) 복잡한 Alias

Instantiation Bean 생성자 <bean id="혜인" name="이쁘니" class="bean. Configuration. Member"/> get. Bean(“혜인”); 팩토리 Static Instant

Instantiation Bean 생성자 <bean id="혜인" name="이쁘니" class="bean. Configuration. Member"/> get. Bean(“혜인”); 팩토리 Static Instant <bean id="pizza" class="keesun. Pizza. Store" factory-method="create. Pizza"/> <bean id="pizza. Store" class="keesun. pizza. Strore" /> <bean id="pizza" factory-bean="pizza. Store" factory-method="create. Pizza" /> get. Bean(“pizza”); Factory. Bean

예제 2(wrong aliasing)

예제 2(wrong aliasing)

3. Dependencies

3. Dependencies

Injection Constructor-Injection Setter-Injection Method-Injection

Injection Constructor-Injection Setter-Injection Method-Injection

예제 4(constructor-arg 구별)

예제 4(constructor-arg 구별)

<property /> <constructor-arg /> 종속성을 가지는 대상에 따라 사용할 수 있는 하위 태그들이 여러개

<property /> <constructor-arg /> 종속성을 가지는 대상에 따라 사용할 수 있는 하위 태그들이 여러개 있습니다. <value /> <idref /> <bean /> <list /> <set /> <map /> <props /> <null /> idref 엘리먼트 Inner beans Collections - <list /> Collection Merging

<bean /> depend-on=“빈 이름들” lazy-init="true“ autowire=“no | by. Name | by. Type | constructor

<bean /> depend-on=“빈 이름들” lazy-init="true“ autowire=“no | by. Name | by. Type | constructor | autodetect” dependency-check=“none | simple | object | all ”

예제 5(auto-wring)

예제 5(auto-wring)

4. Bean scopes

4. Bean scopes

scopes

scopes

singleton

singleton

prototype

prototype

예제 6(singleton)

예제 6(singleton)

예제 7(prototype)

예제 7(prototype)

5. Customizing the nature of a bean

5. Customizing the nature of a bean

Initializing. Bean & Disposable. Bean

Initializing. Bean & Disposable. Bean

init-method & destroy-method

init-method & destroy-method

예제 8(customizing)

예제 8(customizing)

Knowing who you are Bean. Factory. Aware 인터페이스 구현하기 Bean. Factory. Aware 사용 예

Knowing who you are Bean. Factory. Aware 인터페이스 구현하기 Bean. Factory. Aware 사용 예 Object. Factory. Creating. Factory. Bean 사용하기 Object. Factory. Creating. Factory. Bean 사용 예

예제 9(ticket)

예제 9(ticket)

6. Bean definition inheritance

6. Bean definition inheritance

7. Container extension points

7. Container extension points

Bean. Post. Processors Bean. Post. Processor 사용 예

Bean. Post. Processors Bean. Post. Processor 사용 예

Bean. Factory. Post. Processors Bean. Post. Processor와 비슷하지만 적용되는 대 상이 Configuration Metadata 입니다.

Bean. Factory. Post. Processors Bean. Post. Processor와 비슷하지만 적용되는 대 상이 Configuration Metadata 입니다. bean을 만들고 DI하기 전에 설정 내용을 변경 할 수 있습니다. Bean. Factory. Post. Processor 사용 예

Factory. Bean Io. C Container Factory. Bean

Factory. Bean Io. C Container Factory. Bean

Factory. Bean get. Bean(“car”); Application. Context get. Object(); Car. Factory. Bean named by “car”

Factory. Bean get. Bean(“car”); Application. Context get. Object(); Car. Factory. Bean named by “car”

8. The Application. Context

8. The Application. Context

예제 11(Message. Source)

예제 11(Message. Source)

마지막 예제 – Event Listener

마지막 예제 – Event Listener

마지막 예제 – Event Publisher

마지막 예제 – Event Publisher

마지막 예제 – Configuration & Run

마지막 예제 – Configuration & Run