org.apache.ojb.otm.core
Class ConcreteEditingContext

java.lang.Object
  extended byorg.apache.ojb.otm.core.ConcreteEditingContext
All Implemented Interfaces:
EditingContext, MaterializationListener, ObjectCache

public class ConcreteEditingContext
extends java.lang.Object
implements EditingContext, MaterializationListener, ObjectCache

Concrete implementation of EditingContext.

Author:
Raghu Rajah
See Also:
EditingContext

Constructor Summary
ConcreteEditingContext(Transaction tx, PersistenceBroker pb)
           
 
Method Summary
 void afterMaterialization(IndirectionHandler handler, java.lang.Object object)
          this callback is invoked after an Object is materialized within an IndirectionHandler.
 void beforeMaterialization(IndirectionHandler handler, Identity oid)
          this callback is invoked before an Object is materialized within an IndirectionHandler.
 void cache(Identity oid, java.lang.Object obj)
          makes object obj persistent to the Objectcache under the key oid.
 void checkpoint()
          Writes all changes in this context into the persistent store.
 void clear()
          clear the ObjectCache.
 void commit()
          Commit this context into the persistent store.
 void deletePersistent(Identity oid, java.lang.Object object)
           
 java.util.Collection getAllObjectsInContext()
           
 void insert(Identity oid, java.lang.Object obj, int lock)
          Insert the given object into the EditingContext, acquiring the specified lock.
 java.lang.Object lookup(Identity oid)
          Lookup object with the given oid in the Context.
 State lookupState(Identity oid)
          lookup the state of an object, given the oid, in the context
 void remove(Identity oid)
          Remove a managed object from the management of this EditingContext.
 void rollback()
          Rollback all changes made during this transaction.
 void setState(Identity oid, State state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcreteEditingContext

public ConcreteEditingContext(Transaction tx,
                              PersistenceBroker pb)
Method Detail

insert

public void insert(Identity oid,
                   java.lang.Object obj,
                   int lock)
            throws LockingException
Description copied from interface: EditingContext
Insert the given object into the EditingContext, acquiring the specified lock.

Specified by:
insert in interface EditingContext
Parameters:
oid - the identity of the object to be inserted
obj - the object to insert
lock - the lock to be acquired.
Throws:
LockingException - thrown by the Lock Manager to avoid deadlocks. The insertion could be re-attempted if the lock fails.
See Also:
EditingContext.insert(Identity, Object, int)

remove

public void remove(Identity oid)
Description copied from interface: EditingContext
Remove a managed object from the management of this EditingContext. All edits on the object will be lost. All locks kept by this object will be released.

Specified by:
remove in interface EditingContext
Parameters:
oid - the Identity of the object to be removed from this context.
See Also:
EditingContext.remove(Identity)

deletePersistent

public void deletePersistent(Identity oid,
                             java.lang.Object object)
                      throws LockingException
Throws:
LockingException

lookup

public java.lang.Object lookup(Identity oid)
Description copied from interface: EditingContext
Lookup object with the given oid in the Context.

Specified by:
lookup in interface EditingContext
Parameters:
oid - the oid of the object to lookup
See Also:
EditingContext.lookup(Identity)

lookupState

public State lookupState(Identity oid)
                  throws LockingException
Description copied from interface: EditingContext
lookup the state of an object, given the oid, in the context

Specified by:
lookupState in interface EditingContext
Parameters:
oid -
Returns:
the state of that object in the context, null if the object is not in the context
Throws:
LockingException
See Also:
EditingContext.lookupState(Identity)

setState

public void setState(Identity oid,
                     State state)
Specified by:
setState in interface EditingContext
See Also:
EditingContext.setState(Identity, State)

getAllObjectsInContext

public java.util.Collection getAllObjectsInContext()
Specified by:
getAllObjectsInContext in interface EditingContext

beforeMaterialization

public void beforeMaterialization(IndirectionHandler handler,
                                  Identity oid)
Description copied from interface: MaterializationListener
this callback is invoked before an Object is materialized within an IndirectionHandler.

Specified by:
beforeMaterialization in interface MaterializationListener
Parameters:
handler - the invoking handler
oid - the identity of the object to be materialized

afterMaterialization

public void afterMaterialization(IndirectionHandler handler,
                                 java.lang.Object object)
Description copied from interface: MaterializationListener
this callback is invoked after an Object is materialized within an IndirectionHandler.

Specified by:
afterMaterialization in interface MaterializationListener
Parameters:
handler - the invoking handler
object - the materialized Object

commit

public void commit()
            throws TransactionAbortedException
Commit this context into the persistent store. The EditingContext is not usable after a commit.

Throws:
TransactionAbortedException

checkpoint

public void checkpoint()
                throws TransactionAbortedException
Writes all changes in this context into the persistent store.

Throws:
TransactionAbortedException

rollback

public void rollback()
Rollback all changes made during this transaction. The EditingContext is not usable after a rollback.


cache

public void cache(Identity oid,
                  java.lang.Object obj)
Description copied from interface: ObjectCache
makes object obj persistent to the Objectcache under the key oid.

Specified by:
cache in interface ObjectCache

clear

public void clear()
Description copied from interface: ObjectCache
clear the ObjectCache.

Specified by:
clear in interface ObjectCache


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14