spring - Ioc Container: Dependency Injection, Dependency Lookup? -
i trying understand spring framework more know currently, , referring "pro spring 3" book.
i came across following section in book below:
it says in general ioc
can decomposed 2 components viz: dependency injection
, dependency lookup
.
with respect this, have following questions:
1) spring provide both dependency injection
,dependency lookup
?
2) ioc
container have both these systems viz: dependency injection
,dependency lookup
?
3) if spring provides both dependency injection
,dependency lookup
, isn't wrong spring di framework, when has both these capabilities?
1: yes, spring provides both dependency injection , dependency lookup. can let spring inject dependencies using example @autowired
annotation, , can manually lookup components spring's applicationcontext
calling 1 of getbean
methods.
the main thing understand concept "inversion of control" (ioc) spring work you, instead of other way around: let spring create instances of components, , let spring inject dependencies, instead of other way around, write code create instances , lookup dependencies.
2: no, not necessarily.
3: spring can dependency injection (di), di framework. because other things (such allow lookup components explicitly) doesn't not make di framework anymore.
Comments
Post a Comment