org.apache.ojb.odmg
Class ObjectEnvelope

java.lang.Object
  extended by org.apache.ojb.odmg.ObjectEnvelope
All Implemented Interfaces:
java.io.Serializable, ObjectModification, Image.ImageListener

public class ObjectEnvelope
extends java.lang.Object
implements ObjectModification, Image.ImageListener

ObjectEnvelope is used during ODMG transactions as a wrapper for a persistent objects declaration

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.ojb.broker.util.ObjectModification
INSERT, UPDATE
 
Method Summary
 void addedOneToOne(ObjectReferenceDescriptor ord, java.lang.Object refObjOrProxy, Identity oid)
           
 void addedXToN(CollectionDescriptor cod, java.lang.Object refObjOrProxy, Identity oid)
           
 void afterAbort()
          Method declaration
 void afterCommit()
          Method declaration
 void beforeAbort()
          Method declaration
 void beforeCommit()
          We need to implement the Two-Phase Commit protocol.
 void cleanup(boolean reuse, boolean wasInsert)
          This method should be called before transaction ends to allow cleanup of used resources, e.g. remove proxy listener objects to avoid invoke of registered objects after tx end.
 void deletedOneToOne(ObjectReferenceDescriptor ord, java.lang.Object refObjOrProxy, Identity oid, boolean needsUnlink)
           
 void deletedXToN(CollectionDescriptor cod, java.lang.Object refObjOrProxy, Identity oid)
           
 void doDelete()
           
 void doEvictFromCache()
           
 void doInsert()
           
 void doUpdate()
           
 PersistenceBrokerInternal getBroker()
           
 Identity getIdentity()
           
 org.apache.ojb.odmg.states.ModificationState getModificationState()
          Returns the Modification-state.
 java.lang.Object getObject()
          Returns the managed materialized object.
 java.lang.Object getRealObject()
           
 boolean hasChanged(PersistenceBroker broker)
          For internal use only!
 boolean isDeleted(Identity id)
          Checks if the object with the given identity has been deleted within the transaction.
 boolean needsDelete()
          Returns true if the underlying Object needs an UPDATE statement, else returns false.
 boolean needsInsert()
          Returns true if the underlying Object needs an INSERT statement, else returns false.
 boolean needsUpdate()
          Returns true if the underlying Object needs an UPDATE statement, else returns false.
 Identity refreshIdentity()
          Replace the current with a new generated identity object and returns the old one.
 void refreshObjectIfNeeded(java.lang.Object obj)
           
 void setModificationState(org.apache.ojb.odmg.states.ModificationState newModificationState)
          set the Modification state to a new value.
 java.lang.String toString()
          returns a String representation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getBroker

public PersistenceBrokerInternal getBroker()
Specified by:
getBroker in interface Image.ImageListener

cleanup

public void cleanup(boolean reuse,
                    boolean wasInsert)
This method should be called before transaction ends to allow cleanup of used resources, e.g. remove proxy listener objects to avoid invoke of registered objects after tx end.


refreshIdentity

public Identity refreshIdentity()
Replace the current with a new generated identity object and returns the old one.


getIdentity

public Identity getIdentity()

getObject

public java.lang.Object getObject()
Returns the managed materialized object.


getRealObject

public java.lang.Object getRealObject()

refreshObjectIfNeeded

public void refreshObjectIfNeeded(java.lang.Object obj)

beforeCommit

public void beforeCommit()
We need to implement the Two-Phase Commit protocol. beginCommit is where we say if we can or cannot commit the transaction. At the begining however, we need to attain the after image so we can isolate everything. We should issue the call against the database at this point. If we get a SQL Exception, we should throw the org.odmg.TransactionAbortedException. We should also check to see if the object is TransactionAware. If so, we should give it a chance to kill the transaction before we toss it to the database.


afterCommit

public void afterCommit()
Method declaration


beforeAbort

public void beforeAbort()
Method declaration


afterAbort

public void afterAbort()
Method declaration


getModificationState

public org.apache.ojb.odmg.states.ModificationState getModificationState()
Returns the Modification-state.

Returns:
org.apache.ojb.server.states.ModificationState

needsInsert

public boolean needsInsert()
Returns true if the underlying Object needs an INSERT statement, else returns false.

Specified by:
needsInsert in interface ObjectModification

needsUpdate

public boolean needsUpdate()
Returns true if the underlying Object needs an UPDATE statement, else returns false.

Specified by:
needsUpdate in interface ObjectModification

needsDelete

public boolean needsDelete()
Returns true if the underlying Object needs an UPDATE statement, else returns false.


isDeleted

public boolean isDeleted(Identity id)
Checks if the object with the given identity has been deleted within the transaction.

Parameters:
id - The identity
Returns:
true if the object has been deleted
Throws:
PersistenceBrokerException

setModificationState

public void setModificationState(org.apache.ojb.odmg.states.ModificationState newModificationState)
set the Modification state to a new value. Used during state transitions.

Parameters:
newModificationState - org.apache.ojb.server.states.ModificationState

toString

public java.lang.String toString()
returns a String representation.

Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

hasChanged

public boolean hasChanged(PersistenceBroker broker)
For internal use only! Only call immediately before commit to guarantee that all changes can be detected (because this method cache the detected "change state" thus on eager call changes could be ignored). Checks whether object and internal clone differ and returns true if so, returns false else.

Returns:
boolean The result.

doUpdate

public void doUpdate()

doInsert

public void doInsert()

doDelete

public void doDelete()

doEvictFromCache

public void doEvictFromCache()

addedOneToOne

public void addedOneToOne(ObjectReferenceDescriptor ord,
                          java.lang.Object refObjOrProxy,
                          Identity oid)
Specified by:
addedOneToOne in interface Image.ImageListener

deletedOneToOne

public void deletedOneToOne(ObjectReferenceDescriptor ord,
                            java.lang.Object refObjOrProxy,
                            Identity oid,
                            boolean needsUnlink)
Specified by:
deletedOneToOne in interface Image.ImageListener

addedXToN

public void addedXToN(CollectionDescriptor cod,
                      java.lang.Object refObjOrProxy,
                      Identity oid)
Specified by:
addedXToN in interface Image.ImageListener

deletedXToN

public void deletedXToN(CollectionDescriptor cod,
                        java.lang.Object refObjOrProxy,
                        Identity oid)
Specified by:
deletedXToN in interface Image.ImageListener


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30