org.apache.jdo.impl.fostore
Class DBInfo

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.DBInfo
All Implemented Interfaces:
org.netbeans.mdr.persistence.Streamable

public class DBInfo
extends java.lang.Object
implements org.netbeans.mdr.persistence.Streamable

This class represents the information about the contents of the store itself which must be durable across JVMs.

This class is public so that it can be used as a Streamable and stored in the database.

Author:
Dave Bristor

Nested Class Summary
(package private)  class DBInfo.DBClassIterator
           
(package private)  class DBInfo.ExtentIterator
           
 
Field Summary
private static int DBCLASS_UID
           
private static OID dbInfoOID
          This is the OID of the DBInfo.
private  java.util.HashSet dirtyExtents
          Set of extents that are currently modified and need to be stored when a transaction commits.
private static int EXTENT_UID
           
private static int FIRST_CLASS_UID
           
private  FOStoreDatabase fodb
           
(package private) static org.apache.commons.logging.Log logger
          Logger
private static I18NHelper msg
          I18N support.
private  CLID nextCLID
           
private  java.util.ArrayList nextUIDs
           
private static int SUBCLASS_UID
           
 
Constructor Summary
  DBInfo()
           
(package private) DBInfo(FOStoreDatabase fodb)
          Create a new instance.
 
Method Summary
(package private)  void clearDirtyExtents()
          Causes this DBInfo to forget about the dirty state of all extents marked as dirty since the last time storeDirtyExtents was invoked.
(package private) static DBInfo get(FOStoreDatabase db)
           
(package private)  java.util.Iterator getDBClasses()
           
(package private) static OID getDBClassOID(CLID clid)
          Provides the OID which represents the given CLID's class.
(package private) static OID getExtentOID(CLID clid)
          Provides the OID which represents extent of instances of objects all of which have the given CLID.
(package private)  java.util.Iterator getExtents()
           
(package private) static OID getSubclassSetOID(CLID clid)
          Provides the OID which at which is stored the ArrayList of the CLIDs of of subclasses of the class corresponding to the CLID.
(package private)  boolean makeExtentDirty(DBExtent e)
          Marks the given extent as dirty, so that it can later be stored.
(package private)  OID newClassOID()
          Provide a new OID to represent a class.
(package private)  OID newInstanceOID(CLID clid)
          Provide a new OID for the given CLID.
 void read(java.io.InputStream is)
           
(package private)  void store()
           
(package private)  void storeDirtyExtents()
          Stores all extents that have been marked dirty since the last time this method was invoked.
 java.lang.String toString()
          Returns a human-readable description of this DBInfo.
 void write(java.io.OutputStream os)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fodb

private FOStoreDatabase fodb

dbInfoOID

private static final OID dbInfoOID
This is the OID of the DBInfo.


nextCLID

private CLID nextCLID

DBCLASS_UID

private static final int DBCLASS_UID
See Also:
Constant Field Values

SUBCLASS_UID

private static final int SUBCLASS_UID
See Also:
Constant Field Values

EXTENT_UID

private static final int EXTENT_UID
See Also:
Constant Field Values

FIRST_CLASS_UID

private static final int FIRST_CLASS_UID
See Also:
Constant Field Values

nextUIDs

private java.util.ArrayList nextUIDs

dirtyExtents

private java.util.HashSet dirtyExtents
Set of extents that are currently modified and need to be stored when a transaction commits.


msg

private static final I18NHelper msg
I18N support.


logger

static final org.apache.commons.logging.Log logger
Logger

Constructor Detail

DBInfo

DBInfo(FOStoreDatabase fodb)
Create a new instance. Use this constructor when creating an instance for a brand new database (as opposed to an existing database, in which we use the Streamable-required default constructor, below).

Parameters:
fodb - The FOStoreDatabase instance.
Throws:
FOStoreFatalInternalException - Thrown when there is an attempt to create a second DBInfo within a store.

DBInfo

public DBInfo()
Method Detail

store

void store()
     throws FOStoreDatabaseException
Throws:
FOStoreDatabaseException

get

static DBInfo get(FOStoreDatabase db)
           throws FOStoreDatabaseException
Throws:
FOStoreDatabaseException

newClassOID

OID newClassOID()
Provide a new OID to represent a class. Use this when activating a class.

Returns:
An OID for a class just now known to this store.

getDBClassOID

static OID getDBClassOID(CLID clid)
Provides the OID which represents the given CLID's class.

Parameters:
clid - The CLID for which the corresponding OID is needed.
Returns:
The OID of the CLID.

getSubclassSetOID

static OID getSubclassSetOID(CLID clid)
Provides the OID which at which is stored the ArrayList of the CLIDs of of subclasses of the class corresponding to the CLID.

Parameters:
clid - The CLID for which the corresponding OID is needed.
Returns:
The OID of the ArrayList of CLIDs of the given CLID's subclasses.

getExtentOID

static OID getExtentOID(CLID clid)
Provides the OID which represents extent of instances of objects all of which have the given CLID.

Parameters:
clid - CLID of extent to return.
Returns:
OID of the extent of instances of CLID's class.

getDBClasses

java.util.Iterator getDBClasses()
Returns:
Iterator of DBClass objects

makeExtentDirty

boolean makeExtentDirty(DBExtent e)
Marks the given extent as dirty, so that it can later be stored.


storeDirtyExtents

void storeDirtyExtents()
                 throws FOStoreDatabaseException
Stores all extents that have been marked dirty since the last time this method was invoked.

Throws:
FOStoreDatabaseException

clearDirtyExtents

void clearDirtyExtents()
Causes this DBInfo to forget about the dirty state of all extents marked as dirty since the last time storeDirtyExtents was invoked.


getExtents

java.util.Iterator getExtents()
Returns:
Iterator of DBExtent objects

newInstanceOID

OID newInstanceOID(CLID clid)
Provide a new OID for the given CLID. Use this when creating an instance in the store. The OID will have its CLID part as per the given CLID, and its UID part one greater than the last-created newInstanceOID.

Parameters:
clid - CLID for which a new OID is needed.
Returns:
An OID for the CLID.
Throws:
FOStoreFatalInternalException - thrown if the CLID is invalid.

toString

public java.lang.String toString()
Returns a human-readable description of this DBInfo. If system property "dbinfo.shortname" is true, then the description includes the name of the database (e.g. 'foo'), otherwise it includes the complete pathname of the database (e.g. '/bleem/foo').


write

public void write(java.io.OutputStream os)
           throws org.netbeans.mdr.persistence.StorageException
Specified by:
write in interface org.netbeans.mdr.persistence.Streamable
Throws:
org.netbeans.mdr.persistence.StorageException

read

public void read(java.io.InputStream is)
          throws org.netbeans.mdr.persistence.StorageException
Specified by:
read in interface org.netbeans.mdr.persistence.Streamable
Throws:
org.netbeans.mdr.persistence.StorageException