org.sourceforge.jemm.client
Class LifecycleListenerImpl

java.lang.Object
  extended by org.sourceforge.jemm.client.LifecycleListenerImpl
All Implemented Interfaces:
ConstructorListener, MethodListener, TypeConstructorListener

public class LifecycleListenerImpl
extends java.lang.Object
implements ConstructorListener, MethodListener, TypeConstructorListener

A lifecycle listener which manages the state of the JEMMObject, such as the object values, the JEMM ID and the ShadowObject.

 
Hierarchy of class constructors
-------------------------------

pre - stack the class
super -> 
        pre - stack the class
        super
        begin - associated the the object with stacked class

        end/fail
begin
end/fail
---
END/FAIL ALGORITHM
pop
if(peek is a class in the hierarchy of current OBJ AND has no object)
        do nothing
else //must be a different object on the stack
        synchronize
---


Nested Construction of objects
------------------------------

pre
super
begin
        pre
        begin
        end/fail
end/fail

Author:
Paul Keeble

Constructor Summary
LifecycleListenerImpl(ObjectDatabase db, StackTracer st, LockTracer lt)
           
 
Method Summary
 void beginConstructor(LifecycleEvent e)
          Register the class of the object.
 void beginLock(LockEvent e)
          Acquire a lock in the database
 void endConstructor(LifecycleEvent e)
          Synchronise the state of the Object with the database and clear any object fields of their values into the ShadowData.
 void endLock(LockEvent e)
          Release a lock in the database
 void entityEntered(MethodEvent e)
          Register the class Setup the required object fields that will be used by the method if it is the first time a method is entered.
 void entityExited(MethodEvent e)
          Captures the object state and saves it.
 void failedConstruction(LifecycleEvent e)
          Removes the context for the constructor from the stack.
 void preConstructor(java.lang.String className)
          Called before the call to super().
 void setObjectCreator(JEMMObjectCreator creator)
           
 void typeConstructed(JEMMType typeInstance)
          Notification by a type instance that it has been created via the user 'new' method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleListenerImpl

public LifecycleListenerImpl(ObjectDatabase db,
                             StackTracer st,
                             LockTracer lt)
Method Detail

preConstructor

public void preConstructor(java.lang.String className)
Description copied from interface: ConstructorListener
Called before the call to super().

Specified by:
preConstructor in interface ConstructorListener
Parameters:
className - The name of the class from which the call is being called

beginConstructor

public void beginConstructor(LifecycleEvent e)
Register the class of the object. Gets the ID for a new object and sets it back to the original object along with the ShadowObject. If the constructor for the same object but a super class is called this should be ignored and no further registrations or IDs retrieved.

Specified by:
beginConstructor in interface ConstructorListener
Parameters:
e - The event

setObjectCreator

public void setObjectCreator(JEMMObjectCreator creator)

typeConstructed

public void typeConstructed(JEMMType typeInstance)
Description copied from interface: TypeConstructorListener
Notification by a type instance that it has been created via the user 'new' method. Should be called by the type before any internal initialisation using the shadow object is done.

Specified by:
typeConstructed in interface TypeConstructorListener
Parameters:
typeInstance - The instance that has been created.

failedConstruction

public void failedConstruction(LifecycleEvent e)
Removes the context for the constructor from the stack.

Specified by:
failedConstruction in interface ConstructorListener

endConstructor

public void endConstructor(LifecycleEvent e)
Synchronise the state of the Object with the database and clear any object fields of their values into the ShadowData. The fields should only be saved/cleared if the Object is being exited and hence this is the last endConstructor being called for this Objects creation.

Specified by:
endConstructor in interface ConstructorListener
Parameters:
e - The event

beginLock

public void beginLock(LockEvent e)
Acquire a lock in the database

Specified by:
beginLock in interface MethodListener

endLock

public void endLock(LockEvent e)
Release a lock in the database

Specified by:
endLock in interface MethodListener

entityEntered

public void entityEntered(MethodEvent e)
Register the class Setup the required object fields that will be used by the method if it is the first time a method is entered. If an attribute has already been setup then the value (even if it has changed) is left in place. Track the call stack to allow the exit method to determine if it can save the values.

Specified by:
entityEntered in interface MethodListener
Parameters:
e - The event

entityExited

public void entityExited(MethodEvent e)
Captures the object state and saves it. This is only done if the Object is actually being exited by this call, if it is not then the fields should be left in tact and no storage of attributes done until this is called the last time for a method entry. Release all the JEMMObject fields that were initialised by entityEntered

Specified by:
entityExited in interface MethodListener
Parameters:
e - The event


Copyright © 2009. All Rights Reserved.