Class JOP.util.RefDB
All Packages  Class Hierarchy  This Package  Previous  Next  Index  Home

Class JOP.util.RefDB

java.lang.Object
   |
   +----JOP.util.RefDB

public class RefDB
extends Object
implements Persistable
RefDB offers the ability to have a reference to an object that is read from the persistent store only when it is referenced. This can improve performance, especially when an object contains references to complex objects that are only occasionally traversed.
    public class MyClass
    {
        RefDB   relatedObject ;
        void setRelatedObject( AnotherObject o )
        {
            relatedObject.setObject( o ) ;
        }
        AnotherObject getRelatedObject() throws Exception
        {
            return (AnotherObject)relatedObject.getObject() ;
        }
    }
    
In the above example the instances of MyClass can be saved and restored as needed. When an instance of MyClass is restored the instance of AnotherObject (stored in the 'relatedObject' RefDB) is not read from the persistent database until the 'getRelatedObject()' method is called.

Constructor Index

 o RefDB()
All objects that implement JOP.persist.Persistable require a public constructor that takes no arguments.
 o RefDB(Object)
Initialise the reference with an existing object.

Method Index

 o defineObject(PersistController)
Defines a RefDB as an object identifier (ie a long)
 o getObject()
Get the referenced object.
 o setObject(Object)
Change the object referenced.
 o streamIn(PersistController)
Called by the PersistManager.
 o streamOut(PersistController)
Called by the PersistManager.
 o toString()

Constructors

 o RefDB
  public RefDB()
All objects that implement JOP.persist.Persistable require a public constructor that takes no arguments.
 o RefDB
  public RefDB(Object o)
Initialise the reference with an existing object.

Methods

 o setObject
  public void setObject(Object o)
Change the object referenced. The referenced object will be saved when the object containing the reference is saved.
 o toString
  public String toString()
Overrides:
toString in class Object
 o getObject
  public Object getObject() throws Exception
Get the referenced object. If the referenced object is not in memory then it will be read from the persistent store. Returns 'null' if no object was stored in the RefDB.

 o streamIn
  public synchronized void streamIn(PersistController c) throws Exception
Called by the PersistManager. Required to implement JOP.persist.Persistable
 o streamOut
  public synchronized void streamOut(PersistController c) throws Exception
Called by the PersistManager. Required to implement JOP.persist.Persistable
 o defineObject
  public void defineObject(PersistController c) throws Exception
Defines a RefDB as an object identifier (ie a long)

All Packages  Class Hierarchy  This Package  Previous  Next  Index  Home