Quark Context is a lightweight and single purpose java library for loading and manipulating configurations
The idea was to create a small, single-jar library, similar to the IoC Container provided by Spring Framework , that is:
- lightweight, no dependencies
- single purpose and is not part of a framework
- provides both functional and annotation based API
- has conditional bean registration mechanism
- detects slow bean creation
Add to your build.gradle:
dependencies {
implementation "com.coditory.quark:quark-context:0.1.4"
}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);
// ...
}
}