Transparent Activation

db4o activation framework (TA)

Since version 6.3, db4o provides an activation framework as described here.

However, this framework requires for each object to implement an additional interface plus an Activator field, and then call activate on the Activator when you need to access the content of the object.

db4o persistence framework (TP)

More recently, the activation has been generalized into This enables to transparently store objects into db4o.


Setting up transparent activation

Configuration configuration = Db4o.newConfiguration();

By default, there is no persistence policy configured and the default activation activates on all methods.

Setting up transparent persistence and activation with custom policies and thread local activator

Configuration configuration = Db4o.newConfiguration();
configuration.add(ProxyActivationSupport.create().withActivationPolicy(new ActivateOnAllMethods()).withPersistPolicy(new AnnotationPersistencePolicy()).threadLocalActivator());

The persistence policy will persist after a call on a method with the @Persist annotation.

Additional parameters
  • ThreadLocal: the activator can be stored in a threadlocal variable to enable one activator per thread. This is useful if you need to share TA/TP objects between threads. Default to false.
  • Activation Policy: any ActivateOnMethodPolicy implementation. By default all methods require activation but another implementation could only activate getters or use an annotation.
  • Persistence Policy: any PersistOnMethodPolicy implementation. By default, only method that are annotated with @Persist will cause the activator to be called with ActivationPurpose.WRITE.