글
6월, 2013의 게시물 표시
Dependency injection
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
5.4.1. Dependency injection Dependency injection (DI) is a process whereby objects define their dependencies, that is, the other object instance with, only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. DI exists in two major variants, Constructor-based dependency injection public class SimpleMovieListener { // the simpleMovieListener has a dependency on a MovieFinder private MovieFinder movieFinder; // a constructor so that the Spring container can 'inject' a MovieFinder public SimpleMovieListner(MovieFinder movieFinder) { this .movieFinder = movieFinder; // business logic that actually 'uses' the injected MovieFinder is omitted... } Setter-based dependency injection public class SimpleMovieListener { // the simpleMo...