org.datanucleus.store.db4o
Class ConnectionFactoryImpl

java.lang.Object
  extended by org.datanucleus.store.connection.AbstractConnectionFactory
      extended by org.datanucleus.store.db4o.ConnectionFactoryImpl
All Implemented Interfaces:
org.datanucleus.store.connection.ConnectionFactory

public class ConnectionFactoryImpl
extends org.datanucleus.store.connection.AbstractConnectionFactory

Implementation of a ConnectionFactory for DB4O. Obtains access to the DB4O ObjectContainer supporting use of

When an ObjectContainer is obtained for an ObjectManager, it is cached so all subsequent uses for that ObjectManager will have the same ObjectContainer. This means that the ObjectContainer is aligned with the transaction, and so we can use commit/rollback on the ObjectContainer. When the txn commits we still have the ObjectContainer in the cache so if a subsequent txn starts on the same ObjectManager it will then have the same ObjectContainer. When the ObjectManager is closed the ObjectContainer is finally closed.


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER_DB4O
          Localiser for messages.
protected  java.util.Map objectContainerByObjectManager
          Cache of the DB4O ObjectContainer keyed by ObjectManager.
 
Fields inherited from class org.datanucleus.store.connection.AbstractConnectionFactory
omfContext, options
 
Fields inherited from interface org.datanucleus.store.connection.ConnectionFactory
DATANUCLEUS_CONNECTION_RESOURCE_TYPE, DATANUCLEUS_CONNECTION2_RESOURCE_TYPE, RESOURCE_TYPE_OPTION
 
Constructor Summary
ConnectionFactoryImpl(org.datanucleus.OMFContext omfContext, java.lang.String resourceType)
          Constructor
 
Method Summary
 void closeObjectContainerForObjectManager(java.lang.Object poolKey)
          Convenience method to notify the factory that the specified ObjectManager is closing, so to close any resources for it.
 org.datanucleus.store.connection.ManagedConnection createManagedConnection(java.lang.Object poolKey, java.util.Map options)
          Obtain a connection from the Factory.
protected  com.db4o.config.Configuration getNewConfiguration()
           
protected  com.db4o.ObjectContainer getNewObjectContainer()
          Convenience method to create a new ObjectContainer for this datastore.
 
Methods inherited from class org.datanucleus.store.connection.AbstractConnectionFactory
getConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER_DB4O

protected static final org.datanucleus.util.Localiser LOCALISER_DB4O
Localiser for messages.


objectContainerByObjectManager

protected java.util.Map objectContainerByObjectManager
Cache of the DB4O ObjectContainer keyed by ObjectManager.

Constructor Detail

ConnectionFactoryImpl

public ConnectionFactoryImpl(org.datanucleus.OMFContext omfContext,
                             java.lang.String resourceType)
Constructor

Parameters:
omfContext - The OMF context
resourceType - Type of resource (tx, nontx)
Method Detail

closeObjectContainerForObjectManager

public void closeObjectContainerForObjectManager(java.lang.Object poolKey)
Convenience method to notify the factory that the specified ObjectManager is closing, so to close any resources for it.

Parameters:
om - ObjectManager

getNewConfiguration

protected com.db4o.config.Configuration getNewConfiguration()

getNewObjectContainer

protected com.db4o.ObjectContainer getNewObjectContainer()
Convenience method to create a new ObjectContainer for this datastore.

Returns:
The ObjectContainer

createManagedConnection

public org.datanucleus.store.connection.ManagedConnection createManagedConnection(java.lang.Object poolKey,
                                                                                  java.util.Map options)
Obtain a connection from the Factory. The connection will be enlisted within the Transaction associated to the poolKey if "enlist" is set to true.

Parameters:
poolKey - the pool that is bound the connection during its lifecycle (or null)
options - Any options for then creating the connection
Returns:
the ManagedConnection


Copyright © 2010. All Rights Reserved.