Skip to main content

Overview

ActiveJ Inject is a lightweight dependency injection library that is optimized for performance and that has no third-party dependencies. It is multi-thread friendly, feature-rich, and boasts fast start-up time and runtime, far superior to Spring DI or Guice. ActiveJ Inject is one of ActiveJ technologies and can be used as a standalone component.

Why ActiveJ Inject?

  • Annotation-based configuration is supported, as well as manual binding to avoid reflection overhead
  • Bindings are grouped into Modules that can be reused in other applications
  • Optimized injectors for single-threaded and multi-threaded use cases
  • Ability to combine, override and transform bindings
  • Support for singletons, nested scopes and transient bindings
  • Dependency graph processing is performed once at startup time
  • Provides means to introspect the dependency graph
  • No third-party dependencies

Dependency Injection: Redefined

Enjoy development with a wide range of powerful tools. ActiveJ Inject makes it easy to develop, debugg, refactor, and reuse code without restrictions or overhead.

Annotation processing is separated into a standard plugin, which is used by default and allows you to generate missing dependencies. However, if you need to implement complex business logic, you can either use ActiveJ Inject DSL or even create your own annotations processing plugins.

DSL provides support for programmatic binding generation, dependency graph introspection, transformations, automatic generation of missing bindings, and modification of existing bindings. In this way, you can use the full power of Java to algorithmically create complex bindings and dependencies graphs directly at runtime, taking into account the runtime information and settings.

Module cookbook = new AbstractModule() {    @Provides    Sugar sugar() { return new Sugar("Sugar", 10.f); }
    @Provides    Butter butter() { return new Butter("Butter", 20.0f); }
    @Provides    Flour flour() { return new Flour("Flour", 100.0f); }
    @Provides    Pastry pastry(Sugar sugar, Butter butter, Flour flour) {        return new Pastry(sugar, butter, flour);    }
    @Provides    Cookie cookie(Pastry pastry) {        return new Cookie(pastry);    }};Injector.of(cookbook).getInstance(Cookie.class);

Add ActiveJ Inject to your project

You can add ActiveJ Inject to your project by importing its Maven repository. These docs cover the most recent release of ActiveJ Inject v5.3 (see on Github or Maven).