org.datanucleus.store.connection
Interface ConnectionManager

All Known Implementing Classes:
ConnectionManagerImpl

public interface ConnectionManager

Manager of connections for a StoreManager, allowing ManagedConnection pooling, enlistment in transaction. The pool caches one connection per poolKey object. The poolKey is typically the ExecutionContext (ObjectManager). The allocateConnection method can create connections and enlist them (like most normal persistence operations need) or create a connection and return it without enlisting it into a transaction, for example the connections used to generate object identity, create the database schema or obtaining the schema metadata. The closeAllConnections method is typically called when the owning object (ExecutionContext) is being closed giving us chance to close all retained connections for that poolKey.

Connections can be locked per object poolKey basis. Locking of connections is used to handle the connection over to the user application. A locked connection denies any further access to the datastore, until the user application unlock it.


Method Summary
 ManagedConnection allocateConnection(ConnectionFactory factory, java.lang.Object poolKey, Transaction tx, java.util.Map options)
          Allocate a connection using the specified factory (unless we already have one cached for the poolKey object).
 void closeAllConnections(ConnectionFactory factory, java.lang.Object poolKey)
          Method to close all pooled connections for the specified key of the specified factory.
 void disableConnectionPool()
          Disable binding objects to "poolKey" references, so automatically disables the connection pooling
 ConnectionFactory lookupConnectionFactory(java.lang.String name)
          Method to lookup a connection factory and create it if not yet existing.
 void registerConnectionFactory(java.lang.String name, ConnectionFactory factory)
          Method to register a connection factory
 

Method Detail

lookupConnectionFactory

ConnectionFactory lookupConnectionFactory(java.lang.String name)
Method to lookup a connection factory and create it if not yet existing.

Parameters:
name - The lookup name "e.g "jdbc/tx"
Returns:
The connection factory

registerConnectionFactory

void registerConnectionFactory(java.lang.String name,
                               ConnectionFactory factory)
Method to register a connection factory

Parameters:
name - The lookup name "e.g "jdbc/tx"
factory - The connection factory

closeAllConnections

void closeAllConnections(ConnectionFactory factory,
                         java.lang.Object poolKey)
Method to close all pooled connections for the specified key of the specified factory.

Parameters:
factory - The factory
poolKey - The key in the pool

allocateConnection

ManagedConnection allocateConnection(ConnectionFactory factory,
                                     java.lang.Object poolKey,
                                     Transaction tx,
                                     java.util.Map options)
Allocate a connection using the specified factory (unless we already have one cached for the poolKey object).

Parameters:
factory - The ConnectionFactory to create any new connection with
poolKey - the object that is bound the connection during its lifecycle
options - Any options for allocating the connection (e.g isolation)
Returns:
The ManagedConnection

disableConnectionPool

void disableConnectionPool()
Disable binding objects to "poolKey" references, so automatically disables the connection pooling



Copyright © 2011. All Rights Reserved.