|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjdbm.recman.BaseRecordManager
public final class BaseRecordManager
This class manages records, which are uninterpreted blobs of data. The set of operations is simple and straightforward: you communicate with the class using long "rowids" and byte[] data blocks. Rowids are returned on inserts and you can stash them away someplace safe to be able to get back to them. Data blocks can be as long as you wish, and may have lengths different from the original when updating.
Operations are synchronized, so that only one of them will happen concurrently even if you hammer away from multiple threads. Operations are made atomic by keeping a transaction log which is recovered after a crash, so the operations specified by this interface all have ACID properties.
You identify a file by just the name. The package attaches .db for the database file, and .lg for the transaction log. The transaction log is synchronized regularly and then restarted, so don't worry if you see the size going up and down.
Field Summary | |
---|---|
static boolean |
DEBUG
Static debugging flag |
static int |
NAME_DIRECTORY_ROOT
Reserved slot for name directory. |
Constructor Summary | |
---|---|
BaseRecordManager(java.lang.String filename)
Creates a record manager for the indicated file |
Method Summary | |
---|---|
void |
close()
Closes the record manager. |
void |
commit()
Commit (make persistent) all changes since beginning of transaction. |
void |
delete(long recid)
Deletes a record. |
void |
disableTransactions()
Switches off transactioning for the record manager. |
java.lang.Object |
fetch(long recid)
Fetches a record using standard java object serialization. |
java.lang.Object |
fetch(long recid,
Serializer serializer)
Fetches a record using a custom serializer. |
long |
getNamedObject(java.lang.String name)
Obtain the record id of a named object. |
long |
getRoot(int id)
Returns the indicated root rowid. |
int |
getRootCount()
Returns the number of slots available for "root" rowids. |
TransactionManager |
getTransactionManager()
Get the underlying Transaction Manager |
long |
insert(java.lang.Object obj)
Inserts a new record using standard java object serialization. |
long |
insert(java.lang.Object obj,
Serializer serializer)
Inserts a new record using a custom serializer. |
void |
rollback()
Rollback (cancel) all changes since beginning of transaction. |
void |
setNamedObject(java.lang.String name,
long recid)
Set the record id of a named object. |
void |
setRoot(int id,
long rowid)
Sets the indicated root rowid. |
void |
update(long recid,
java.lang.Object obj)
Updates a record using standard java object serialization. |
void |
update(long recid,
java.lang.Object obj,
Serializer serializer)
Updates a record using a custom serializer. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NAME_DIRECTORY_ROOT
public static final boolean DEBUG
Constructor Detail |
---|
public BaseRecordManager(java.lang.String filename) throws java.io.IOException
java.io.IOException
- when the file cannot be opened or is not
a valid file content-wise.Method Detail |
---|
public TransactionManager getTransactionManager()
public void disableTransactions()
Only call this method directly after opening the file, otherwise the results will be undefined.
public void close() throws java.io.IOException
close
in interface RecordManager
java.io.IOException
- when one of the underlying I/O operations fails.public long insert(java.lang.Object obj) throws java.io.IOException
insert
in interface RecordManager
obj
- the object for the new record.
java.io.IOException
- when one of the underlying I/O operations fails.public long insert(java.lang.Object obj, Serializer serializer) throws java.io.IOException
insert
in interface RecordManager
obj
- the object for the new record.serializer
- a custom serializer
java.io.IOException
- when one of the underlying I/O operations fails.public void delete(long recid) throws java.io.IOException
delete
in interface RecordManager
recid
- the rowid for the record that should be deleted.
java.io.IOException
- when one of the underlying I/O operations fails.public void update(long recid, java.lang.Object obj) throws java.io.IOException
update
in interface RecordManager
recid
- the recid for the record that is to be updated.obj
- the new object for the record.
java.io.IOException
- when one of the underlying I/O operations fails.public void update(long recid, java.lang.Object obj, Serializer serializer) throws java.io.IOException
update
in interface RecordManager
recid
- the recid for the record that is to be updated.obj
- the new object for the record.serializer
- a custom serializer
java.io.IOException
- when one of the underlying I/O operations fails.public java.lang.Object fetch(long recid) throws java.io.IOException
fetch
in interface RecordManager
recid
- the recid for the record that must be fetched.
java.io.IOException
- when one of the underlying I/O operations fails.public java.lang.Object fetch(long recid, Serializer serializer) throws java.io.IOException
fetch
in interface RecordManager
recid
- the recid for the record that must be fetched.serializer
- a custom serializer
java.io.IOException
- when one of the underlying I/O operations fails.public int getRootCount()
getRootCount
in interface RecordManager
public long getRoot(int id) throws java.io.IOException
getRoot
in interface RecordManager
java.io.IOException
getRootCount()
public void setRoot(int id, long rowid) throws java.io.IOException
setRoot
in interface RecordManager
java.io.IOException
getRootCount()
public long getNamedObject(java.lang.String name) throws java.io.IOException
getNamedObject
in interface RecordManager
java.io.IOException
public void setNamedObject(java.lang.String name, long recid) throws java.io.IOException
setNamedObject
in interface RecordManager
java.io.IOException
public void commit() throws java.io.IOException
commit
in interface RecordManager
java.io.IOException
public void rollback() throws java.io.IOException
rollback
in interface RecordManager
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |