ojb.odmg
Class ObjectEnvelope

java.lang.Object
  |
  +--ojb.odmg.ObjectEnvelope
All Implemented Interfaces:
ObjectModification, java.io.Serializable

public class ObjectEnvelope
extends java.lang.Object
implements ObjectModification

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

See Also:
Serialized Form

Constructor Summary
ObjectEnvelope(java.lang.Object obj, TransactionImpl aTx)
          Create a wrapper by providing an Object.
 
Method Summary
 void afterAbort()
          Method declaration
 void afterCommit()
          Method declaration
 void beforeAbort()
          Method declaration
 void beforeCommit()
          We need to implement the Two-Phase Commit protocol.
 ModificationState getModificationState()
          returns the Modification-state.
 java.lang.Object getObject()
          returns the managed object.
 boolean hasChanged()
          checks whether object and internal clone differ and returns true if so, returns false else.
 void manage(java.lang.Object obj)
          Manage an object.
 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.
 void setModificationState(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectEnvelope

public ObjectEnvelope(java.lang.Object obj,
                      TransactionImpl aTx)
Create a wrapper by providing an Object.

Method Detail

manage

public void manage(java.lang.Object obj)
Manage an object.


getObject

public java.lang.Object getObject()
returns the managed object.


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 ModificationState getModificationState()
returns the Modification-state.

Returns:
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.


setModificationState

public void setModificationState(ModificationState newModificationState)
set the Modification state to a new value. Used during state transitions.

Parameters:
newModificationState - 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()
checks whether object and internal clone differ and returns true if so, returns false else.

Returns:
boolean


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04