10.2. KodoPersistenceManager

10.2.1. JDO Events
10.2.2. PersistenceManager Extension

All Kodo persistence managers implement the kodo.runtime.KodoPersistenceManager interface. This interface extends the standard javax.jdo.PersistenceManager, and, just as the standard persistence manager is the primary window into JDO runtime services, the KodoPersistenceManager is the primary window into Kodo-specific functionality. We strongly encourage you to investigate the API extensions this interface contains, including many JDO 2.0 preview features.

10.2.1. JDO Events

One very important aspect of the KodoPersistenceManager is its support for broadcasting transaction-related events. By registering one or more kodo.event.TransactionListener's with the persistence manager, you can receive notifications when transactions begin, flush, rollback, commit, and more. Where appropriate, event notifications include the set of persistence-capable objects participating in the transaction.

For details on the transaction framework, see the Javadoc for the kodo.event package.

[Note]Note

The Kodo JDO Performance Pack also supports distributed events.

10.2.2. PersistenceManager Extension

Some advanced users may want to use a custom PersistenceManager in place of Kodo JDO's kodo.runtime.PersistenceManagerImpl.

Kodo JDO permits simple extension of the PersistenceManager used by the runtime. This can be useful when custom behavior is desired, or when an application needs to receive notification when certain PersistenceManager methods are invoked.

To specify a subclass of PersistenceManagerImpl, set the kodo.PersistenceManagerImpl configuration property to the full class name of you custom persistence manager.

As a plugin string, this property can also be used to configure persistence managers. All PersistenceManagerImpls recognize the following properties:

  • CloseOnManagedCommit: If true, then the persistence manager will be closed after a managed transaction (such as an EJB container-managed transaction) commits, assuming you have invoked the close method. If this is set to false, then the persistence manager will not be closed. This means that objects that were not properly detached from the persistence manager at the end of a session bean method and were then passed to a processing tier in the same JVM will still be usable, as their owning persistence manager will still be open. This behavior is not in strict compliance with the JDO specification, but is convenient for applications that were coded against Kodo 2, which did not close the persistence manager in these situations. The default for this property is true, meaning that the PersistenceManager will be properly closed.

  • EvictFromDataCache: When evicting an object through the standard persistence manager evict methods, whether to also evict it from the Kodo's datastore cache. Defaults to false.