Skip navigation links

Package hu.ibello.inject

This package contains API elements for the Ibello dependency injection system.

See: Description

Package hu.ibello.inject Description

This package contains API elements for the Ibello dependency injection system.

Ibello Dependency Injection System

In ibello, all dependency injections are performed by the injector. The injector discovers the injectable fields and handles their values. Sometimes a new instance will be created, and sometimes a previously created instance will be used again.

The dependency injection is based on annotations.

The test execution consists of different stages. These are:

Instances of session-scoped classes are valid only for a session. In a new session, whole new instances will be created. Similarly, instances of specification-scoped classes are valid for a specification execution, and instances of test-scoped classes are valid for a single test run. Singleton instances do not lose they validity, so a singleton class has only one instance for the entire program run.

Not all injections can be performed successfully. If the scope of the parent class is bigger that the scope of the injected field, the the injection is forbidden and will result a runtime exception. So you can't inject specification-scoped instances into a session-scoped class.

The injected class should have a default constructor. The injector calls this constructor if a new instance is needed for this class.

If the injected class implements the Initializable interface, and the injector creates a new instance, then the Initializable#initialize() method will be called automatically on that instance.

During the injection these steps will be performed in the given order:

  1. The injector determines if the field needs a new instance, or an existing instance should be used.
  2. If an existing instance should be used, then the injector assings that instance to the field, and the injection process ends.
  3. If a new instance should be created, then the injector creates that instance with the default constructor of the injected class.
  4. The injector performs a full injection process on the new instance, discovers it's injectable fields and assigns values to them.
  5. If the injected class implements the Initializable interface, then the Initializable#initialize() method will be called.
  6. The injection process for that field ends.
Author:
Kornél Simon
Skip navigation links

Created by Kornél Simon, 2022