org.apache.ojb.odmg
Class ObjectEnvelope

java.lang.Object
  extended byorg.apache.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

Nested Class Summary
static class ObjectEnvelope.ImageExcetion
          Thrown if something unexpected is happen when handling the object images for state detection.
 
Constructor Summary
ObjectEnvelope(ObjectEnvelopeTable buffer, Identity oid, java.lang.Object obj, boolean isNewObject)
          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.
 void close()
           
 void doDelete()
           
 void doEvictFromCache()
           
 void doInsert()
           
 void doUpdate()
           
 java.util.Map getBeforeImage()
           
 PersistenceBroker getBroker()
           
 java.util.Map getCurrentImage()
           
 Identity getIdentity()
           
 org.apache.ojb.odmg.states.ModificationState getModificationState()
          returns the Modification-state.
 java.lang.Object getObject()
          returns the managed object.
 boolean hasChanged(PersistenceBroker broker)
          checks whether object and internal clone differ and returns true if so, returns false else.
 boolean isDeleted(Identity id)
          Checks if the object with the given identity has been deleted within the transaction.
 boolean isWriteLocked()
           
 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 refreshObjectIfNeeded(java.lang.Object obj)
           
 void refreshObjectImage()
           
 void setModificationState(org.apache.ojb.odmg.states.ModificationState newModificationState)
          set the Modification state to a new value.
 void setWriteLocked(boolean writeLocked)
           
 java.lang.String toString()
          returns a String representation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectEnvelope

public ObjectEnvelope(ObjectEnvelopeTable buffer,
                      Identity oid,
                      java.lang.Object obj,
                      boolean isNewObject)
Create a wrapper by providing an Object.

Method Detail

getBroker

public PersistenceBroker getBroker()

getBeforeImage

public java.util.Map getBeforeImage()

getCurrentImage

public java.util.Map getCurrentImage()

close

public void close()

refreshObjectImage

public void refreshObjectImage()

getIdentity

public Identity getIdentity()

getObject

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


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.

Returns:
java.lang.String

hasChanged

public boolean hasChanged(PersistenceBroker broker)
checks whether object and internal clone differ and returns true if so, returns false else.

Returns:
boolean

doUpdate

public void doUpdate()

doInsert

public void doInsert()

doDelete

public void doDelete()

doEvictFromCache

public void doEvictFromCache()

isWriteLocked

public boolean isWriteLocked()

setWriteLocked

public void setWriteLocked(boolean writeLocked)


(C) 2002 - 2004 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.3, 2005-04-2