org.hibernate.engine.jdbc.internal
Class LogicalConnectionImpl

java.lang.Object
  extended by org.hibernate.engine.jdbc.internal.LogicalConnectionImpl
All Implemented Interfaces:
Serializable, LogicalConnection, LogicalConnectionImplementor

public class LogicalConnectionImpl
extends Object
implements LogicalConnectionImplementor

Standard Hibernate LogicalConnection implementation

IMPL NOTE : Custom serialization handling!

See Also:
Serialized Form

Constructor Summary
LogicalConnectionImpl(Connection userSuppliedConnection, ConnectionReleaseMode connectionReleaseMode, JdbcServices jdbcServices, JdbcConnectionAccess jdbcConnectionAccess)
           
 
Method Summary
 void addObserver(ConnectionObserver observer)
          Add an observer interested in notification of connection events.
 void afterStatementExecution()
          Used to signify that a statement has completed execution which may indicate that this logical connection need to perform an aggressive release of its physical connection.
 void afterTransaction()
          Used to signify that a transaction has completed which may indicate that this logical connection need to perform an aggressive release of its physical connection.
 void aggressiveRelease()
          Force aggressive release of the underlying connection.
 Connection close()
          Release the underlying connection and clean up any other resources associated with this logical connection.
static LogicalConnectionImpl deserialize(ObjectInputStream ois, TransactionContext transactionContext)
           
 void disableReleases()
          Manually (and temporarily) circumvent aggressive release processing.
 void enableReleases()
          Re-enable aggressive release processing (after a prior LogicalConnectionImplementor.disableReleases() call.
 Connection getConnection()
          Retrieves the connection currently "logically" managed by this LogicalConnectionImpl.
 ConnectionReleaseMode getConnectionReleaseMode()
          The release mode under which this logical connection is operating.
 Connection getDistinctConnectionProxy()
          Retrieves a distinct connection proxy.
 JdbcServices getJdbcServices()
          Obtains the JDBC services associated with this logical connection.
 JdbcResourceRegistry getResourceRegistry()
          Obtains the JDBC resource registry associated with this logical connection.
 Connection getShareableConnectionProxy()
          Retrieves the shareable connection proxy.
 boolean isAutoCommit()
           
 boolean isOpen()
          Is this logical connection open? Another phraseology sometimes used is: "are we logically connected"?
 boolean isPhysicallyConnected()
          Is this logical connection instance "physically" connected.
 boolean isReadyForSerialization()
           
 Connection manualDisconnect()
          Manually disconnect the underlying JDBC Connection.
 void manualReconnect(Connection suppliedConnection)
          Manually reconnect the underlying JDBC Connection.
 void notifyObserversStatementPrepared()
           
 void removeObserver(ConnectionObserver connectionObserver)
          Remove an observer
 void serialize(ObjectOutputStream oos)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogicalConnectionImpl

public LogicalConnectionImpl(Connection userSuppliedConnection,
                             ConnectionReleaseMode connectionReleaseMode,
                             JdbcServices jdbcServices,
                             JdbcConnectionAccess jdbcConnectionAccess)
Method Detail

getJdbcServices

public JdbcServices getJdbcServices()
Description copied from interface: LogicalConnectionImplementor
Obtains the JDBC services associated with this logical connection.

Specified by:
getJdbcServices in interface LogicalConnectionImplementor
Returns:
JDBC services

getResourceRegistry

public JdbcResourceRegistry getResourceRegistry()
Description copied from interface: LogicalConnectionImplementor
Obtains the JDBC resource registry associated with this logical connection.

Specified by:
getResourceRegistry in interface LogicalConnectionImplementor
Returns:
The JDBC resource registry.

addObserver

public void addObserver(ConnectionObserver observer)
Description copied from interface: LogicalConnectionImplementor
Add an observer interested in notification of connection events.

Specified by:
addObserver in interface LogicalConnectionImplementor
Parameters:
observer - The observer.

removeObserver

public void removeObserver(ConnectionObserver connectionObserver)
Description copied from interface: LogicalConnectionImplementor
Remove an observer

Specified by:
removeObserver in interface LogicalConnectionImplementor
Parameters:
connectionObserver - The observer to remove.

isOpen

public boolean isOpen()
Description copied from interface: LogicalConnection
Is this logical connection open? Another phraseology sometimes used is: "are we logically connected"?

Specified by:
isOpen in interface LogicalConnection
Returns:
True if logically connected; false otherwise.

isPhysicallyConnected

public boolean isPhysicallyConnected()
Description copied from interface: LogicalConnection
Is this logical connection instance "physically" connected. Meaning do we currently internally have a cached connection.

Specified by:
isPhysicallyConnected in interface LogicalConnection
Returns:
True if physically connected; false otherwise.

getConnection

public Connection getConnection()
                         throws HibernateException
Description copied from interface: LogicalConnection
Retrieves the connection currently "logically" managed by this LogicalConnectionImpl.

Note, that we may need to obtain a connection to return here if a connection has either not yet been obtained (non-UserSuppliedConnectionProvider) or has previously been aggressively released.

Specified by:
getConnection in interface LogicalConnection
Returns:
The current Connection.
Throws:
HibernateException

getShareableConnectionProxy

public Connection getShareableConnectionProxy()
Description copied from interface: LogicalConnection
Retrieves the shareable connection proxy.

Specified by:
getShareableConnectionProxy in interface LogicalConnection
Returns:
The shareable connection proxy.

getDistinctConnectionProxy

public Connection getDistinctConnectionProxy()
Description copied from interface: LogicalConnection
Retrieves a distinct connection proxy. It is distinct in that it is not shared with others unless the caller explicitly shares it.

Specified by:
getDistinctConnectionProxy in interface LogicalConnection
Returns:
The distinct connection proxy.

close

public Connection close()
Description copied from interface: LogicalConnection
Release the underlying connection and clean up any other resources associated with this logical connection.

This leaves the logical connection in a "no longer usable" state.

Specified by:
close in interface LogicalConnection
Returns:
The application-supplied connection, or null if Hibernate was managing connection.

getConnectionReleaseMode

public ConnectionReleaseMode getConnectionReleaseMode()
Description copied from interface: LogicalConnectionImplementor
The release mode under which this logical connection is operating.

Specified by:
getConnectionReleaseMode in interface LogicalConnectionImplementor
Returns:
the release mode.

afterStatementExecution

public void afterStatementExecution()
Description copied from interface: LogicalConnectionImplementor
Used to signify that a statement has completed execution which may indicate that this logical connection need to perform an aggressive release of its physical connection.

Specified by:
afterStatementExecution in interface LogicalConnectionImplementor

afterTransaction

public void afterTransaction()
Description copied from interface: LogicalConnectionImplementor
Used to signify that a transaction has completed which may indicate that this logical connection need to perform an aggressive release of its physical connection.

Specified by:
afterTransaction in interface LogicalConnection
Specified by:
afterTransaction in interface LogicalConnectionImplementor

disableReleases

public void disableReleases()
Description copied from interface: LogicalConnectionImplementor
Manually (and temporarily) circumvent aggressive release processing.

Specified by:
disableReleases in interface LogicalConnectionImplementor

enableReleases

public void enableReleases()
Description copied from interface: LogicalConnectionImplementor
Re-enable aggressive release processing (after a prior LogicalConnectionImplementor.disableReleases() call.

Specified by:
enableReleases in interface LogicalConnectionImplementor

aggressiveRelease

public void aggressiveRelease()
Force aggressive release of the underlying connection.


manualDisconnect

public Connection manualDisconnect()
Description copied from interface: LogicalConnectionImplementor
Manually disconnect the underlying JDBC Connection. The assumption here is that the manager will be reconnected at a later point in time.

Specified by:
manualDisconnect in interface LogicalConnectionImplementor
Returns:
The connection maintained here at time of disconnect. Null if there was no connection cached internally.

manualReconnect

public void manualReconnect(Connection suppliedConnection)
Description copied from interface: LogicalConnectionImplementor
Manually reconnect the underlying JDBC Connection. Should be called at some point after manualDisconnect().

Specified by:
manualReconnect in interface LogicalConnectionImplementor
Parameters:
suppliedConnection - For user supplied connection strategy the user needs to hand us the connection with which to reconnect. It is an error to pass a connection in the other strategies.

isAutoCommit

public boolean isAutoCommit()
Specified by:
isAutoCommit in interface LogicalConnectionImplementor

notifyObserversStatementPrepared

public void notifyObserversStatementPrepared()
Specified by:
notifyObserversStatementPrepared in interface LogicalConnectionImplementor

isReadyForSerialization

public boolean isReadyForSerialization()
Specified by:
isReadyForSerialization in interface LogicalConnectionImplementor

serialize

public void serialize(ObjectOutputStream oos)
               throws IOException
Throws:
IOException

deserialize

public static LogicalConnectionImpl deserialize(ObjectInputStream ois,
                                                TransactionContext transactionContext)
                                         throws IOException,
                                                ClassNotFoundException
Throws:
IOException
ClassNotFoundException


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.