goodsjpi
Class Metaobject

java.lang.Object
  extended bygoodsjpi.Metaobject
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BasicMetaobject

public abstract class Metaobject
extends java.lang.Object
implements java.io.Serializable

Metaobject is a base class for all Transaction + locking strategies. Each @see Persistent holds a MetaObject, which is called when the object is modified or read. This also means you can have different strategies for different classes, or even object if you wish. The default is PessimisticRepeatableRead
This class has abstract functions to handle loading and unloading of Object over the wire, and to handle Transactions. Specifically their failure strategies are implemented by different implementations of the various derived classes.
Most functions are implemented in the BasicMetaObject, but the begin/end * Access functions are implemented in the different derived classes.
JAVAMOP, the MetaObjectProtocol postprocessor inserts all necessary code to call MetaObject functions into the compiled byte code.

See Also:
Serialized Form

Field Summary
static int CONSTRUCTOR
          CONSTRUCTOR == 4 means wrapped method is constructor
static int EXCEPTION
          EXCEPTION == 8, means method is terminated by exception
static int MUTATOR
          MUTATOR == 1 , means object can be changed
static int VARIABLE
          VARIABLE == 2 , means access to non-self instance variable
 
Constructor Summary
Metaobject()
           
 
Method Summary
protected abstract  void beginReadAccess(Persistent obj)
          beginReadAccess is called when the read Access begins.
protected abstract  void beginWriteAccess(Persistent obj)
          beginWriteAccess is called when the write Access begins.
protected abstract  void commitObjectChanges(Persistent obj)
          commitObjectChanges is called during commitTransaction.
protected abstract  void destroyObject(Persistent obj)
          Destoroy all object references to make it possible to provide more unaccessible objects to GC
protected abstract  void endAccess(Persistent obj)
          endAccess is called when the (current) access/function has ended, and the object is not accessed anymore (the accesscount hits 0 ).
protected abstract  void forgetObject(Persistent obj)
          forgetObject is called when the objects finalize() is called, if it's opid is still valid.
protected abstract  void invalidateObject(Persistent obj)
          This method is asynchronously called by server storag agent when deterioration notification from server is received.
protected abstract  void loadObject(Persistent obj)
          loadObject is not so much the loading of the Object, ,but a notification thereof.
protected abstract  void makePersistent(Persistent obj, Persistent parent)
          makePersistent should do just that, make the obj persistent.
static void modify()
          modify provides MOP preprocessor with information that objects was (or will be) modified.
static void mutator()
          mutator is only hint to MOP preprocessor to consider method invoking Metaobject.mutator() as been mutator.
protected abstract  void notifyOnModification(Persistent obj, boolean status)
          Enable or disable notification on receving invalidation messages from the server for this object.
abstract  void postDaemon(java.lang.Object obj, int attr, boolean modified)
          Invocation of this postDaemon is inserted by MOP generator after each method invocation or object component access.
abstract  void preDaemon(java.lang.Object obj, int attr)
          Invocation of this preDaemon is inserted by MOP generator before each method invocation or object component access.
protected abstract  void preloadObject(Persistent obj, int size)
          preloadObject is called by Storage.read() when it's bytes have been received and just before they are copied into it's data member
protected abstract  void releaseObject(Persistent obj)
          releaseObject is called during a commitTransaction, for objects that have not been modified.
protected abstract  void undoObjectChanges(Persistent obj)
          undoObjectChanges is called during an abortTransaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MUTATOR

public static final int MUTATOR
MUTATOR == 1 , means object can be changed

See Also:
Constant Field Values

VARIABLE

public static final int VARIABLE
VARIABLE == 2 , means access to non-self instance variable

See Also:
Constant Field Values

CONSTRUCTOR

public static final int CONSTRUCTOR
CONSTRUCTOR == 4 means wrapped method is constructor

See Also:
Constant Field Values

EXCEPTION

public static final int EXCEPTION
EXCEPTION == 8, means method is terminated by exception

See Also:
Constant Field Values
Constructor Detail

Metaobject

public Metaobject()
Method Detail

preDaemon

public abstract void preDaemon(java.lang.Object obj,
                               int attr)
