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 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)
           
 Connection getConnection()
          Retrieves the connection currently "logically" managed by this LogicalConnectionImpl.
 ConnectionReleaseMode getConnectionReleaseMode()
          The release mode under which this logical connection is operating.
 JdbcServices getJdbcServices()
          Obtains the JDBC services associated with this logical connection.
 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 isUserSuppliedConnection()
           
 Connection manualDisconnect()
          Manually disconnect the underlying JDBC Connection.
 void manualReconnect(Connection suppliedConnection)
          Manually reconnect the underlying JDBC Connection.
 void notifyObserversStatementPrepared()
           
 void releaseConnection()
          Physically closes the JDBC Connection.
 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

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

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.

aggressiveRelease

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

Specified by:
aggressiveRelease in interface LogicalConnectionImplementor

releaseConnection

public void releaseConnection()
                       throws JDBCException
Physically closes the JDBC Connection.

Specified by:
releaseConnection in interface LogicalConnectionImplementor
Throws:
JDBCException - Indicates problem closing a 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

isUserSuppliedConnection

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

notifyObserversStatementPrepared

public void notifyObserversStatementPrepared()
Specified by:
notifyObserversStatementPrepared 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-2015 Red Hat, Inc. All Rights Reserved.