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.
-
RefDB()
- All objects that implement JOP.persist.Persistable require a public
constructor that takes no arguments.
-
RefDB(Object)
- Initialise the reference with an existing object.
-
defineObject(PersistController)
- Defines a RefDB as an object identifier (ie a long)
-
getObject()
- Get the referenced object.
-
setObject(Object)
- Change the object referenced.
-
streamIn(PersistController)
- Called by the PersistManager.
-
streamOut(PersistController)
- Called by the PersistManager.
-
toString()
-
RefDB
public RefDB()
- All objects that implement JOP.persist.Persistable require a public
constructor that takes no arguments.
RefDB
public RefDB(Object o)
- Initialise the reference with an existing object.
setObject
public void setObject(Object o)
- Change the object referenced. The referenced object will be saved when the
object containing the reference is saved.
toString
public String toString()
- Overrides:
- toString in class Object
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.
streamIn
public synchronized void streamIn(PersistController c) throws Exception
- Called by the PersistManager. Required to implement JOP.persist.Persistable
streamOut
public synchronized void streamOut(PersistController c) throws Exception
- Called by the PersistManager. Required to implement JOP.persist.Persistable
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