https://github.com/quantummaid/injectmaid
Lightweight dependency injection framework that does not rely on annotations.
https://github.com/quantummaid/injectmaid
Last synced: 3 months ago
JSON representation
Lightweight dependency injection framework that does not rely on annotations.
- Host: GitHub
- URL: https://github.com/quantummaid/injectmaid
- Owner: quantummaid
- License: apache-2.0
- Created: 2020-05-26T15:40:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-02T20:31:21.000Z (over 2 years ago)
- Last Synced: 2025-08-14T14:57:00.433Z (10 months ago)
- Language: Java
- Homepage: https://quantummaid.de
- Size: 480 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://sonarcloud.io/dashboard?id=de.quantummaid.injectmaid%3Ainjectmaid-parent)
[](https://github.com/quantummaid/injectmaid)
[](https://maven-badges.herokuapp.com/maven-central/de.quantummaid.injectmaid/injectmaid)
[](https://github.com/quantummaid/injectmaid)
[](https://opensource.org/licenses/Apache-2.0)
[](https://quantummaid.de/community.html)
[](https://gitter.im/quantum-maid-framework/community)
[](https://twitter.com/quantummaid)

# InjectMaid
InjectMaid is a lightweight dependency injection framework that does not rely on annotations.
Features:
- Injection via public constructor or static factory method
- Does not call non-public methods nor set non-public fields
- Support for singletons (lazy and eager initialization)
- Generics are fully supported
- Optionally respects `@Inject` and `@Singleton` annotations
- Advanced scoping
- Circular dependency detection
- No expensive classpath scanning
Coming soon:
- Pre-compiled reflections
- Support for GraalVM
Limitations:
- No support for field and setter injection
## Getting started
The InjectMaid documentation can be found [here](./documentation/01_Usage.md).
## Get in touch
Feel free to join us on [Slack](https://quantummaid.de/community.html)
or [Gitter](https://gitter.im/quantum-maid-framework/community) to ask questions, give feedback or just discuss software
architecture with the team behind HttpMaid. Also, don't forget to visit our [website](https://quantummaid.de) and follow
us on [Twitter](https://twitter.com/quantummaid)!
## Frequently asked questions
### Can I use InjectMaid without reflection?
Yes. You can easily [register all types directly](documentation/03_CustomInstantiation.md) and InjectMaid
will not perform a single reflective call.
### Is there anything wrong with annotations?
No. But like any other concept, there are downsides.
InjectMaid leaves the choice whether to use them to you. You can configure InjectMaid
with annotations, but you don't have to.
However, InjectMaid is part of the larger [QuantumMaid application framework](https://quantummaid.de/index.html). QuantumMaid is designed around the concept of
clean architecture [as defined by Robert C. Martin](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).
Here, developers are encouraged to strictly keep infrastructure code separate from business logic (or *domain code* in Domain-Driven Design):

This way, infrastructure aspects like databases and public APIs (REST, etc.) are mere replaceable details.
Directly annotating business logic with infrastructure annotations like those of [JAX-RS](https://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services),
[CDI](https://docs.oracle.com/javaee/6/tutorial/doc/giwhl.html), [JSON-B](https://javaee.github.io/jsonb-spec/users-guide.html),
[JSR 303](https://beanvalidation.org/1.0/spec/), [JPA](https://en.wikipedia.org/wiki/Java_Persistence_API), etc.
removes this strict separation.
A common workaround is the creation of wrapper classes whose sole purpose is to carry the
infrastructure annotations (controllers, JSON models, etc.). This might be feasible in some cases but introduces a lot
of boilerplate overhead.
Another downside to classical annotation processing is its implication on application startup time.
A classical JEE container needs to scan all classes in a newly deployed application for annotations to determine its configuration.
This is inherently slow and leads to long initialization phases.
With the introduction of popular serverless hosting options like
[AWS Lambda](https://aws.amazon.com/lambda/), this becomes a crucial issue.
Projects like [Google Dagger](https://dagger.dev/), [Quarkus](https://quarkus.io/) and [Micronaut](https://micronaut.io/)
partially solve that problem by processing annotations at compile time.
QuantumMaid offers an alternative approach by avoiding configuration by annotations altogether.
Here are additional (independent) blogs with a similar point of view:
- [https://blog.softwaremill.com/the-case-against-annotations-4b2fb170ed67]()
- [https://medium.com/@vincent.maurin.fr/java-annotations-and-oop-a2633f3692fb]()
Another Java application framework that follows an approach without annotations is the [Vlingo Platform](https://vlingo.io/).
It is actively maintained by Vaughn Vernon, the author of the
book [Implementing Domain-Driven Design](https://www.oreilly.com/library/view/implementing-domain-driven-design/9780133039900/).