Home

xl2.odb
Class XL2Database

java.lang.Object
  |
  +--xl2.odb.XL2Database
Direct Known Subclasses:
EncryptedDatabase

public class XL2Database
extends java.lang.Object

A network of serialized objects accessible from a single root object.

Files

An XL2 database is a directory containing of several files.

Usage

Closing

Database Daemon

Since:
Java 2
See Also:
XL2Transaction

Field Summary
static int NOT_OPEN
          Open mode.
static int OPEN_READ_ONLY
          Open mode.
static int OPEN_READ_WRITE
          Open mode.
 
Constructor Summary
XL2Database()
          See open()
 
Method Summary
 void close()
          Aborts open transactions, evicts database contents from memory, and unlocks the database.
 void closeException(java.lang.Exception x)
          Deprecated. Replaced by log(Throwable)
static XL2Database create(java.lang.String dbDir)
          Creates and returns a new XL2Database that will be open for read/write.
 java.io.ObjectInput getObjectInput(java.io.InputStream in)
          Callback for subclasses to manage serialization.
 java.io.ObjectOutput getObjectOutput(java.io.OutputStream out)
          Callback for subclasses to manage serialization.
 int getOpenMode()
          NOT_OPEN, OPEN_READ_ONLY, or OPEN_READ_WRITE
 java.lang.Object getRoot()
          Returns the database entry object.
 void log(java.lang.String message, java.lang.Throwable throwable)
          Prints a timestamp, message and stack trace to "log.xl2" in the database directory.
 void newDatabase(java.lang.String dbDir)
          Creates a database that will be closed upon completion of this method.
 XL2Transaction newTransaction()
          Required to access and mutate XL2References and opened database instances.
 void open(java.lang.String dbDir, int mode)
          Opens the database with the given mode.
 void setRoot(java.lang.Object object)
          Sets the database root.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_OPEN

public static final int NOT_OPEN
Open mode.

OPEN_READ_ONLY

public static final int OPEN_READ_ONLY
Open mode.

OPEN_READ_WRITE

public static final int OPEN_READ_WRITE
Open mode.
Constructor Detail

XL2Database

public XL2Database()
See open()
Method Detail

close

public void close()
Aborts open transactions, evicts database contents from memory, and unlocks the database. Any exceptions are passed to log()

closeException

public void closeException(java.lang.Exception x)
Deprecated. Replaced by log(Throwable)

See Also:
#log(Throwable)

create

public static XL2Database create(java.lang.String dbDir)
                          throws XL2Exception
Creates and returns a new XL2Database that will be open for read/write.
Parameters:
dbDir - XL2Database directory.
Throws:
XL2Exception - Wrapping any other exceptions.
See Also:
newDatabase(String)

getObjectInput

public java.io.ObjectInput getObjectInput(java.io.InputStream in)
                                   throws XL2Exception
Callback for subclasses to manage serialization.
Throws:
XL2Exception - Wrapping any internal exception such as IOExceptions.
See Also:
getObjectOutput(OutputStream)

getObjectOutput

public java.io.ObjectOutput getObjectOutput(java.io.OutputStream out)
                                     throws XL2Exception
Callback for subclasses to manage serialization.
Throws:
XL2Exception - Wrapping any internal exception such as IOExceptions.
See Also:
getObjectInput(InputStream)

getOpenMode

public int getOpenMode()
NOT_OPEN, OPEN_READ_ONLY, or OPEN_READ_WRITE

getRoot

public java.lang.Object getRoot()
Returns the database entry object.

log

public void log(java.lang.String message,
                java.lang.Throwable throwable)
Prints a timestamp, message and stack trace to "log.xl2" in the database directory. If logging causes an exception, System.err is used.
Parameters:
message - May be null.
exception - May be null.

newDatabase

public void newDatabase(java.lang.String dbDir)
                 throws XL2Exception
Creates a database that will be closed upon completion of this method.
Parameters:
dbDir - XL2Database directory.
Throws:
XL2Exception - Wrapping any other exceptions.

newTransaction

public XL2Transaction newTransaction()
Required to access and mutate XL2References and opened database instances.
Throws:
DatabaseNotOpenException -  

open

public void open(java.lang.String dbDir,
                 int mode)
          throws DatabaseLockedException,
                 XL2Exception
Opens the database with the given mode.
Parameters:
dbDir - The database directory.
mode - OPEN_READ_ONLY or OPEN_READ_WRITE
Throws:
DatabaseLockedException - If a lock file prevents opening.
XL2Exception - Wrapping exceptions such as IOExceptions.

setRoot

public void setRoot(java.lang.Object object)
Sets the database root.

Home