Package org.fcrepo.kernel.api
Class ReadOnlyTransaction
java.lang.Object
org.fcrepo.kernel.api.ReadOnlyTransaction
- All Implemented Interfaces:
Transaction
A read-only tx that never expires and cannot be committed.
- Author:
- pwinckles
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commit the transactionvoidCommit the transaction only if the transaction is shortLivedvoidExecutes the runnable within the tx.voidThrows an exception if the tx is not in a COMMITTING statevoidexpire()Expire a transactionvoidfail()Marks the transaction as failed.Get the date this session expiresgetId()Get the transaction idbooleanHas the transaction expired?booleanbooleanisOpen()booleanbooleanbooleanbooleanCheck if the transaction is short-lived.voidlockResource(FedoraId resourceId) Acquires an exclusive lock on the specified resource for this transaction.voidlockResourceAndGhostNodes(FedoraId resourceId) Acquire an exclusive lock on the specified resource and any ghost nodes above it for this transaction.voidlockResourceNonExclusive(FedoraId resourceId) Acquires a non-exclusive lock on the specified resource for this transaction.voidrefresh()Refresh the transaction to extend its expiration window.voidReleases any resource locks held by the transaction if the session is short-lived.voidrollback()Rollback the transactionvoidsetBaseUri(String baseUri) Sets the baseUri on the transactionvoidsetShortLived(boolean shortLived) Set transaction short-lived state.voidsetUserAgent(String userAgent) Sets the user-agent on the transactionvoidAfter invoking, any accumulated events will be suppressed.updateExpiry(Duration amountToAdd) Update the expiry by the provided amount
-
Field Details
-
INSTANCE
-
READ_ONLY_TX_ID
- See Also:
-
-
Method Details
-
commit
Description copied from interface:TransactionCommit the transaction- Specified by:
commitin interfaceTransaction
-
commitIfShortLived
Description copied from interface:TransactionCommit the transaction only if the transaction is shortLived- Specified by:
commitIfShortLivedin interfaceTransaction
-
isCommitted
- Specified by:
isCommittedin interfaceTransaction- Returns:
- returns true if this transaction has already been committed
-
rollback
Description copied from interface:TransactionRollback the transaction- Specified by:
rollbackin interfaceTransaction
-
fail
Description copied from interface:TransactionMarks the transaction as failed. Failed transactions cannot be committed but may be rolledback.- Specified by:
failin interfaceTransaction
-
isRolledBack
- Specified by:
isRolledBackin interfaceTransaction- Returns:
- true if this transaction has been rolled back
-
isOpenLongRunning
- Specified by:
isOpenLongRunningin interfaceTransaction- Returns:
- true if the tx is a long-running tx that has not expired and is not in a COMMITTED, ROLLEDBACK, or FAILED state
-
isOpen
- Specified by:
isOpenin interfaceTransaction- Returns:
- true if the tx is in an OPEN state and has not expired
-
ensureCommitting
Description copied from interface:TransactionThrows an exception if the tx is not in a COMMITTING state- Specified by:
ensureCommittingin interfaceTransaction
-
isReadOnly
- Specified by:
isReadOnlyin interfaceTransaction- Returns:
- true the tx is read-only
-
getId
Description copied from interface:TransactionGet the transaction id- Specified by:
getIdin interfaceTransaction- Returns:
- the transaction id.
-
isShortLived
Description copied from interface:TransactionCheck if the transaction is short-lived.- Specified by:
isShortLivedin interfaceTransaction- Returns:
- is the transaction short-lived.
-
setShortLived
Description copied from interface:TransactionSet transaction short-lived state.- Specified by:
setShortLivedin interfaceTransaction- Parameters:
shortLived- boolean true (short-lived) or false (not short-lived)
-
expire
Description copied from interface:TransactionExpire a transaction- Specified by:
expirein interfaceTransaction
-
hasExpired
Description copied from interface:TransactionHas the transaction expired?- Specified by:
hasExpiredin interfaceTransaction- Returns:
- true if expired
-
updateExpiry
Description copied from interface:TransactionUpdate the expiry by the provided amount- Specified by:
updateExpiryin interfaceTransaction- Parameters:
amountToAdd- the amount of time to add- Returns:
- the new expiration date
-
getExpires
Description copied from interface:TransactionGet the date this session expires- Specified by:
getExpiresin interfaceTransaction- Returns:
- expiration date, if one exists
-
refresh
Description copied from interface:TransactionRefresh the transaction to extend its expiration window.- Specified by:
refreshin interfaceTransaction
-
lockResource
Description copied from interface:TransactionAcquires an exclusive lock on the specified resource for this transaction.- Specified by:
lockResourcein interfaceTransaction- Parameters:
resourceId- the resource to lock
-
lockResourceNonExclusive
Description copied from interface:TransactionAcquires a non-exclusive lock on the specified resource for this transaction.- Specified by:
lockResourceNonExclusivein interfaceTransaction- Parameters:
resourceId- the resource to lock
-
lockResourceAndGhostNodes
Description copied from interface:TransactionAcquire an exclusive lock on the specified resource and any ghost nodes above it for this transaction.- Specified by:
lockResourceAndGhostNodesin interfaceTransaction- Parameters:
resourceId- the resource to lock
-
releaseResourceLocksIfShortLived
Description copied from interface:TransactionReleases any resource locks held by the transaction if the session is short-lived. This method should always be called after handling a request, regardless of the outcome, so that any held locks are released immediately without having to wait for the short-lived transaction to expire.- Specified by:
releaseResourceLocksIfShortLivedin interfaceTransaction
-
doInTx
Description copied from interface:TransactionExecutes the runnable within the tx. While there are active runnables being executed, the tx may not be committed or rolledback. Runnables may only be executed when the tx is in an OPEN state and has not expired.- Specified by:
doInTxin interfaceTransaction- Parameters:
runnable- the code to execute within the tx
-
setBaseUri
Description copied from interface:TransactionSets the baseUri on the transaction- Specified by:
setBaseUriin interfaceTransaction- Parameters:
baseUri- the baseUri of the requests
-
setUserAgent
Description copied from interface:TransactionSets the user-agent on the transaction- Specified by:
setUserAgentin interfaceTransaction- Parameters:
userAgent- the request's user-agent
-
suppressEvents
Description copied from interface:TransactionAfter invoking, any accumulated events will be suppressed.- Specified by:
suppressEventsin interfaceTransaction
-