Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dafexdev/java-dpi-jsr330
A small example of how to use dependency injection in Java using the jakarta.inject API and the Weld SE implementation.
https://github.com/dafexdev/java-dpi-jsr330
dependency-injection design-patterns jakartaee java jsr330 maven weld-se
Last synced: 16 days ago
JSON representation
A small example of how to use dependency injection in Java using the jakarta.inject API and the Weld SE implementation.
- Host: GitHub
- URL: https://github.com/dafexdev/java-dpi-jsr330
- Owner: dafexDev
- Created: 2024-07-23T22:08:57.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-24T01:38:43.000Z (5 months ago)
- Last Synced: 2024-11-19T12:59:36.477Z (about 1 month ago)
- Topics: dependency-injection, design-patterns, jakartaee, java, jsr330, maven, weld-se
- Language: Java
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java Dependency Injection JSR-330
[![Java](https://img.shields.io/badge/Java-ED8B00?style=for-the-badge&logo=openjdk&logoColor=white)](https://www.java.com/es/)
[![Maven](https://img.shields.io/badge/Apache_Maven-C71A36?style=for-the-badge&logo=apachemaven&logoColor=white)](https://maven.apache.org/)A small example of how to use dependency injection in Java using the `jakarta.inject` API and the [**Weld SE**](https://weld.cdi-spec.org/) implementation.
[**Weld SE**](https://weld.cdi-spec.org/) 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
![](./assets/java-dpi-jsr330.png)
- **`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.