🚧 This library as under heavy development until release of version 1.x.x
🚧
Lightweight, single purpose, dependency injection java library. Similar to IoC Container provided by Spring Framework but lighter.
- lightweight, exactly 3 minimalistic dependencies
- single purpose, not part of a framework
- provides both functional and annotation based API
- has conditional bean registration mechanism
- detects slow bean creation
- provides event bus integration
- public API annotated with
@NotNull
and@Nullable
for better kotlin integration
Add to your build.gradle
:
dependencies {
implementation "com.coditory.quark:quark-context:$version"
}
When using annotations you could load context with a single line:
public class Application {
public static void main(String[] args) {
Context context = Context.scanPackage(Application.class);
MyBean myBean = context.get(MyBean.class);
// ...
}
}
For more complicated setups use context builder:
public class Application {
public static void main(String[] args) {
Context context = Context.builder()
.add(new MyBean())
.add(MyBean2.class, () -> new MyBean2())
.add(MyBean3.class, (ctx) -> new MyBean3(context.getBean(MyBean.class)))
.scanPackage(Application.class)
.build();
MyBean myBean = context.get(MyBean.class);
// ...
}
}