Pustike Inject

Pustike Inject is a simple dependency injection framework that implements the Jakarta Injection API specification.

Injector is the core part of this library and it tracks dependencies for types configured by module binders. A module uses the binder to define bindings, which will be used to create an Injector. When an instance of a type or of a binding key is requested, the injector returns the instance by creating it and injecting all its declared dependencies (constructor, fields and methods).

Pustike Inject

Following are some key features of this library:

  • Programmatic configuration in plain Java using EDSL similar to that of Guice Binder.
  • Field, Method and Constructor injections that can be Named or Annotated specifically
  • Default Scopes: Prototype, Lazy Singleton and Eager Singleton
  • Support for custom scopes: Thread Local Scope and HTTP Session Scope
  • MultiBinder support to bind multiple values as List/Collection
  • Hierarchical Injector support
  • Optional dependencies using @Nullable or Optional<T>
  • BindingListener: useful for performing further configurations
  • Events to allow publish-subscribe style communication between components
  • Only ~60kB in size and has dependency on Jakarta Injection API
  • It requires Java 11 or higher.

Documentation:

  • User Guide is included in the project’s README.md file.
  • Latest API docs are accessible here.

Download:

The most recent release is v2.0.0 (2021-01-25), and it is available from Maven central repository.

To add it as a dependency in Maven builds, use the following:

<dependency>
    <groupId>io.github.pustike</groupId>
    <artifactId>pustike-inject</artifactId>
    <version>2.0.0</version>
</dependency>

Or, download the latest JAR(~60kB) from Maven Central.

License: This library is published under the Apache License, Version 2.0