Lightning-fast and ultimately powerful Dependency Injection

What is ActiveInject?

ActiveInject is a lightweight and powerful dependency injection library with ultimate performance and no third-party dependencies. It is multi-thread friendly, feature-rich, and can boast with lighting-fast start-up time and runtime, significantly outperforming Spring DI or Guice.
ActiveInject is one of the ActiveJ technologies, but it has minimal third-party dependencies and can be used as a stand-alone component.

Why ActiveInject?

Powerful

Support of nested scopes, singletons and transient bindings, modules, optimized multi-threaded and single-threaded Injectors

Thoroughly optimized

Entire runtime code of Injector consists of ~50 lines of code, and all the dependencies graph preprocessing is performed at startup time

Convenient

All reflection is entirely optional and abstracted out in a separate module. Also ActiveInject is fully transparent for introspection of the dependency graph

Lightweight

ActiveInject has no third-party dependencies on its own. Can be used in a lightweight embedded Dependency Injection mode

Dependency Injection: Redefined

Enjoy development with a wide range of powerful tools. ActiveInject simplifies development, debugging, refactoring and reusing of your code without restrictions and overhead. It features a very efficient and familiar DSL along with extensive use of Java 8+ functional-style programming.

Besides being extremely convenient, ActiveInject is 5.5 times faster than Guice and up to 100s times faster than Spring due to zero third-party dependencies and no overheads during runtime.

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);

Benchmarks

We’ve compared ActiveInject to Guice and Spring in the same scenario using JMH as the benchmark tool. We ran benchmarks in AverageTime mode and made 20 measurements.

Dependency Injection
ActiveInject - 7.2 Mrps Guice - 1.3 Mrps Spring - 1.3 Krps
ActiveInject
7.2 Mrps
Guice
1.3 Mrps
Spring
1.3 Krps

Add ActiveInject to your project

You can add ActiveInject to your project by importing its Maven repository.
These docs cover the most recent release of ActiveInject which is v2.2, published Sep 11, 2020 (see on Github).

Project background

ActiveInject is one of the ActiveJ technologies that also include cloud solutions, lightning-fast serializers, bytecode generators and others. To learn more about ActiveJ ecosystem, visit ActiveJ website.