Dependency - Injector


The container injects dependencies when it creates the bean.

The injector's job is to assemble graphs of objects. You request an instance of a given type, and it figures out what to build, resolves dependencies, and wires everything together. To specify how dependencies are resolved, configure your injector.

Building object graphs by hand is labour intensive, error prone, and makes testing difficult. Instead, a container or dependency injector can build the object graph for you.

The dependency injector builds the object graph


Usually a dependency injector manages the lifecycle of objects and their dependencies based on a configuration file or annotations.

It can also allows to resolve dependencies at run time for extensibility using containers such as

Dependency injection involves four elements:

  • the implementation of a service object;
  • the client object depending on the service;
  • the interface the client uses to communicate with the service;
  • and the injector object, which is responsible for injecting the service into the client. The injector object may also be referred to as an assembler, provider, container, factory, or spring




JSR-330 (javax.inject) - Dependency Injection for Java

JSR-330 standardizes annotations like @Inject and the Provider interfaces for Java platforms.

Powered by ComboStrap