| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.farrago.catalog.FarragoReposTxnContext
public class FarragoReposTxnContext
FarragoReposTxnContext manages the state of at most one repository transaction. A context may be inactive, meaning it has no current transaction.
Always use the following exception-safe transaction pattern:
   FarragoReposTxnContext txn = repos.newTxnContext();
   try {
       txn.beginWriteTxn();
       ... do stuff which accesses repository ...
       txn.commit();
   } finally {
       // no effect if already committed or beginWriteTxn failed
       txn.rollback();
   }
| Nested Class Summary | |
|---|---|
private static class | 
FarragoReposTxnContext.State
 | 
| Field Summary | |
|---|---|
private  int | 
lockLevel
 | 
private  boolean | 
manageReposSession
 | 
private  boolean | 
readOnly
 | 
private  FarragoRepos | 
repos
 | 
private  FarragoReposTxnContext.State | 
state
 | 
| Constructor Summary | |
|---|---|
FarragoReposTxnContext(FarragoRepos repos)
Creates a new inactive transaction context with manual repository session management.  | 
|
FarragoReposTxnContext(FarragoRepos repos,
                       boolean manageRepoSession)
Creates a new inactive transaction context.  | 
|
FarragoReposTxnContext(FarragoRepos repos,
                       boolean manageRepoSession,
                       boolean readOnly)
Creates a new inactive transaction context that's optionally readonly.  | 
|
| Method Summary | |
|---|---|
 void | 
beginExclusiveAccess()
Puts the repository in exclusive access mode.  | 
 void | 
beginLockedTxn(boolean readOnly)
Acquires a repository lock and begins a matching MDR transaction (shared lock for read, or exclusive lock for write).  | 
 void | 
beginReadTxn()
Begins a new read-only transaction.  | 
 void | 
beginWriteTxn()
Begins a new read/write transaction.  | 
 void | 
commit()
Commits the active transaction, if any.  | 
 void | 
endExclusiveAccess()
Ends exclusive access mode for the repository.  | 
 boolean | 
isReadTxnInProgress()
 | 
 boolean | 
isTxnInProgress()
 | 
 void | 
rollback()
Rolls back the active transaction, if any.  | 
 void | 
setReposReadOnly()
Switches the repository to read-only mode.  | 
 void | 
unlockAfterTxn()
Releases lock acquired by beginLockedTxn.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
private FarragoRepos repos
private FarragoReposTxnContext.State state
private int lockLevel
private final boolean manageReposSession
private boolean readOnly
| Constructor Detail | 
|---|
public FarragoReposTxnContext(FarragoRepos repos)
repos - the repos against which transactions are to be performed
public FarragoReposTxnContext(FarragoRepos repos,
                              boolean manageRepoSession)
repos - the repos against which transactions are to be performedmanageRepoSession - if true, a repository session is wrapped around
 each transaction
public FarragoReposTxnContext(FarragoRepos repos,
                              boolean manageRepoSession,
                              boolean readOnly)
repos - the repos against which transactions are to be performedmanageRepoSession - if true, a repository session is wrapped around
 each transaction| Method Detail | 
|---|
public boolean isTxnInProgress()
public boolean isReadTxnInProgress()
public void beginReadTxn()
public void beginWriteTxn()
public void commit()
public void rollback()
public void beginLockedTxn(boolean readOnly)
readOnly - if true, a shared lock is acquired on the catalog;
 otherwise, an exclusive lock is acquiredpublic void unlockAfterTxn()
public void beginExclusiveAccess()
public void endExclusiveAccess()
public void setReposReadOnly()
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||