|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.WrappedDBClassStore<T>
com.antelmann.db.ArchiveDBClassStore<T>
@Warning(value="due to missing X/A support, updates of the archive may not be transactionally consistent") @Todo(value="support X/A via TransactionListener") public class ArchiveDBClassStore<T extends DBEntry>
allows to add an archive store to any given store, which enables to extend the data set.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore |
|---|
DBClassStore.DBMethod |
| Field Summary |
|---|
| Fields inherited from class com.antelmann.db.WrappedDBClassStore |
|---|
store |
| Constructor Summary | |
|---|---|
ArchiveDBClassStore(DBClassStore<T> store,
DBClassStore<T> archive,
boolean enableArchive)
|
|
| Method Summary | |
|---|---|
boolean |
containsID(Object id)
determines whether the given ID is present in this store. |
int |
deleteEntries(Filter<? super T> filter)
deletes all DBEntry objects that match the given filter; if the filter is null, all resources are deleted. |
boolean |
deleteEntry(Object id)
removes the entry with the given ID from this store in the database. |
DBEnumeration<T> |
fetch(Filter<? super T> filter)
allows to retrieve the entries of this storage via iteration. |
DBEnumeration<Stub<T>> |
fetchStubs(Filter<? super Stub<?>> filter)
allows to access objects from this store w/o having to instantiate the entire original objects, but instead use Stubs to be able to display the list properly for selection. |
T |
getEntry(Object id)
returns the DBEntry based on its ID. |
Stub<T> |
getStub(Object id)
returns a Stub representing the resource for the given ID or null. |
boolean |
isArchiveEnabled()
if true, each data access call also reaches through to the embedded archived store |
boolean |
isEnableArchiveEdit()
|
int |
moveToArchive(Filter<? super T> filter)
requires transactional context on both stores |
void |
setArchiveEnabled(boolean flag)
if set to true, each data access call also reaches through to the embedded archived store |
void |
setEnableArchiveEdit(boolean enableArchiveEdit)
if set to true, delete and update operations are propagated to the archive (insertions will always only affect the 'normal' store). |
int |
size(Filter<? super T> filter)
returns the total number of T elements in this store based on the given filter (which may be null) |
void |
update(T entry)
updates the given entry in the database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArchiveDBClassStore(DBClassStore<T> store,
DBClassStore<T> archive,
boolean enableArchive)
| Method Detail |
|---|
public boolean isArchiveEnabled()
ArchivedStore
isArchiveEnabled in interface ArchivedStore<T extends DBEntry>public void setArchiveEnabled(boolean flag)
ArchivedStore
setArchiveEnabled in interface ArchivedStore<T extends DBEntry>public boolean isEnableArchiveEdit()
isEnableArchiveEdit in interface ArchivedStore<T extends DBEntry>ArchivedStore.setEnableArchiveEdit(boolean)@Warning(value="if set to true, updates/deletes on the archive may commit even if the current transaction aborts in the current implementation") public void setEnableArchiveEdit(boolean enableArchiveEdit)
ArchivedStoreArchivedStore.isArchiveEnabled().
setEnableArchiveEdit in interface ArchivedStore<T extends DBEntry>
public boolean containsID(Object id)
throws DatabaseException
DBClassStore
containsID in interface DBClassStore<T extends DBEntry>containsID in class WrappedDBClassStore<T extends DBEntry>DatabaseException
public boolean deleteEntry(Object id)
throws DatabaseException
DBClassStore
deleteEntry in interface DBClassStore<T extends DBEntry>deleteEntry in class WrappedDBClassStore<T extends DBEntry>DatabaseException
public int deleteEntries(Filter<? super T> filter)
throws DatabaseException
DBClassStoreDBClassStore.deleteEntry(Object)
is called for each entry passing the filter (although stores may choose to do so)!
Consequently, if a store's implementation does not call DBClassStore.deleteEntry(Object)
on each instance, calling this method may result in changes that are hard to monitor
for versioning purposes.
deleteEntries in interface DBClassStore<T extends DBEntry>deleteEntries in class WrappedDBClassStore<T extends DBEntry>DatabaseExceptionWrappedDBClassStore.setProcessBeforeFiltering(boolean)
public void update(T entry)
throws DatabaseException
DBClassStore
update in interface DBClassStore<T extends DBEntry>update in class WrappedDBClassStore<T extends DBEntry>DatabaseException - if the database was not able to perform the update
or it the entry didn't exist in the database before calling this method
public DBEnumeration<T> fetch(Filter<? super T> filter)
throws DatabaseException
DBClassStoreAs all relevant entries may not completely fit into memory, an Enumeration is returned instead of a list. To directly get all entries as a list (and thus avoid concurrency problems), consider using methods from AbstractIterator to quickly retrieve all resources before processing them.
Be aware that the result of the enumeration may become undefined if data is inserted/deleted/updated while the elements are accessed. To guarantee consistency, all access to the returned Enumeration must be externally synchronized by holding the monitor of the database transaction throughout maintaining the Enumeration.
Note that you may have IterationExceptions being thrown on calling methods on the returned Enumeration, which are caused by either DatabaseExceptions or InstantiationExceptions on trying to fetch the next element, as not all possible errors may be caught on calling this method (as it possibly cannot instantiate all entries in advance).
All access to the returned Enumeration must be made within an active transaction.
As the returned Enumeration may hold resources to the database while iterating, the caller must ensure that these resources can be properly release. This is usually achieved by simply completely iterating through the return value, in which case the DBEnumeration is expected to properly clean up automatically. But in cases where the caller doesn't intend to go all the way through the Enumeration, the caller has to clean up explicitly, which can be done by calling the close() method on the returned DBEnumeration.
fetch in interface DBClassStore<T extends DBEntry>fetch in class WrappedDBClassStore<T extends DBEntry>filter - may be null, in which case all entries from are returned.
DatabaseExceptionWrappedDBClassStore.setProcessBeforeFiltering(boolean)
public DBEnumeration<Stub<T>> fetchStubs(Filter<? super Stub<?>> filter)
throws DatabaseException
DBClassStorefetch(Filter) .
fetchStubs in interface DBClassStore<T extends DBEntry>fetchStubs in class WrappedDBClassStore<T extends DBEntry>DatabaseExceptionWrappedDBClassStore.setProcessBeforeFiltering(boolean)
public T getEntry(Object id)
throws DatabaseException
DBClassStore
getEntry in interface DBClassStore<T extends DBEntry>getEntry in class WrappedDBClassStore<T extends DBEntry>id - the ID that is retrieved from Resource.getID()
DatabaseExceptionDBEntry.getID()
public Stub<T> getStub(Object id)
throws DatabaseException
DBClassStore
getStub in interface DBClassStore<T extends DBEntry>getStub in class WrappedDBClassStore<T extends DBEntry>DatabaseException
public int size(Filter<? super T> filter)
throws DatabaseException
DBClassStore
size in interface DBClassStore<T extends DBEntry>size in class WrappedDBClassStore<T extends DBEntry>filter - if non-null, only those elements will be counted that are applicable to the filter
DatabaseExceptionWrappedDBClassStore.setProcessBeforeFiltering(boolean)
public int moveToArchive(Filter<? super T> filter)
throws DatabaseException
ArchivedStore
moveToArchive in interface ArchivedStore<T extends DBEntry>DatabaseException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||