org.datanucleus.store.connection
Class ConnectionManagerImpl

java.lang.Object
  extended by org.datanucleus.store.connection.ConnectionManagerImpl
All Implemented Interfaces:
ConnectionManager

public class ConnectionManagerImpl
extends java.lang.Object
implements ConnectionManager

Manager of connections for a datastore, allowing ManagedConnection pooling, enlistment in transaction. The pool caches one connection per poolKey object. 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. 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.


Field Summary
protected static Localiser LOCALISER
          Localisation of messages.
 
Constructor Summary
ConnectionManagerImpl(OMFContext omfContext)
          Constructor.
 
Method Summary
 ManagedConnection allocateConnection(ConnectionFactory factory, java.lang.Object poolKey, Transaction transaction, java.util.Map options)
          Method to return a connection for this "poolKey".
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation of messages.

Constructor Detail

ConnectionManagerImpl

public ConnectionManagerImpl(OMFContext omfContext)
Constructor.

Parameters:
omfContext - OMFContext for this manager.
Method Detail

closeAllConnections

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

Specified by:
closeAllConnections in interface ConnectionManager
Parameters:
factory - The factory
poolKey - The key in the pool

allocateConnection

public ManagedConnection allocateConnection(ConnectionFactory factory,
                                            java.lang.Object poolKey,
                                            Transaction transaction,
                                            java.util.Map options)
Method to return a connection for this "poolKey". If a connection for the "poolKey" exists in the cache will return it. If no connection exists will create a new one using the ConnectionFactory.

Specified by:
allocateConnection in interface ConnectionManager
Parameters:
factory - ConnectionFactory it relates to
poolKey - the object that is bound the connection during its lifecycle
options - Options for the connection (e.g isolation). These will override those of the txn itself
Returns:
The ManagedConnection

lookupConnectionFactory

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

Specified by:
lookupConnectionFactory in interface ConnectionManager
Parameters:
name - The lookup name "e.g "jdbc/tx"
Returns:
The connection factory

registerConnectionFactory

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

Specified by:
registerConnectionFactory in interface ConnectionManager
Parameters:
name - The lookup name "e.g "jdbc/tx"
factory - The connection factory

disableConnectionPool

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

Specified by:
disableConnectionPool in interface ConnectionManager


Copyright © 2011. All Rights Reserved.