Package org.datanucleus.store.connection
Interface ManagedConnection
-
- All Known Implementing Classes:
AbstractManagedConnection
public interface ManagedConnectionWrapper for a connection to the datastore, allowing management. A connection is handed out usinggetConnection
, and returned usingrelease
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(ManagedConnectionResourceListener listener)Registers a ManagedConnectionResourceListener to be notified of events.voidclose()Close the connection to the datastore.booleancloseAfterTransactionEnd()Convenience method for whether this connection should be closed after the end of transaction.booleancloseOnRelease()booleancommitOnRelease()ObjectgetConnection()Accessor for the datastore connection.XAResourcegetXAResource()An XAResoure for this datastore connection.booleanisLocked()voidlock()voidrelease()Method to release the datastore connection back.voidreleaseSavepoint(String name)Release the named savepoint (or do nothing if not supported).voidremoveListener(ManagedConnectionResourceListener listener)Deregister a ManagedConnectionResourceListener.voidrollbackToSavepoint(String name)Rollback the connection to the named savepoint (or do nothing if not supported).voidsetCloseOnRelease(boolean close)voidsetCommitOnRelease(boolean commit)voidsetSavepoint(String name)Set this position in the txn as a savepoint with the provided name (if supported, otherwise do nothing).voidtransactionFlushed()Flush the connection.voidtransactionPreClose()Prepare the connection for end of transaction.voidunlock()
-
-
-
Method Detail
-
getConnection
Object getConnection()
Accessor for the datastore connection.- Returns:
- The underlying connection for this datastore
-
release
void release()
Method to release the datastore connection back. Will have been handed out with a getConnection(). This may trigger a commit() of the connection depending on its operating mode at the time.
-
transactionFlushed
void transactionFlushed()
Flush the connection. It must invoke the operationManagedConnectionResourceListener.transactionFlushed()
-
transactionPreClose
void transactionPreClose()
Prepare the connection for end of transaction. It must invoke the operationManagedConnectionResourceListener.transactionPreClose()
-
close
void close()
Close the connection to the datastore. It most invoke the operationsManagedConnectionResourceListener.managedConnectionPreClose()andManagedConnectionResourceListener.managedConnectionPostClose(). The listeners are unregistered after this method is invoked.
-
setCommitOnRelease
void setCommitOnRelease(boolean commit)
-
setCloseOnRelease
void setCloseOnRelease(boolean close)
-
commitOnRelease
boolean commitOnRelease()
-
closeOnRelease
boolean closeOnRelease()
-
getXAResource
XAResource getXAResource()
An XAResoure for this datastore connection. Returns null if the connection is not usable in an XA sense- Returns:
- The XAResource
-
isLocked
boolean isLocked()
-
lock
void lock()
-
unlock
void unlock()
-
addListener
void addListener(ManagedConnectionResourceListener listener)
Registers a ManagedConnectionResourceListener to be notified of events.- Parameters:
listener- The listener
-
removeListener
void removeListener(ManagedConnectionResourceListener listener)
Deregister a ManagedConnectionResourceListener.- Parameters:
listener- The listener
-
closeAfterTransactionEnd
boolean closeAfterTransactionEnd()
Convenience method for whether this connection should be closed after the end of transaction. In DN 2.x, 3.0, 3.1 this was always true, and a connection lasted until txn commit, and then had to get a new connection. In DN 3.2+ this is configurable per datastore connection factory.- Returns:
- Whether the ConnectionManager should call close() on it when a txn ends
-
setSavepoint
void setSavepoint(String name)
Set this position in the txn as a savepoint with the provided name (if supported, otherwise do nothing).- Parameters:
name- Name of savepoint
-
releaseSavepoint
void releaseSavepoint(String name)
Release the named savepoint (or do nothing if not supported).- Parameters:
name- Name of savepoint
-
rollbackToSavepoint
void rollbackToSavepoint(String name)
Rollback the connection to the named savepoint (or do nothing if not supported).- Parameters:
name- Name of savepoint
-
-