public interface Repository
Storable
instances. Some repositories do not have control over the schema (for example, a JDBC
Repository depends on the schema defined by the underlying relational database); such
repositories are called "dependent". Conversely, a repository which has complete control
over the schema is termed "independent".
A dependent repository requires and will verify that Storables have a matching definition in the external storage layer. An independent repository will automatically update type definitions in its database to match changes to Storable definitions.
Repository instances should be thread-safe and immutable. Therefore, it is safe for multiple threads to be interacting with a Repository.
RepositoryBuilder| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this repository reference, aborting any current
transactions.
|
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)
Requests a specific capability of this Repository.
|
java.lang.String |
getName()
Returns the name of this repository.
|
IsolationLevel |
getTransactionIsolationLevel()
Returns the isolation level of the current transaction, or null if there
is no transaction in the current thread.
|
<S extends Storable> |
storageFor(java.lang.Class<S> type)
Returns a Storage instance for the given user defined Storable class or
interface.
|
java.lang.String getName()
<S extends Storable> Storage<S> storageFor(java.lang.Class<S> type) throws SupportException, RepositoryException
java.lang.IllegalArgumentException - if specified type is nullMalformedTypeException - if specified type is not suitableSupportException - if specified type cannot be supportedRepositoryException - if storage layer throws any other kind of
exceptionTransaction enterTransaction()
To 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();
}
Transaction enterTransaction(IsolationLevel level)
level - minimum desired transaction isolation level -- if null, a
suitable default is selectedjava.lang.UnsupportedOperationException - if repository does not support
isolation as high as the desired levelenterTransaction()Transaction enterTopTransaction(IsolationLevel level)
This 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.
level - minimum desired transaction isolation level -- if null, a
suitable default is selectedjava.lang.UnsupportedOperationException - if repository does not support
isolation as high as the desired levelenterTransaction()IsolationLevel getTransactionIsolationLevel()
<C extends Capability> C getCapability(java.lang.Class<C> capabilityType)
capabilityType - type of capability requestedvoid close()
java.lang.SecurityException - if caller does not have permissionCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.