|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectnet.sourceforge.pain.db.PainDB
PAiN Db is a not thread safe semi-object oriented main memory and very buggy database.
It's used by PAiN Mud Codebase @http://pain.sf.net as persistence engine.
However, PAiN DB is general purpose database, it has great performance,
it's simple, opensource and could be used in any java based opensource projects.
Distributed under the GPL licence
| Field Summary | |
boolean |
ALLOW_PLAIN_WRITE
allows use setters outside from transactions -> could not be rolled back (performance issue) but if database will be closed before flush, this changes will be lost |
static java.lang.String |
DB_VERSION
|
boolean |
MANUAL_FLUSH_MODE
MANUAL_FLUSH mode is a kind of delayed commit, user should manually call flush (outside of transaction) to flush all data to disk, if MANUAL_FLUSH_MODE is false every time T1(upper level) transaction commited PainDB will automatically call flush method. |
| Constructor Summary | |
PainDB(java.lang.String fileName)
Opens specified database file. |
|
| Method Summary | |
void |
beginTransaction()
starts the database transaction. |
void |
close()
closes database. |
void |
commitTransaction()
commits the database transaction. |
java.lang.Object |
execute(DbTransaction trans)
same as execute(trans, null); |
java.lang.Object |
execute(DbTransaction trans,
java.lang.Object[] params)
Executes transaction. |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
void |
flush()
flushes all changes done after previous flush to disk Called automatically after each upper level transaction commit if MANUAL_FLUSH_MODE is false |
void |
forceClose()
all active transactions will be rolled back |
DbClass |
getClass(java.lang.Object classId)
|
DbClass |
getDbClass(java.lang.Class javaClazz)
|
java.lang.String |
getDbFileName()
|
long |
getDBFileSize()
|
int |
getNumberOfObjectsInDb()
|
DbObject |
getObject(java.lang.Object objectId)
|
DbObject |
getRoot()
root is a simple mark on object, It's allowed to do not have root in DB. |
boolean |
isClosed()
|
boolean |
isDatabaseEmpty()
|
void |
rollbackTransaction()
|
void |
setRoot(DbObject obj)
root is a simple mark on object, db could have not root at all, any time user can null this mark |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String DB_VERSION
public boolean ALLOW_PLAIN_WRITE
public boolean MANUAL_FLUSH_MODE
| Constructor Detail |
public PainDB(java.lang.String fileName)
throws java.lang.Exception
fileName - - name of database file
java.lang.Exception - - if file is corrupted or is not paindb database file| Method Detail |
public void flush()
throws java.io.IOException
java.io.IOException - if any IO error occurs.
java.lang.RuntimeException - if there is active transactionpublic DbClass getClass(java.lang.Object classId)
classId - - OID of the DbClass
public DbObject getObject(java.lang.Object objectId)
objectId - - serialized unique object id
public void close()
public DbClass getDbClass(java.lang.Class javaClazz)
public DbObject getRoot()
public void setRoot(DbObject obj)
public long getDBFileSize()
throws java.io.IOException
java.io.IOException - if any IO error occured during this method callpublic boolean isDatabaseEmpty()
public int getNumberOfObjectsInDb()
protected void finalize()
java.lang.Objectfinalize method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.
The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.
The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the finalize method causes
the finalization of this object to be halted, but is otherwise
ignored.
public void beginTransaction()
DbTransaction wrapper class and do not call
this method manually
public void commitTransaction()
throws java.io.IOException
DbTransaction wrapper class and do not call
this method manually
This method will automatically flush all changes to disk if
there no upperlevel transaction and MANUAL_FLUSH_MODE was not set
java.io.IOException - if any IO problem occurs during flushpublic void rollbackTransaction()
public java.lang.Object execute(DbTransaction trans)
throws java.lang.Exception
java.lang.Exception
public java.lang.Object execute(DbTransaction trans,
java.lang.Object[] params)
throws java.lang.Exception
params - passed to DbTransaction.execute() method
java.lang.Exception - if it was thrown in DbTransaction.execute method or if
write error on flush occurspublic java.lang.String getDbFileName()
public boolean isClosed()
public void forceClose()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||