Txn - Transaction typepublic abstract class AbstractRepository<Txn> extends java.lang.Object implements Repository, ShutdownCapability, SequenceCapability
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRepository(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Collection<Storage> |
allStorage()
Returns all available Storage instances.
|
void |
close()
Closes this repository reference, aborting any current
transactions.
|
protected abstract SequenceValueProducer |
createSequenceValueProducer(java.lang.String name)
Called upon to create a new SequenceValueProducer instance.
|
protected abstract <S extends Storable> |
createStorage(java.lang.Class<S> type)
Called upon to create a new Storage instance.
|
Transaction |
enterTopTransaction(IsolationLevel level)
Causes the current thread to enter a top-level transaction scope
with an explict isolation level.
|
Transaction |
enterTransaction()
Causes the current thread to enter a transaction scope.
|
Transaction |
enterTransaction(IsolationLevel level)
Causes the current thread to enter a transaction scope with an explict
isolation level.
|
<C extends Capability> |
getCapability(java.lang.Class<C> capabilityType)
Default implementation checks if Repository implements Capability
interface, and if so, returns the Repository.
|
protected abstract org.apache.commons.logging.Log |
getLog()
Return the main Log object for this Repository.
|
java.lang.String |
getName()
Returns the name of this repository.
|
SequenceValueProducer |
getSequenceValueProducer(java.lang.String name)
Retrieve and/or generate a SequenceValueProducer for the given name.
|
IsolationLevel |
getTransactionIsolationLevel()
Returns the isolation level of the current transaction, or null if there
is no transaction in the current thread.
|
boolean |
isAutoShutdownEnabled()
Returns true if repository has a shutdown hook registered to
automatically call shutdown when the virtual machine exits.
|
boolean |
isClosed() |
protected abstract TransactionScope<Txn> |
localTransactionScope()
Returns the thread-local TransactionScope, creating it if needed.
|
protected void |
lockoutShutdown()
Call to prevent shutdown hook from running.
|
void |
setAutoShutdownEnabled(boolean enabled)
Request to enable or disable the automatic shutdown hook.
|
void |
shutdown()
Similar to calling close on a repository, except should only be called
when the virtual machine is in the process of shutting down.
|
protected void |
shutdownHook()
Install custom shutdown logic by overriding this method.
|
<S extends Storable> |
storageFor(java.lang.Class<S> type)
Returns a Storage instance for the given user defined Storable class or
interface.
|
protected abstract TransactionManager<Txn> |
transactionManager()
Returns the repository's TransactionManager.
|
protected void |
unlockoutShutdown()
Only call this to release lockoutShutdown.
|
public java.lang.String getName()
RepositorygetName in interface Repositorypublic <S extends Storable> Storage<S> storageFor(java.lang.Class<S> type) throws SupportException, RepositoryException
RepositorystorageFor in interface RepositorySupportException - if specified type cannot be supportedRepositoryException - if storage layer throws any other kind of
exceptionpublic Transaction enterTransaction()
RepositoryTo ensure exit is called, use transactions as follows:
Transaction txn = repository.enterTransaction();
try {
// Make updates to storage layer
...
// Commit the changes up to this point
txn.commit();
// Optionally make more updates
...
// Commit remaining changes
txn.commit();
} finally {
// Ensure transaction exits, aborting uncommitted changes if an exception was thrown
txn.exit();
}
enterTransaction in interface Repositorypublic Transaction enterTransaction(IsolationLevel level)
RepositoryenterTransaction in interface Repositorylevel - minimum desired transaction isolation level -- if null, a
suitable default is selectedRepository.enterTransaction()public Transaction enterTopTransaction(IsolationLevel level)
RepositoryThis method requests a top-level transaction, which means it never has a parent transaction, but it still can be a parent transaction itself. This kind of transaction is useful when a commit must absolutely succeed, even if the current thread is already in a transaction scope. If there was a parent transaction, then a commit might still be rolled back by the parent.
Requesting a top-level transaction can be deadlock prone if the current thread is already in a transaction scope. The top-level transaction may not be able to obtain locks held by the parent transaction. An alternative to requesting top-level transactions is to execute transactions in separate threads.
enterTopTransaction in interface Repositorylevel - minimum desired transaction isolation level -- if null, a
suitable default is selectedRepository.enterTransaction()public IsolationLevel getTransactionIsolationLevel()
RepositorygetTransactionIsolationLevel in interface Repositorypublic <C extends Capability> C getCapability(java.lang.Class<C> capabilityType)
getCapability in interface RepositorycapabilityType - type of capability requestedpublic void close()
Repositoryclose in interface Repositorypublic boolean isClosed()
public boolean isAutoShutdownEnabled()
ShutdownCapabilityisAutoShutdownEnabled in interface ShutdownCapabilitypublic void setAutoShutdownEnabled(boolean enabled)
ShutdownCapabilitysetAutoShutdownEnabled in interface ShutdownCapabilitypublic void shutdown()
ShutdownCapabilityRepositories may choose to implement this method by simply calling close. There is no guarantee that shutdown will reduce exceptions, and it might not suspend any threads. Also, repositories that require proper shutdown should automatically register runtime hooks, and so this method usually doesn't need to be called manually.
shutdown in interface ShutdownCapabilitypublic SequenceValueProducer getSequenceValueProducer(java.lang.String name) throws RepositoryException
SequenceCapabilitygetSequenceValueProducer in interface SequenceCapabilityname - sequence nameRepositoryExceptionprotected abstract TransactionManager<Txn> transactionManager()
protected abstract TransactionScope<Txn> localTransactionScope()
protected void lockoutShutdown()
protected void unlockoutShutdown()
protected java.util.Collection<Storage> allStorage()
protected void shutdownHook()
protected abstract org.apache.commons.logging.Log getLog()
protected abstract <S extends Storable> Storage<S> createStorage(java.lang.Class<S> type) throws RepositoryException
RepositoryExceptionprotected abstract SequenceValueProducer createSequenceValueProducer(java.lang.String name) throws RepositoryException
RepositoryExceptionCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.