Skip to content

Coditory Quark Context is a lightweight and single purpose java library with IoC container

License

Notifications You must be signed in to change notification settings

coditory/quark-context

Folders and files

NameName
Last commit message
Last commit date
Feb 6, 2024
Jan 28, 2023
Feb 6, 2024
Mar 24, 2025
May 9, 2024
Jan 6, 2021
Jan 6, 2021
Jan 6, 2021
Feb 6, 2024
Feb 6, 2024
Feb 6, 2024
Feb 6, 2024
Feb 6, 2024

Repository files navigation

Quark Context

Build Coverage Maven Central

🚧 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

Installation

Add to your build.gradle:

dependencies {
    implementation "com.coditory.quark:quark-context:$version"
}

Loading application context

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);
        // ...
    }
}