org.apache.ojb.otm.core
Class ConcreteEditingContext

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

public class ConcreteEditingContext
extends 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, Object cacheObject)
          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, Object obj)
          Used to cache objects by it's Identity.
 boolean cacheIfNew(Identity oid, Object obj)
           
 void checkpoint()
          Writes all changes in this context into the persistent store.
 void clear()
          Clear the cache.
 void commit()
          Commit this context into the persistent store.
 boolean contains(Identity oid)
           
 void deletePersistent(Identity oid, Object userObject)
           
 Collection getAllObjectsInContext()
           
 void insert(Identity oid, Object userObject, int lock)
          Insert the given object into the EditingContext, acquiring the specified lock.
 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 refresh(Identity oid, Object object)
          Rollback all changes made during this transaction to the given object.
 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,
                   Object userObject,
                   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
userObject - the object to insert, for user operations
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 ObjectCache
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,
                             Object userObject)
                      throws LockingException
Throws:
LockingException

lookup

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

Specified by:
lookup in interface ObjectCache
Specified by:
lookup in interface EditingContext
Parameters:
oid - the oid of the object to lookup
Returns:
The cached object or null if no matching object for specified Identity is found.
See Also:
EditingContext.lookup(Identity)

contains

public boolean contains(Identity oid)

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
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 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,
                                 Object cacheObject)
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
cacheObject - 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.


refresh

public void refresh(Identity oid,
                    Object object)
Rollback all changes made during this transaction to the given object.

Specified by:
refresh in interface EditingContext

cache

public void cache(Identity oid,
                  Object obj)
Description copied from interface: ObjectCache
Used to cache objects by it's Identity.

Specified by:
cache in interface ObjectCache
Parameters:
oid - Identity of the object to cache.
obj - The object to cache.

cacheIfNew

public boolean cacheIfNew(Identity oid,
                          Object obj)

clear

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

Specified by:
clear in interface ObjectCache


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.