Skip to end of metadata
Go to start of metadata

Introduction

The GumTree local persistence (ILocalPersistenceManager) service provides a managed way to store object and state locally for application recovery. The database used for persistence is called db4o (managed by service IObjectContainerManager), which is an small embedded object database for Java and OSGi.  To use the persistence service, you will need to import plug-in org.gumtree.core.persistence, and have plug-in db4o_osgi available.

Local Persistence Service

The local persistence service provides a simple way to store object using key-value pairs, backed by the default db4o object container offered by the GumTree platform.  The following test case illustrates how this service can be used:

Developer note: Due to the constraint of OSGi class loading, the stored data MUST be located in exported package (ie, cannot persist object from internal packages).

Object Container Service

This service provides a default object database, as well as keeping track of other object database based on user creation. Those databases are stored under <workspace>/.metadata/.plugins/org.gumtree.core.persistence/.

Developer note: We use the OSGi version db4o (Db4oService) and not the generic helper class (Db4o) to create new object container instance, since it solves the class loading problem.

Using Default Persistence Database

To use this service for storage:

To retrieve object, use Native Query directly on the object container:

Using Your Own Persistence Database

You can create a new object container with the local persistence manager:

If the database has already opened, it will return the database straight away.

  • No labels