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

Quark Context

Build Coverage Status Maven Central

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

Installation

Add to your build.gradle:

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

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

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •