Table of Contents

Dependency - Injector

About

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

Implementation

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:

Framework

Java:

Specification

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

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