public abstract class AbstractManagedConnection extends Object implements ManagedConnection
Modifier and Type | Field and Description |
---|---|
protected boolean |
closeOnRelease
Whether we should close() when release() of the connection is called.
|
protected boolean |
commitOnRelease
Whether we should commit() the connection on release().
|
protected Object |
conn
The underlying (datastore-specific) connection.
|
protected List<ManagedConnectionResourceListener> |
listeners
Listeners for the connection.
|
protected boolean |
locked
Whether the connection is locked for use.
|
protected int |
useCount
Count on the number of outstanding uses of this connection.
|
Constructor and Description |
---|
AbstractManagedConnection() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ManagedConnectionResourceListener listener)
Registers a ManagedConnectionResourceListener to be notified of events.
|
void |
close()
Close the connection to the datastore.
|
boolean |
closeAfterTransactionEnd()
Convenience method for whether this connection should be closed after the end of transaction.
|
boolean |
closeOnRelease() |
boolean |
commitOnRelease() |
XAResource |
getXAResource()
Obtain an XAResource which can be enlisted in a transaction
Override this if you intend on supporting this as an XA resource (default = not supported).
|
protected void |
incrementUseCount() |
boolean |
isLocked() |
void |
lock() |
void |
release()
Release this connection back to us so we can pool it if required.
|
void |
releaseSavepoint(String name)
Release the named savepoint (or do nothing if not supported).
|
void |
removeListener(ManagedConnectionResourceListener listener)
Deregister a ManagedConnectionResourceListener.
|
void |
rollbackToSavepoint(String name)
Rollback the connection to the named savepoint (or do nothing if not supported).
|
void |
setCloseOnRelease(boolean close) |
void |
setCommitOnRelease(boolean commit) |
void |
setSavepoint(String name)
Set this position in the txn as a savepoint with the provided name (if supported, otherwise do nothing).
|
String |
toString()
Method to return a string form of this object for convenience debug.
|
void |
transactionFlushed()
Flush the connection.
|
void |
transactionPreClose()
Prepare the connection for end of transaction.
|
void |
unlock() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getConnection
protected Object conn
protected boolean closeOnRelease
protected boolean commitOnRelease
protected boolean locked
protected List<ManagedConnectionResourceListener> listeners
protected int useCount
protected void incrementUseCount()
public void close()
ManagedConnection
ManagedConnectionResourceListener.managedConnectionPreClose()
and
ManagedConnectionResourceListener.managedConnectionPostClose()
.
The listeners are unregistered after this method is invoked.close
in interface ManagedConnection
public void release()
release
in interface ManagedConnection
public void transactionFlushed()
ManagedConnection
ManagedConnectionResourceListener.transactionFlushed()
transactionFlushed
in interface ManagedConnection
public void transactionPreClose()
ManagedConnection
ManagedConnectionResourceListener.transactionPreClose()
transactionPreClose
in interface ManagedConnection
public void setCloseOnRelease(boolean close)
setCloseOnRelease
in interface ManagedConnection
public void setCommitOnRelease(boolean commit)
setCommitOnRelease
in interface ManagedConnection
public boolean closeOnRelease()
closeOnRelease
in interface ManagedConnection
public boolean commitOnRelease()
commitOnRelease
in interface ManagedConnection
public void addListener(ManagedConnectionResourceListener listener)
ManagedConnection
addListener
in interface ManagedConnection
listener
- The listenerpublic void removeListener(ManagedConnectionResourceListener listener)
ManagedConnection
removeListener
in interface ManagedConnection
listener
- The listenerpublic boolean isLocked()
isLocked
in interface ManagedConnection
public void lock()
lock
in interface ManagedConnection
public void unlock()
unlock
in interface ManagedConnection
public XAResource getXAResource()
getXAResource
in interface ManagedConnection
public boolean closeAfterTransactionEnd()
ManagedConnection
closeAfterTransactionEnd
in interface ManagedConnection
public void setSavepoint(String name)
ManagedConnection
setSavepoint
in interface ManagedConnection
name
- Name of savepointpublic void releaseSavepoint(String name)
ManagedConnection
releaseSavepoint
in interface ManagedConnection
name
- Name of savepointpublic void rollbackToSavepoint(String name)
ManagedConnection
rollbackToSavepoint
in interface ManagedConnection
name
- Name of savepointCopyright © 2019. All rights reserved.