6월, 2013의 게시물 표시

[몬스타] 키스 2초전! 내가 남자로 안보여?!@6화

Dependency injection

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 simpleMovieListener has a dependency on the MovieFinder      private  Movie