CDI Extension

EclipseStore comes with a CDI extension, which allows accessing the functionality of EclipseStore through the usage of a few annotations.

It is available within this artifact:


The integration requires the javax namespace and requires a CDI 4.0 implementation and an Eclipse MicroProfile Config 2.0 implementation.

This CDI extension makes use of the Extension interface and the BeanManager functionality, so it might not work in a strict Jakarta EE 10 Core Profile product that only supports the CDI Lite functionality.


The configuration of the StorageManager can be done using key/value pairs that are provided by MicroProfile Config. The configuration keys must be prefixed by

Since the - character is not supported in some sources (like the environment variables), you can also define the configuration keys using the . character.

Besides that, the regular MicroProfile Config rules about keys are applied (since we are using MicroProfile Config directly, see specification).

The configured and started StorageManager is a CDI bean and thus can be injected or retrieved programmatically.

private StorageManager storageManager;

public void someMethod() {
    StorageManager storageManager = CDI.current().select(StorageManager.class).get();

The StorageManager configuration can be customized by CDI beans that implement the interface The customize method is called with an EmbeddedStorageFoundation which allows you to fully customize the StorageManager that will be created. You can for example, add the specific Type Handlers for JDK 8 as described on the documentation.

After the StorageManager is created, the CDI beans that implement are called. You have the opportunity to perform actions on the StorageManager or root object. Following rules apply to the StorageManager that is passed to the initialize method of the interface.

  • The StorageManager is already started unless you specified the configuration value

  • If you have used the @Storage annotation on a class, the StorageManager is already associated with an instance of that class as the Root object.

There is a second option to configure and retrieve the StorageManager, and it makes use of the EclipseStore functionality to read the configuration from any file.

@ConfigProperty(name = "")
private StorageManager storageManager;

The above construct makes use of the MicroProfile Config functionality that you convert the value of the key and convert it into a StorageManager. The value of the key is expected to point to an existing file. The formats XML, INI, and properties are supported.

The StorageManager is also fully configured and started just as you would use it when using the first option of configuration.

If you define it multiple times, within different beans, for example, you always receive the same instance of the StorageManager when you specify the same value for the name member of the @ConfigProperty annotation.

This way, you can define and use multiple _StorageManager_s within your application.

The customizer and initializer features described earlier as CDI beans implementing a specific interface are also available when you use the MicroProfile Config annotation (@ConfigProperty). Since you can define multiple StorageManager_s this way, you can distinguish between them based on the _database name.

The database name can be set by using the following property within the configuration file (example makes use of the properties format, but it is also supported in the other formats)


If this property is not specified, the value of the MicroProfile config key (used within the name member of @ConfigProperty) is used.

Within the customizer and initializer, you can use this to perform the required actions based on the instance you receive.



Root object

The root object can be indicated by using the @Storage annotation on the class. This annotation converts the POJO into a CDI bean (there is no need to use any scope-defining annotation) with Application Scope.

This is only supported when you inject the StorageManager without making use of the MicroProfile Config @ConfigProperty annotation.

Besides converting it into a CDI bean, any field injection within this class is also resolved.

The integration also defines the instance of the class that is created as the root object (StorageManager.setRoot()) and stores the initial value (StorageManager.storeRoot()) when storageManager does not have a root object assigned yet (this happens only the very first time when you start up your application and the storage doesn’t contain any data yet)

The POJO must have a (default) no-argument constructor so that the integration can create an instance of it.

You can only annotate 1 class with the @Storage annotation, if you have marked multiple, the deployment of your application will fail at the CDI validation phase.