public class LocalRepoTransactionImpl extends Object implements LocalRepoTransaction, ContextWithLocalRepoManager, ContextWithPersistenceManager
Modifier and Type | Field and Description |
---|---|
static long |
LOCK_TIMEOUT |
Constructor and Description |
---|
LocalRepoTransactionImpl(co.codewizards.cloudstore.local.LocalRepoManagerImpl localRepoManager,
boolean write) |
Modifier and Type | Method and Description |
---|---|
protected void |
_rollback() |
void |
addPostCloseListener(LocalRepoTransactionPostCloseListener listener) |
void |
addPreCloseListener(LocalRepoTransactionPreCloseListener listener) |
void |
close()
Equivalent to
LocalRepoTransaction.rollbackIfActive() . |
void |
commit() |
protected void |
firePostCloseListeners(boolean commit) |
protected void |
firePreCloseListeners(boolean commit) |
void |
flush() |
<T> T |
getContextObject(Class<T> clazz) |
<D> D |
getDao(Class<D> daoClass) |
LocalRepoManager |
getLocalRepoManager() |
long |
getLocalRevision() |
PersistenceManager |
getPersistenceManager() |
boolean |
isActive() |
void |
removeContextObject(Class<?> clazz) |
void |
removeContextObject(Object object) |
void |
rollback() |
void |
rollbackIfActive() |
void |
setContextObject(Object object) |
public static final long LOCK_TIMEOUT
public LocalRepoTransactionImpl(co.codewizards.cloudstore.local.LocalRepoManagerImpl localRepoManager, boolean write)
public void commit()
commit
in interface LocalRepoTransaction
public boolean isActive()
isActive
in interface LocalRepoTransaction
public void rollback()
rollback
in interface LocalRepoTransaction
public void rollbackIfActive()
rollbackIfActive
in interface LocalRepoTransaction
protected void _rollback()
public void close()
LocalRepoTransaction
LocalRepoTransaction.rollbackIfActive()
.
Implementations must make sure that invoking close()
means exactly the same as invoking
rollbackIfActive()
. This method was added to make the usage of LocalRepoTransaction
possible in a try-with-resources-clause. See AutoCloseable
for more details. Here's a code
example:
try ( LocalRepoTransaction transaction = localRepoManager.beginWriteTransaction(); ) { // Write sth. into the database... // And don't forget to commit! transaction.commit(); }
close
in interface LocalRepoTransaction
close
in interface AutoCloseable
LocalRepoTransaction.rollbackIfActive()
public PersistenceManager getPersistenceManager()
getPersistenceManager
in interface ContextWithPersistenceManager
public long getLocalRevision()
getLocalRevision
in interface LocalRepoTransaction
public LocalRepoManager getLocalRepoManager()
getLocalRepoManager
in interface ContextWithLocalRepoManager
getLocalRepoManager
in interface LocalRepoTransaction
public <D> D getDao(Class<D> daoClass)
getDao
in interface DaoProvider
public void flush()
flush
in interface LocalRepoTransaction
public void setContextObject(Object object)
setContextObject
in interface ExtensibleContext
public <T> T getContextObject(Class<T> clazz)
getContextObject
in interface ExtensibleContext
public void removeContextObject(Object object)
removeContextObject
in interface ExtensibleContext
public void removeContextObject(Class<?> clazz)
removeContextObject
in interface ExtensibleContext
public void addPreCloseListener(LocalRepoTransactionPreCloseListener listener)
addPreCloseListener
in interface LocalRepoTransaction
public void addPostCloseListener(LocalRepoTransactionPostCloseListener listener)
addPostCloseListener
in interface LocalRepoTransaction
protected void firePreCloseListeners(boolean commit)
protected void firePostCloseListeners(boolean commit)
Copyright © 2013–2019. All rights reserved.