Invocation of this preDaemon is inserted by MOP generator before each method invocation or object component access. (Other database implementation call this method fetch(), to indicate that this causes the data of the Object to be fetched, if it's not already there)
The exact call that is inserted is super.metaobject.preDaemon(this, attr);

Parameters:
obj - The Object that is to be loaded. Really it is an instance of Persistent
attr - an int value, indicating the kind of access. An OR combination of the static flags below.

postDaemon

public abstract void postDaemon(java.lang.Object obj,
                                int attr,
                                boolean modified)
Invocation of this postDaemon is inserted by MOP generator after each method invocation or object component access.
The inserted code is something like: super.metaobject.postDaemon(this,attr,flag)

Parameters:
obj - an Object, or really a Persistent, that has been changed
attr - an int, indicating where/how the change happened. An OR combination of the static flags below
modified - a boolean value, indicating whether there has actually been a change. Because of exceptions it isn't always true.

mutator

public static void mutator()
mutator is only hint to MOP preprocessor to consider method invoking Metaobject.mutator() as been mutator. No actual code will appear in preprocessed class file.


modify

public static void modify()
modify provides MOP preprocessor with information that objects was (or will be) modified. No method invocation will appear in preprocessed code.


preloadObject

protected abstract void preloadObject(Persistent obj,
                                      int size)
preloadObject is called by Storage.read() when it's bytes have been received and just before they are copied into it's data member

Parameters:
obj - a Persistent that has been read (from the net)
size - an int, how many bytes the data member will hold

loadObject

protected abstract void loadObject(Persistent obj)
loadObject is not so much the loading of the Object, ,but a notification thereof. The object is really loaded by the Storage class (in prepare(obj) method) and after the deed is done, this method is called.

Parameters:
obj - a Persistent object that has been loaded

forgetObject

protected abstract void forgetObject(Persistent obj)
forgetObject is called when the objects finalize() is called, if it's opid is still valid. If all data were local, this would mean the object could be destroyed because it's not reachable anymore. But because more references may exist at the servers end, this basically reduces the reference count at the servers side.
Server side garbage collection will eventually reclaim the object space, if it really has become unreachable.

Parameters:
obj - a Persistent that has become locally unreachable

releaseObject

protected abstract void releaseObject(Persistent obj)
releaseObject is called during a commitTransaction, for objects that have not been modified.

Parameters:
obj - a Persistent to be released.

commitObjectChanges

protected abstract void commitObjectChanges(Persistent obj)
commitObjectChanges is called during commitTransaction.

Parameters:
obj - a Persistent object to commit

undoObjectChanges

protected abstract void undoObjectChanges(Persistent obj)
undoObjectChanges is called during an abortTransaction.

Parameters:
obj - a Persistent value

makePersistent

protected abstract void makePersistent(Persistent obj,
                                       Persistent parent)
makePersistent should do just that, make the obj persistent.

Parameters:
obj - a Persistent object to make persistent (or prepare for that)
parent - a Persistent object "close" to the obj. May be used , as by BasicMetaObject, to place the obj in the same storage as parent.

beginReadAccess

protected abstract void beginReadAccess(Persistent obj)
beginReadAccess is called when the read Access begins. It is called from the (auto generated) preDeamon (in BasicMataObject) if the Mutator flag is set.
Different implementations of this function can be found in the subclasses and by eg locking or not locking the Object provide different strategies.

Parameters:
obj - a Persistent object that is about to be read.

beginWriteAccess

protected abstract void beginWriteAccess(Persistent obj)
beginWriteAccess is called when the write Access begins. It is called from the (autogenerated) preDeamon (in BasicMataObject) if the Mutator flag is not set.
Different implementations of this function can be found in the subclasses and by eg locking or not locking the Object provide different strategies.

Parameters:
obj - a Persistent object that is about to be read.

endAccess

protected abstract void endAccess(Persistent obj)
endAccess is called when the (current) access/function has ended, and the object is not accessed anymore (the accesscount hits 0 ). It is called from the (autogenerated) postDeamon in BasiMetaObject. Different implementations of this function can be found in the subclasses and by eg locking or not locking the Object provide different strategies.

Parameters:
obj - a Persistent object that is about to be read.

invalidateObject

protected abstract void invalidateObject(Persistent obj)
This method is asynchronously called by server storag agent when deterioration notification from server is received.

Parameters:
obj - a Persistent object to be invalidated.

destroyObject

protected abstract void destroyObject(Persistent obj)
Destoroy all object references to make it possible to provide more unaccessible objects to GC

Parameters:
obj - a Persistent value

notifyOnModification

protected abstract void notifyOnModification(Persistent obj,
                                             boolean status)
Enable or disable notification on receving invalidation messages from the server for this object.

Parameters:
obj - a Persistent to make the notification changes for
status - a boolean, whether notifications are used for this object