org.datanucleus.store.neodatis
Class ConnectionFactoryImpl

java.lang.Object
  extended by org.datanucleus.store.neodatis.ConnectionFactoryImpl
All Implemented Interfaces:
org.datanucleus.ConnectionFactory

public class ConnectionFactoryImpl
extends java.lang.Object
implements org.datanucleus.ConnectionFactory

Implementation of a ConnectionFactory for NeoDatis. Obtains access to the NeoDatis ODB supporting use of

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


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER_NEODATIS
          Localiser for messages.
protected  java.util.HashMap odbByObjectManager
          Cache of the NeoDatis ODB keyed by ObjectManager.
 
Fields inherited from interface org.datanucleus.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 closeODBForObjectManager(org.datanucleus.ObjectManager om)
          Convenience method to notify the factory that the specified ObjectManager is closing, so to close any resources for it.
 org.datanucleus.ManagedConnection createManagedConnection(org.datanucleus.ObjectManager om, java.util.Map options)
          Method to create a new managed connection.
 org.datanucleus.ManagedConnection getConnection(org.datanucleus.ObjectManager om, java.util.Map options)
          Method to get a managed connection enlisting it in the transaction.
protected  org.neodatis.odb.ODB getNewODB()
          Convenience method to create a new ODB for this datastore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER_NEODATIS

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


odbByObjectManager

protected java.util.HashMap odbByObjectManager
Cache of the NeoDatis ODB 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

closeODBForObjectManager

public void closeODBForObjectManager(org.datanucleus.ObjectManager om)
Convenience method to notify the factory that the specified ObjectManager is closing, so to close any resources for it.

Parameters:
om - ObjectManager

getNewODB

protected org.neodatis.odb.ODB getNewODB()
Convenience method to create a new ODB for this datastore.

Returns:
The ODB

getConnection

public org.datanucleus.ManagedConnection getConnection(org.datanucleus.ObjectManager om,
                                                       java.util.Map options)
Method to get a managed connection enlisting it in the transaction.

Specified by:
getConnection in interface org.datanucleus.ConnectionFactory
Parameters:
om - ObjectManager (or null)
options - Any options for when creating the connection
Returns:
The connection

createManagedConnection

public org.datanucleus.ManagedConnection createManagedConnection(org.datanucleus.ObjectManager om,
                                                                 java.util.Map options)
Method to create a new managed connection.

Specified by:
createManagedConnection in interface org.datanucleus.ConnectionFactory
Parameters:
om - ObjectManager
options - Transaction options
Returns:
The connection


Copyright © 2009. All Rights Reserved.