|
Side of Software Persistence Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsos.db.AbstractDatabase
sos.db.AbstractSerializationDatabase
sos.db.InMemoryDatabase
public class InMemoryDatabase
A non-persistent database that stores objects in memory.
Since the database is entirely in memory,
database objects cannot persist across multiple executions. Each time
the application starts, it will have an empty database, which must be
initialized with create. Most applications will use
FileDatabase rather than this class.
This class is useful for applications wishing to use a temporary database, such as a cache. Also, applets can use this database without requiring access to the host's file system.
AbstractSerializationDatabase for more information.
AbstractSerializationDatabase for more information.
Database,
AbstractSerializationDatabase,
TransactionPolicy,
FileDatabase| Field Summary |
|---|
| Fields inherited from interface sos.db.Database |
|---|
logger |
| Constructor Summary | |
|---|---|
InMemoryDatabase(java.lang.String databaseName)
Creates an instance of InMemoryDatabase with the
specified database name. |
|
InMemoryDatabase(java.lang.String databaseName,
TransactionPolicy policy)
Creates a InMemoryDatabase with the specified database name and
transaction policy. |
|
| Method Summary | |
|---|---|
protected boolean |
doDelete()
Performs the action of delete. |
protected boolean |
doExists()
Performs the action of exists. |
protected byte[] |
doFetchObject(long id)
Returns the serialized object associated with id. |
protected boolean |
doFlush(LongMap<byte[]> newObjects,
LongMap<byte[]> modifiedObjects,
Progress progress)
Adds new objects, re-saves modified objects, and removes old objects from this database in a single, atomic step. |
protected long |
doNextKey(long fromKey)
Returns the next key greater than or equal to fromKey that
corresponds to an object in this database. |
protected void |
doRemoveObject(long oldKey)
Removes the specified object from this database. |
| Methods inherited from class sos.db.AbstractDatabase |
|---|
abortTransaction, addObject, close, commitTransaction, containsObject, create, delete, exists, getRoot, isOpen, open, startTransaction, transactionDepth |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface sos.db.Database |
|---|
abortTransaction, addObject, close, commitTransaction, containsObject, create, delete, exists, getName, getRoot, getTransactionPolicy, isOpen, open, startTransaction, transactionDepth |
| Constructor Detail |
|---|
public InMemoryDatabase(java.lang.String databaseName)
InMemoryDatabase with the
specified database name. The name is used only in the logging
of messages.
databaseName - name of this databaseInMemoryDatabase(String,TransactionPolicy)
public InMemoryDatabase(java.lang.String databaseName,
TransactionPolicy policy)
InMemoryDatabase with the specified database name and
transaction policy.
databaseName - name of the databasepolicy - policy to use to control transactions (may be null)| Method Detail |
|---|
protected boolean doDelete()
throws java.io.IOException
AbstractDatabasedelete. This method is called
inside delete if this database is in
an acceptable state. It has the same semantics as
delete.
doDelete in class AbstractSerializationDatabasetrue if this database is successfully deleted
java.io.IOException - if an I/O error occursAbstractDatabase.delete()protected boolean doExists()
AbstractDatabaseexists. This method is called
inside exists if this database is in
an acceptable state. It has the same semantics as
exists.
doExists in class AbstractDatabasetrue if this database existsAbstractDatabase.exists()
protected byte[] doFetchObject(long id)
throws java.io.IOException
AbstractSerializationDatabaseid.This method is called while holding this database's monitor.
doFetchObject in class AbstractSerializationDatabaseid - id of object to fetch
id
java.io.IOException - if an I/O error occurs
protected boolean doFlush(LongMap<byte[]> newObjects,
LongMap<byte[]> modifiedObjects,
Progress progress)
throws java.io.IOException
AbstractSerializationDatabaseThis method is called when a top-level transaction commits. It is called while holding this database's monitor.
doFlush in class AbstractSerializationDatabasenewObjects - a mapping of new ids (as Longs) to
new database objects (as byte[]s)modifiedObjects - a mapping of ids (as Longs) to
modified database objects (as byte[]s)progress - an object to be updated and checked as the flush is occurring
(may be null)
false if it is interrupted because the progress is canceled;
true otherwise
java.io.IOException - if an I/O error occurs
protected void doRemoveObject(long oldKey)
throws java.io.IOException
AbstractSerializationDatabaseThis method is called when a garbage collection finds the object unreachable. It is called while holding this database's monitor.
doRemoveObject in class AbstractSerializationDatabaseoldKey - keys of the object to remove from this database
java.io.IOException - if an I/O error occurs
protected long doNextKey(long fromKey)
throws java.io.IOException
AbstractSerializationDatabasefromKey that
corresponds to an object in this database.
This method is called while holding this database's monitor.
doNextKey in class AbstractSerializationDatabasefromKey - key from which to start the search
java.io.IOException - if an I/O error occurs
|
Side of Software Persistence Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||