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

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

About

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

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •