|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.amazon.carbonado.spi.AbstractRepository<Txn>
Txn - Transaction typepublic abstract class AbstractRepository<Txn>
Implements basic functionality required by a core Repository.
| Constructor Summary | |
|---|---|
protected |
AbstractRepository(String name)
|
| Method Summary | ||
|---|---|---|
protected Collection<Storage> |
allStorage()
Returns all available Storage instances. |
|
void |
close()
Closes this repository reference, aborting any current transactions. |
|
protected abstract SequenceValueProducer |
createSequenceValueProducer(String name)
Called upon to create a new SequenceValueProducer instance. |
|
protected abstract
|
createStorage(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. |
|
|
getCapability(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. |
|
String |
getName()
Returns the name of this repository. |
|
SequenceValueProducer |
getSequenceValueProducer(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. |
|
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. |
|
|
storageFor(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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractRepository(String name)
| Method Detail |
|---|
public String getName()
Repository
getName in interface Repository
public <S extends Storable> Storage<S> storageFor(Class<S> type)
throws SupportException,
RepositoryException
Repository
storageFor in interface RepositorySupportException - if specified type cannot be supported
RepositoryException - 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)
Repository
enterTransaction 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()
Repository
getTransactionIsolationLevel in interface Repositorypublic <C extends Capability> C getCapability(Class<C> capabilityType)
getCapability in interface RepositorycapabilityType - type of capability requested
public void close()
Repository
close in interface Repositorypublic boolean isAutoShutdownEnabled()
ShutdownCapability
isAutoShutdownEnabled in interface ShutdownCapabilitypublic void setAutoShutdownEnabled(boolean enabled)
ShutdownCapability
setAutoShutdownEnabled 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 ShutdownCapability
public SequenceValueProducer getSequenceValueProducer(String name)
throws RepositoryException
SequenceCapability
getSequenceValueProducer in interface SequenceCapabilityname - sequence name
RepositoryExceptionprotected abstract TransactionManager<Txn> transactionManager()
protected abstract TransactionScope<Txn> localTransactionScope()
protected void lockoutShutdown()
protected void unlockoutShutdown()
protected Collection<Storage> allStorage()
protected void shutdownHook()
protected abstract org.apache.commons.logging.Log getLog()
protected abstract <S extends Storable> Storage<S> createStorage(Class<S> type)
throws RepositoryException
RepositoryException
protected abstract SequenceValueProducer createSequenceValueProducer(String name)
throws RepositoryException
RepositoryException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||