Package net.ontopia.persistence.proxy
Class AbstractTransaction
- java.lang.Object
-
- net.ontopia.persistence.proxy.AbstractTransaction
-
- All Implemented Interfaces:
TransactionIF
- Direct Known Subclasses:
ROTransaction
,RWTransaction
public abstract class AbstractTransaction extends Object implements TransactionIF
INTERNAL: The default proxy transaction implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected StorageAccessIF
access
protected boolean
debug
protected String
id
protected Map<IdentityIF,PersistentIF>
identity_map
protected boolean
isaborted
protected boolean
isactive
protected boolean
isclosed
protected Map<IdentityIF,PersistentIF>
lru
protected int
lrusize
protected ObjectRelationalMappingIF
mapping
protected ObjectAccessIF
oaccess
protected Map<String,QueryIF>
querymap
protected AccessRegistrarIF
registrar
protected long
timestamp
protected StorageCacheIF
txncache
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PersistentIF
_getObject(IdentityIF identity)
EXPERIMENTAL: ...void
abort()
INTERNAL: Aborts the changes performed in the transaction.void
begin()
INTERNAL: Begins a new transaction.protected PersistentIF
checkIdentityMap(IdentityIF identity)
protected PersistentIF
checkIdentityMapAndCreateInstance(IdentityIF identity)
protected PersistentIF
checkIdentityMapNoLRU(IdentityIF identity)
void
close()
INTERNAL: Releases all resources used by the transaction.void
commit()
INTERNAL: Commits the changes performed in the transaction.protected PersistentIF
createInstance(IdentityIF identity)
QueryIF
createQuery(JDOQuery jdoquery, boolean resolve_identities)
INTERNAL: Build a QueryIF from the specified JDO query instance.Object
executeQuery(String name, Object[] params)
INTERNAL: Executes the named query.protected Collection
extractFieldValues(Object type, int field, Collection<IdentityIF> identities)
protected Collection<IdentityIF>
extractNonDirty(Collection<IdentityIF> identities)
abstract void
flush()
INTERNAL: Stores all pending changes in the data repository.AccessRegistrarIF
getAccessRegistrar()
INTERNAL: Gets the access registrar used by the transaction.String
getId()
INTERNAL: Gets the transaction id.PersistentIF
getObject(IdentityIF identity)
INTERNAL: Gets the object instance with the given identity.PersistentIF
getObject(IdentityIF identity, boolean acceptDeleted)
INTERNAL: Gets the object instance with the given identity.ObjectAccessIF
getObjectAccess()
INTERNAL: Gets the object access used by the transaction.protected QueryIF
getQuery(String name)
StorageAccessIF
getStorageAccess()
INTERNAL: Gets the storage access used by the transaction.boolean
isActive()
INTERNAL: Returns true the transaction is active.boolean
isFieldLoaded(IdentityIF identity, int field)
EXPERIMENTAL:boolean
isObjectLoaded(IdentityIF identity)
EXPERIMENTAL:<F> F
loadField(IdentityIF identity, int field)
INTERNAL: Called by PersistentIFs when the value of the specified field is requested.void
objectMerged(IdentityIF source, IdentityIF target)
INTERNAL: Called by other transactions to notify this transaction of committed merges.void
prefetch(Class<?> type, int[] fields, boolean[] traverse, Collection<IdentityIF> identities)
void
prefetch(Class<?> type, int field, boolean traverse, Collection<IdentityIF> identities)
protected void
registerQuery(String name, QueryIF query)
protected PersistentIF
removeIdentityMapNoLRU(IdentityIF identity)
String
toString()
protected abstract void
transactionPostAbort()
protected abstract void
transactionPostCommit()
protected abstract void
transactionPreAbort()
protected abstract void
transactionPreCommit()
boolean
validate()
INTERNAL: Returns true if the transaction is valid.void
writeIdentityMap(Writer out, boolean dump)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.ontopia.persistence.proxy.TransactionIF
assignIdentity, create, delete, isClean, isObjectClean, isReadOnly, objectCreated, objectDeleted, objectDirty, objectRead
-
-
-
-
Field Detail
-
debug
protected boolean debug
-
isactive
protected boolean isactive
-
isclosed
protected boolean isclosed
-
isaborted
protected boolean isaborted
-
id
protected String id
-
access
protected StorageAccessIF access
-
txncache
protected StorageCacheIF txncache
-
registrar
protected AccessRegistrarIF registrar
-
oaccess
protected ObjectAccessIF oaccess
-
mapping
protected ObjectRelationalMappingIF mapping
-
identity_map
protected final Map<IdentityIF,PersistentIF> identity_map
-
lru
protected Map<IdentityIF,PersistentIF> lru
-
lrusize
protected int lrusize
-
timestamp
protected long timestamp
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:TransactionIF
INTERNAL: Gets the transaction id. This id is unique for a given StorageIF instance.- Specified by:
getId
in interfaceTransactionIF
-
getStorageAccess
public StorageAccessIF getStorageAccess()
Description copied from interface:TransactionIF
INTERNAL: Gets the storage access used by the transaction.- Specified by:
getStorageAccess
in interfaceTransactionIF
-
isActive
public boolean isActive()
Description copied from interface:TransactionIF
INTERNAL: Returns true the transaction is active.- Specified by:
isActive
in interfaceTransactionIF
-
validate
public boolean validate()
Description copied from interface:TransactionIF
INTERNAL: Returns true if the transaction is valid.- Specified by:
validate
in interfaceTransactionIF
-
begin
public void begin()
Description copied from interface:TransactionIF
INTERNAL: Begins a new transaction.- Specified by:
begin
in interfaceTransactionIF
-
commit
public void commit()
Description copied from interface:TransactionIF
INTERNAL: Commits the changes performed in the transaction.- Specified by:
commit
in interfaceTransactionIF
-
abort
public void abort()
Description copied from interface:TransactionIF
INTERNAL: Aborts the changes performed in the transaction.- Specified by:
abort
in interfaceTransactionIF
-
close
public void close()
Description copied from interface:TransactionIF
INTERNAL: Releases all resources used by the transaction.- Specified by:
close
in interfaceTransactionIF
-
flush
public abstract void flush()
Description copied from interface:TransactionIF
INTERNAL: Stores all pending changes in the data repository. Note that the transaction is not commited.- Specified by:
flush
in interfaceTransactionIF
-
transactionPreCommit
protected abstract void transactionPreCommit()
-
transactionPostCommit
protected abstract void transactionPostCommit()
-
transactionPreAbort
protected abstract void transactionPreAbort()
-
transactionPostAbort
protected abstract void transactionPostAbort()
-
getObjectAccess
public ObjectAccessIF getObjectAccess()
Description copied from interface:TransactionIF
INTERNAL: Gets the object access used by the transaction.- Specified by:
getObjectAccess
in interfaceTransactionIF
-
getAccessRegistrar
public AccessRegistrarIF getAccessRegistrar()
Description copied from interface:TransactionIF
INTERNAL: Gets the access registrar used by the transaction.- Specified by:
getAccessRegistrar
in interfaceTransactionIF
-
isObjectLoaded
public boolean isObjectLoaded(IdentityIF identity)
Description copied from interface:TransactionIF
EXPERIMENTAL:- Specified by:
isObjectLoaded
in interfaceTransactionIF
-
isFieldLoaded
public boolean isFieldLoaded(IdentityIF identity, int field)
Description copied from interface:TransactionIF
EXPERIMENTAL:- Specified by:
isFieldLoaded
in interfaceTransactionIF
-
loadField
public <F> F loadField(IdentityIF identity, int field)
Description copied from interface:TransactionIF
INTERNAL: Called by PersistentIFs when the value of the specified field is requested. Note that the persistent object will be notified through the _p_setValue method, so there is usually no need to use the return value to set the instance member.- Specified by:
loadField
in interfaceTransactionIF
- Returns:
- the field value that was loaded.
-
objectMerged
public void objectMerged(IdentityIF source, IdentityIF target)
INTERNAL: Called by other transactions to notify this transaction of committed merges. Default implementation is empty.- Parameters:
source
- The identity of the object merged into targettarget
- The identity of the target object that was merged- Since:
- 5.4.0
-
getObject
public PersistentIF getObject(IdentityIF identity)
Description copied from interface:TransactionIF
INTERNAL: Gets the object instance with the given identity. If the identity is known not to exist in the data repository an exception will be thrown. Deleted objects will not be returned from this method.- Specified by:
getObject
in interfaceTransactionIF
-
getObject
public PersistentIF getObject(IdentityIF identity, boolean acceptDeleted)
Description copied from interface:TransactionIF
INTERNAL: Gets the object instance with the given identity. If the identity is known not to exist in the data repository an exception will be thrown. Known and still existing object instances of deleted objects will be returned from this method if the acceptDeleted flag is true.- Specified by:
getObject
in interfaceTransactionIF
-
_getObject
public PersistentIF _getObject(IdentityIF identity)
Description copied from interface:TransactionIF
EXPERIMENTAL: ...- Specified by:
_getObject
in interfaceTransactionIF
-
checkIdentityMapAndCreateInstance
protected PersistentIF checkIdentityMapAndCreateInstance(IdentityIF identity)
-
checkIdentityMapNoLRU
protected PersistentIF checkIdentityMapNoLRU(IdentityIF identity)
-
removeIdentityMapNoLRU
protected PersistentIF removeIdentityMapNoLRU(IdentityIF identity)
-
checkIdentityMap
protected PersistentIF checkIdentityMap(IdentityIF identity)
-
createInstance
protected PersistentIF createInstance(IdentityIF identity)
-
prefetch
public void prefetch(Class<?> type, int field, boolean traverse, Collection<IdentityIF> identities)
- Specified by:
prefetch
in interfaceTransactionIF
-
prefetch
public void prefetch(Class<?> type, int[] fields, boolean[] traverse, Collection<IdentityIF> identities)
- Specified by:
prefetch
in interfaceTransactionIF
-
extractNonDirty
protected Collection<IdentityIF> extractNonDirty(Collection<IdentityIF> identities)
-
extractFieldValues
protected Collection extractFieldValues(Object type, int field, Collection<IdentityIF> identities)
-
executeQuery
public Object executeQuery(String name, Object[] params)
Description copied from interface:TransactionIF
INTERNAL: Executes the named query. The parameters given in the params parameter are used during the execution of the query.- Specified by:
executeQuery
in interfaceTransactionIF
-
createQuery
public QueryIF createQuery(JDOQuery jdoquery, boolean resolve_identities)
Description copied from interface:TransactionIF
INTERNAL: Build a QueryIF from the specified JDO query instance.- Specified by:
createQuery
in interfaceTransactionIF
-
writeIdentityMap
public void writeIdentityMap(Writer out, boolean dump) throws IOException
- Throws:
IOException
-
-