Package org.fcrepo.kernel.api
Interface Transaction
-
public interface Transaction
The Fedora Transaction abstraction- Author:
- mohideen
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcommit()Commit the transactionvoidcommitIfShortLived()Commit the transaction only if the transaction is shortLivedvoidexpire()Expire a transactionInstantgetExpires()Get the date this session expiresStringgetId()Get the transaction idbooleanhasExpired()Has the transaction expired?booleanisCommitted()booleanisRolledBack()booleanisShortLived()Check if the transaction is short-lived.voidlockResource(FedoraId resourceId)Acquires a lock on the specified resource for this transaction.voidrefresh()Refresh the transaction to extend its expiration window.voidreleaseResourceLocksIfShortLived()Releases 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 transactionInstantupdateExpiry(Duration amountToAdd)Update the expiry by the provided amount
-
-
-
Method Detail
-
commit
void commit()
Commit the transaction
-
commitIfShortLived
void commitIfShortLived()
Commit the transaction only if the transaction is shortLived
-
isCommitted
boolean isCommitted()
- Returns:
- returns true if this transaction has already been committed
-
rollback
void rollback()
Rollback the transaction
-
isRolledBack
boolean isRolledBack()
- Returns:
- true if this transaction has been rolled back
-
isShortLived
boolean isShortLived()
Check if the transaction is short-lived.- Returns:
- is the transaction short-lived.
-
setShortLived
void setShortLived(boolean shortLived)
Set transaction short-lived state.- Parameters:
shortLived- boolean true (short-lived) or false (not short-lived)
-
expire
void expire()
Expire a transaction
-
hasExpired
boolean hasExpired()
Has the transaction expired?- Returns:
- true if expired
-
updateExpiry
Instant updateExpiry(Duration amountToAdd)
Update the expiry by the provided amount- Parameters:
amountToAdd- the amount of time to add- Returns:
- the new expiration date
-
getExpires
Instant getExpires()
Get the date this session expires- Returns:
- expiration date, if one exists
-
refresh
void refresh()
Refresh the transaction to extend its expiration window.
-
lockResource
void lockResource(FedoraId resourceId)
Acquires a lock on the specified resource for this transaction.- Parameters:
resourceId- the resource to lock- Throws:
ConcurrentUpdateException- if the lock cannot be acquired
-
releaseResourceLocksIfShortLived
void releaseResourceLocksIfShortLived()
Releases 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.
-
setBaseUri
void setBaseUri(String baseUri)
Sets the baseUri on the transaction- Parameters:
baseUri- the baseUri of the requests
-
setUserAgent
void setUserAgent(String userAgent)
Sets the user-agent on the transaction- Parameters:
userAgent- the request's user-agent
-
-