public class TransactionImpl extends java.lang.Object implements Transaction, MaterializationListener, org.apache.ojb.broker.util.configuration.Configurable, CollectionProxyListener, TransactionExt
READ, UPGRADE, WRITE
Constructor and Description |
---|
TransactionImpl(ImplementationImpl implementation)
Creates new Transaction
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort and close the transaction.
|
void |
afterLoading(CollectionProxyDefaultImpl colProxy)
Remove colProxy from list of pending collections and
register its contents with the transaction.
|
void |
afterMaterialization(IndirectionHandler handler,
java.lang.Object materializedObject)
this callback is invoked after an Object is materialized
within an IndirectionHandler.
|
void |
beforeLoading(CollectionProxyDefaultImpl colProxy)
noop -- here for interface
|
void |
beforeMaterialization(IndirectionHandler handler,
Identity oid)
this callback is invoked before an Object is materialized
within an IndirectionHandler.
|
void |
begin()
Start a transaction.
|
void |
checkpoint()
Commit the transaction, but reopen the transaction, retaining all locks.
|
void |
clearRegistrationList()
Clears the list of processed object Identity.
|
void |
commit()
Commit and close the transaction.
|
void |
configure(org.apache.ojb.broker.util.configuration.Configuration config)
configure an object using the Configuration pConfig
|
void |
deletePersistent(RuntimeObject rt) |
void |
flush()
Calling
flush flushes persistent object modifications
made within the ODMG transaction since the last checkpoint to the underlying
database transaction, but does commit the database transaction. |
DatabaseImpl |
getAssociatedDatabase()
Returns the associated database
|
PersistenceBroker |
getBroker() |
PersistenceBrokerInternal |
getBrokerInternal()
Gets the broker associated with the transaction.
|
java.lang.String |
getGUID() |
ImplementationImpl |
getImplementation() |
NamedRootsMap |
getNamedRootsMap() |
java.lang.Object |
getObjectByIdentity(Identity id)
Get object by identity.
|
java.util.ArrayList |
getRegistrationList()
Returns an empty List for registration of processed object Identity.
|
boolean |
isDeleted(Identity id)
Checks if the object with the given
Identity
has been deleted within the transaction using
Database.deletePersistent(Object) or TransactionExt.markDelete(Object) . |
boolean |
isImplicitLocking()
Returns true if implicite locking is enabled.
|
boolean |
isOpen()
Determine whether the transaction is open or not.
|
boolean |
isOrdering()
Return true if the OJB ordering algorithm is enabled.
|
void |
join()
Attach the caller's thread to this
Transaction and detach the
thread from any former Transaction the thread may have been
associated with. |
void |
leave()
Detach the caller's thread from this
Transaction , but do not
attach the thread to another Transaction . |
void |
lock(java.lang.Object obj,
int lockMode)
Upgrade the lock on the given object to the given lock mode.
|
void |
lockAndRegister(RuntimeObject rtObject,
int lockMode,
boolean cascade,
java.util.List registeredObjects)
Lock and register the specified object, make sure that when cascading locking and register
is enabled to specify a List to register the already processed object Identiy.
|
void |
lockAndRegister(RuntimeObject rtObject,
int lockMode,
java.util.List registeredObjects)
Lock and register the specified object, make sure that when cascading locking and register
is enabled to specify a List to register the already processed object Identiy.
|
void |
markDelete(java.lang.Object anObject)
Marks an object for deletion without
locking the object.
|
void |
markDirty(java.lang.Object anObject)
Marks an object as dirty without
locking the object.
|
void |
setCascadingDelete(java.lang.Class target,
boolean doCascade)
Allows to change the cascading delete behavior of all references of the
specified class while this transaction is in use - if the specified class is an
interface, abstract class or class with "extent" classes the cascading flag will
be propagated.
|
void |
setCascadingDelete(java.lang.Class target,
java.lang.String referenceField,
boolean doCascade)
Allows to change the cascading delete behavior of the specified reference
of the target class while this transaction is in use.
|
void |
setImplicitLocking(boolean value)
This method can be used to activate or deactivate the implicit
locking mechanism for the current transaction.
|
void |
setOrdering(boolean ordering)
Allows to enable/disable the OJB persistent object ordering algorithm.
|
boolean |
tryLock(java.lang.Object obj,
int lockMode)
Upgrade the lock on the given object to the given lock mode.
|
public TransactionImpl(ImplementationImpl implementation)
implementation
- The odmg Implementation classpublic ImplementationImpl getImplementation()
public NamedRootsMap getNamedRootsMap()
public DatabaseImpl getAssociatedDatabase()
public boolean isOpen()
begin
, but a subsequent call to
either commit
or abort
has not been made.isOpen
in interface Transaction
public void join()
Transaction
and detach the
thread from any former Transaction
the thread may have been
associated with.join
in interface Transaction
public void lock(java.lang.Object obj, int lockMode) throws LockNotGrantedException
lock
in interface Transaction
obj
- object to acquire a lock on.lockMode
- lock mode to acquire. The lock modes
are READ
, UPGRADE
, and WRITE
.LockNotGrantedException
- Description of Exceptionpublic java.util.ArrayList getRegistrationList()
public void clearRegistrationList()
public void lockAndRegister(RuntimeObject rtObject, int lockMode, java.util.List registeredObjects)
public void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade, java.util.List registeredObjects)
public void leave()
Transaction
, but do not
attach the thread to another Transaction
.leave
in interface Transaction
public void checkpoint()
checkpoint
commits persistent object modifications
made within the transaction since the last checkpoint to the database. The
transaction retains all locks it held on those objects at the time the
checkpoint was invoked.checkpoint
in interface Transaction
public void flush()
TransactionExt
Calling flush
flushes persistent object modifications
made within the ODMG transaction since the last checkpoint to the underlying
database transaction, but does commit the database transaction.
The ODMG transaction retains all locks it held on those objects at the time the flush
was invoked.
Transaction.checkpoint()
.flush
in interface TransactionExt
TransactionExt.flush()
public void markDelete(java.lang.Object anObject)
TransactionExt
markDelete
in interface TransactionExt
anObject
- Object to be markedTransactionExt.markDelete(java.lang.Object)
public void deletePersistent(RuntimeObject rt)
public void markDirty(java.lang.Object anObject)
TransactionExt
markDirty
in interface TransactionExt
anObject
- Object to be markedTransactionExt.markDirty(java.lang.Object)
public boolean isDeleted(Identity id)
TransactionExt
Identity
has been deleted within the transaction using
Database.deletePersistent(Object)
or TransactionExt.markDelete(Object)
.isDeleted
in interface TransactionExt
id
- The identity of the object.TransactionExt.isDeleted(org.apache.ojb.broker.Identity)
public boolean tryLock(java.lang.Object obj, int lockMode)
tryLock
is the same as lock
except it returns a boolean
indicating whether the lock was granted instead of generating an exception.tryLock
in interface Transaction
obj
- Description of ParameterlockMode
- Description of ParameterUPGRADE
, and WRITE
.public void commit()
commit
commits to
the database all persistent object modifications within the transaction and
releases any locks held by the transaction. A persistent object
modification is an update of any field of an existing persistent object, or
an update or creation of a new named object in the database. If a
persistent object modification results in a reference from an existing
persistent object to a transient object, the transient object is moved to
the database, and all references to it updated accordingly. Note that the
act of moving a transient object to the database may create still more
persistent references to transient objects, so its referents must be
examined and moved as well. This process continues until the database
contains no references to transient objects, a condition that is guaranteed
as part of transaction commit. Committing a transaction does not remove
from memory transient objects created during the transaction.
The updateObjectList contains a list of all objects for which this transaction
has write privledge to. We need to update these objects.commit
in interface Transaction
public void abort()
abort
in interface Transaction
public void begin()
begin
multiple times on the same
transaction object, without an intervening call to commit
or
abort
, causes the exception
TransactionInProgressException
to be thrown on the second and
subsequent calls. Operations executed before a transaction has been opened,
or before reopening after a transaction is aborted or committed, have
undefined results; these may throw a
TransactionNotInProgressException
exception.begin
in interface Transaction
public java.lang.String getGUID()
public java.lang.Object getObjectByIdentity(Identity id) throws PersistenceBrokerException
id
- The identityPersistenceBrokerException
public void beforeMaterialization(IndirectionHandler handler, Identity oid)
beforeMaterialization
in interface MaterializationListener
handler
- the invoking handleroid
- the identity of the object to be materializedpublic void afterMaterialization(IndirectionHandler handler, java.lang.Object materializedObject)
afterMaterialization
in interface MaterializationListener
handler
- the invoking handlermaterializedObject
- the materialized Objectpublic PersistenceBrokerInternal getBrokerInternal()
TransactionNotInProgressException
- is the transaction is not open;public PersistenceBroker getBroker()
public void configure(org.apache.ojb.broker.util.configuration.Configuration config) throws org.apache.ojb.broker.util.configuration.ConfigurationException
org.apache.ojb.broker.util.configuration.Configurable
configure
in interface org.apache.ojb.broker.util.configuration.Configurable
config
- the Configuration object used to configure current instanceorg.apache.ojb.broker.util.configuration.ConfigurationException
public void setImplicitLocking(boolean value)
TransactionExt
setImplicitLocking
in interface TransactionExt
value
- If set true implicit locking is enabled,
if false, implicit locking is disabled.TransactionExt.setImplicitLocking(boolean)
public boolean isImplicitLocking()
TransactionExt
isImplicitLocking
in interface TransactionExt
TransactionExt.setImplicitLocking(boolean)
public void beforeLoading(CollectionProxyDefaultImpl colProxy)
beforeLoading
in interface CollectionProxyListener
colProxy
- the CollectionProxypublic void afterLoading(CollectionProxyDefaultImpl colProxy)
afterLoading
in interface CollectionProxyListener
colProxy
- the CollectionProxypublic void setCascadingDelete(java.lang.Class target, java.lang.String referenceField, boolean doCascade)
setCascadingDelete
in interface TransactionExt
target
- The class to change cascading delete behavior of the references.referenceField
- The field name of the 1:1, 1:n or 1:n reference.doCascade
- If true cascading delete is enabled, false disabled.public void setCascadingDelete(java.lang.Class target, boolean doCascade)
setCascadingDelete
in interface TransactionExt
target
- The class to change cascading delete behavior of all references.doCascade
- If true cascading delete is enabled, false disabled.public boolean isOrdering()
isOrdering
in interface TransactionExt
setOrdering(boolean)
public void setOrdering(boolean ordering)
setImplicitLocking(boolean)
.setOrdering
in interface TransactionExt
ordering
- Set true to enable object ordering on commit.ImplementationExt.setOrdering(boolean)
(C) 2002 - 2005 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