https://github.com/dgf/dimpl
simple Java class context and factory for dependency injection of implementations
https://github.com/dgf/dimpl
aplatanao dependency injection java
Last synced: 6 months ago
JSON representation
simple Java class context and factory for dependency injection of implementations
- Host: GitHub
- URL: https://github.com/dgf/dimpl
- Owner: dgf
- License: bsd-3-clause
- Created: 2018-09-07T10:20:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-07T11:22:20.000Z (almost 8 years ago)
- Last Synced: 2025-01-23T06:11:29.541Z (over 1 year ago)
- Topics: aplatanao, dependency, injection, java
- Language: Java
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dimpl - simple Java class context and factory
This [DI](https://en.wikipedia.org/wiki/Dependency_injection) approach is only useful for dependency injection of concrete implementations.
There are no plans to support interfaces or annotations at all.
# Example usage
a simple component
```java
public class Component {
public String toString() {
return "dependency";
}
}
```
the example the needs a component injection
```java
public class Example {
private Component component;
public Example(Component component) {
this.component = component;
}
public String toString() {
return "example " + component;
}
}
```
build context and retrieve the example dependency
```java
import org.aplatanao.dimpl.Context;
public class Main {
public static void main(String[] args) {
Example example = new Context().get(Example.class);
System.out.println(example); // outputs: "example dependency"
}
}
```