Spring and IoC

Outline

Inversion of Control (IoC, Inversion of Control), is a concept, an idea. Traditionally refers to the program code directly manipulate objects invoked the right to container, to achieve assemble and manage objects through the container. Inversion of control is transferred to the object of control from the program code itself reversed to the outside of the container.

IoC is a concept, an idea, which is to achieve a variety of ways. There are two current popular ways: dependency injection and dependent lookup. Dependency injection applied more widely.

  • Dependent lookup: Dependency Lookup, DL, and the container provides the context to the callback interface components, program code is required to provide a specific way to find. The typical system is dependent on JNDI lookup.
  • Dependency injection **: ** Dependency Injection, DI, not program code location query, the work done by the containers themselves.

DI DI refers to the program is running, if the call requires the assistance of another object, without having to create the caller in the code, but rather on the outer container, is passed to the program created by the outer container.

Spring's dependency injection caller almost no requirements and callee, fully supports the management of dependencies between POJO.

Dependency injection is the best way of decoupling. Dependency injection allows a way profiles are grouped together, coupled together rather than hard-coded way between the Spring Bean.

Guess you like

Origin www.cnblogs.com/snake107/p/11914964.html