|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
S - the type of the underlying service this database relies on (e.g. a java.sql.Connection)public interface Database<S>
provides a wrapper around a database service implementation and a lookup service for persistence services for DBEntry objects. All database access through Database instances provided by this class is monitored and can be logged by adding listeners.
DBTransaction,
DatabaseChangeMonitor,
DBEntry,
DBClassStore| Method Summary | ||
|---|---|---|
boolean |
addConfigListener(DBConfigListener listener)
|
|
boolean |
addStoreListener(DBStoreListener listener)
|
|
Collection<Class<? extends DBEntry>> |
getAvailableClassStores()
returns an unmodifiable view of the existing classes that map to a DBClassStore in this database |
|
DBConfigListener[] |
getConfigListeners()
|
|
User |
getCurrentUser()
returns the user credentials of the one currently using this database |
|
S |
getDatabaseService()
provides access to the actual database service that is used by the implementation of this interface |
|
Logger |
getLogger()
access to the Logger that by default uses a LogWriter writing entries directly into this database. |
|
|
getStore(Class<T> c)
allows to query for a persistence service for a given DBEntry class. |
|
DBStoreListener[] |
getStoreListeners()
|
|
DBTransaction |
getTransaction()
provides access to the DBTransaction, which coordinates all access to the Resources via DBClassStore. |
|
|
queryStoreForInterface(Class<E> type,
Class<I> desiredInterface)
allows to query an embedded DBClassStore for additional functionality exposed via the given desired interface. |
|
boolean |
removeConfigListener(DBConfigListener listener)
|
|
boolean |
removeStoreListener(DBStoreListener listener)
|
|
void |
setCurrentUser(User user)
sets the user credentials for accessing resources |
|
|
setVersioningEnabled(Class<E> type,
boolean flag)
Enabling versioning on a class store results on additional overhead for insert, update and delete operations, as for each update and delete operation the store first retrieves the existing instance from the database before storing the new version. |
|
| Methods inherited from interface java.io.Closeable |
|---|
close |
| Method Detail |
|---|
User getCurrentUser()
void setCurrentUser(User user)
Collection<Class<? extends DBEntry>> getAvailableClassStores()
DBTransaction getTransaction()
S getDatabaseService()
Logger getLogger()
getLogger in interface LoggerProvider<T extends DBEntry> DBClassStore<T> getStore(Class<T> c)
boolean addStoreListener(DBStoreListener listener)
boolean removeStoreListener(DBStoreListener listener)
DBStoreListener[] getStoreListeners()
boolean addConfigListener(DBConfigListener listener)
boolean removeConfigListener(DBConfigListener listener)
DBConfigListener[] getConfigListeners()
<E extends DBEntry> void setVersioningEnabled(Class<E> type,
boolean flag)
DBStoreListener will then receive
DBVersionedUpdateEvent objects instead of DBUpdateEvent objects
for database updates on such store.
DBVersionedUpdateEvent
<E extends DBEntry,I> I queryStoreForInterface(Class<E> type,
Class<I> desiredInterface)
DBClassStore!
The implementation is to ensure that all calls to the returned interface are
synchronized with and embedded in a transaction if the desired interface inherits
TransactionRequired; then, each call on a method from the returned interface is
either directly committed to the database or the transaction is managed by the caller directly.
Note that each method implementation that actually alters data is responsible for
firing appropriate DBUpdateEvent objects to the listeners of the database.
The return value cannot be casted to the original class store; only a proxy is returned that merely exposes the requested interface.
Class stores that implement interfaces queried here don't need to handle transactions
themselves, similar to the way the DBClassStore methods can be implemented.
type - the DBEntry-type of the DBClassStore that is to implement the desired interfacedesiredInterface - the class of the interface that the store is implementing
TransactionRequired,
DBUtils.runInTransaction(java.util.concurrent.Callable, DBTransaction, boolean),
AbstractDatabase.queryStoreForInterface(Class, Class),
AbstractDatabase.queryStoreForInterface(Class, Class)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||