Interface JOP.persist.Persistable
All Packages  Class Hierarchy  This Package  Previous  Next  Index  Home

Interface JOP.persist.Persistable

public interface Persistable
extends Object
An interface implemented by classes that are saved or read by a PeristManager.

Clases that implement Persistable must:

The PersistManager works by invoking each of these methods to define the structure of a class and to marshall the objects slots to/from the PersistManager. PersistManager's use PeristController to do the actual work.

You do not need to implement JOP.persist.Persistable to allow your class to be saved and restored. You can also create a custom marshall class or rely upon the automatic (native) marshalling.

The following is an example of the use of the Persistable interface:

    package COM.mycompany ;
    import  JOP.persist.Persistable ;
    import  JOP.persist.PersistController ;
    public MyClass extends AnotherClass implements Persistable
    {
        private     char    c1 ;
        private     String  s2[] ;
        public MyClass()
        {
            c1 = 'A' ;
            s1 = new String[1] ;
            s1[0] = "Hello world" ;
        }
        public void defineObject( PersistController c ) throws Exception
        {
            super.defineObject( c ) ;
            c.defineSlot("COM.mycompany.MyClass", "c1", PersistController.TYPE_CHARACTER ) ;
            c.defineSlotArray("COM.mycompany.MyClass", "s2", PersistController.TYPE_STRING ) ;
        }
        public void streamOut( PersistController c ) throws Exception
        {
            super.streamOut( c ) ;
            c.put( "c1", c1 ) ;
            c.put( "s2", s2 ) ;
        }
        public void streamIn( PersistController c ) throws Exception
        {
            super.streamIn( c ) ;
            c1 = c.charValue( "c1" ) ;
            s2 = c.getStringArray( "s2" ) ;
        }
    }
    
See Also:
PersistController, PersistMarshall

Method Index

 o defineObject(PersistController)
An object that implements Persistable must define this method.
 o streamIn(PersistController)
This method must be implemented by all objects that implement the Persistable interface.
 o streamOut(PersistController)
This method must be implemented by all objects that implement the Persistable interface.

Methods

 o defineObject
  public abstract void defineObject(PersistController c) throws Exception
An object that implements Persistable must define this method. This method is called by the PersistManager the first time an object of this class is to be saved or retrieved. The purpose of this method is to call-back to the PersistController to define the object's slots.

Make sure the superclasses defineObject() method is called before the body of this method.

Make sure the class name passed to defineSlot is the fully qualified classname.

Parameters:
c - passed by the PersistManager
See Also:
PersistManager

 o streamOut
  public abstract void streamOut(PersistController c) throws Exception
This method must be implemented by all objects that implement the Persistable interface. The method is called by the PersistManager when the object is being saved to the persistent database.

Call the superclasses streamOut() method before the bofy of this method.

Parameters:
c - passed by the PersistManager
See Also:
PersistManager

 o streamIn
  public abstract void streamIn(PersistController c) throws Exception
This method must be implemented by all objects that implement the Persistable interface. The method is called by the PersistManager when the object is being retrieved from the persistent database.

Call the superclasses streamIn() method before the bofy of this method.

Parameters:
c - passed by the PersistManager
See Also:
PersistManager


All Packages  Class Hierarchy  This Package  Previous  Next  Index  Home