Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 1.24 KB

README.md

File metadata and controls

17 lines (11 loc) · 1.24 KB

Java Dependency Injection JSR-330

Java Maven

A small example of how to use dependency injection in Java using the jakarta.inject API and the Weld SE implementation.

Weld SE is an implementation of CDI (Context and Dependency Injection) in Java SE. The CDI specification is based on JSR-330 for dependency injection, which allows injecting dependencies into objects without the need to explicitly create instances in the code.

Components

  • HelloWorldPrinter: Interface that defines the print method to print a Hello World
  • HelloWorldPrinterCapitalize: Implementation of HelloWorldPrinter that prints Hello World in capitalized format.
  • HelloWorldPrinterUppercase: Implementation of HelloWorldPrinter that prints Hello World in uppercase format.
  • HelloWorldClient: Client that injects all implementations of HelloWorldPrinter and calls the print method of each.