org.exolab.castor.jdo.engine

Class DatabaseImpl

public class DatabaseImpl extends Object implements Database, Synchronization

An implementation of the JDO database supporting explicit transaction demarcation.

Version: $Revision: 1.29 $ $Date: 2005/11/10 15:59:50 $

Author: Assaf Arkin Bruce Snyder

Field Summary
protected TransactionContext_ctx
The transaction context is this database was accessed with an javax.transaction.xa.XAResource.
protected PersistenceInfoGroup_scope
The database engine used to access the underlying SQL database.
Constructor Summary
DatabaseImpl(String dbName, int lockTimeout, CallbackInterceptor callback, InstanceFactory instanceFactory, Transaction transaction, ClassLoader classLoader, boolean autoStore)
Method Summary
voidafterCompletion(int status)
voidbeforeCompletion()
voidbegin()
voidclose()
voidcommit()
voidcreate(Object object)
voidexpireCache(Class[] type, Object[] identity)
Expire objects from the cache.
protected voidfinalize()
Overrides Object.finalize().
CacheManagergetCacheManager()
ClassLoadergetClassLoader()
Gets the current application ClassLoader's instance.
StringgetDatabaseName()
} Return the name of the database
ObjectgetIdentity(Object object)
ConnectiongetJdbcConnection()
Get the underlying JDBC Connection.
LockEnginegetLockEngine()
OQLQuerygetOQLQuery()
OQLQuerygetOQLQuery(String oql)
QuerygetQuery()
PersistenceInfoGroupgetScope()
protected TransactionContextgetTransaction()
booleanisActive()
booleanisAutoStore()
Return if the current transaction is set to autoStore, it there is transaction active.
booleanisClosed()
booleanisPersistent(Object object)
Objectload(Class type, Object identity)
Objectload(Class type, Object identity, Object object)
Objectload(Class type, Object identity, short accessMode)
Objectload(Class type, Object identity, AccessMode mode)
voidlock(Object object)
voidremove(Object object)
voidrollback()
voidsetAutoStore(boolean autoStore)
True if user prefer all reachable object to be stored automatically.
voidsetTxMap(TxDatabaseMap txMap)
StringtoString()
voidupdate(Object object)

Field Detail

_ctx

protected TransactionContext _ctx
The transaction context is this database was accessed with an javax.transaction.xa.XAResource.

_scope

protected PersistenceInfoGroup _scope
The database engine used to access the underlying SQL database.

Constructor Detail

DatabaseImpl

public DatabaseImpl(String dbName, int lockTimeout, CallbackInterceptor callback, InstanceFactory instanceFactory, Transaction transaction, ClassLoader classLoader, boolean autoStore)

Method Detail

afterCompletion

public void afterCompletion(int status)

beforeCompletion

public void beforeCompletion()

begin

public void begin()

close

public void close()

commit

public void commit()

create

public void create(Object object)

expireCache

public void expireCache(Class[] type, Object[] identity)

Deprecated: Please use the new CacheManager which can be obtained by calling getCacheManager.

Expire objects from the cache. Objects expired from the cache will be read from persistent storage, as opposed to being read from the performance cache, during subsequent load/query operations. Objects may be expired from the cache individually, using explicit type/identity pairs in the argument list, or whole classes of objects may be expired by specifying a class type without a corresponding entry in the identity array. Objects contained within a "master" object, for example objects maintained in a one-to-many relationship, will automatically be expired from the cache without the need to explicitly identify them. This does not apply when expiring objects by type. Each type, both container and contained objects need to be specified.

Parameters: type An array of class types. identity An array of object identifiers.

Throws: PersistenceException Indicates that a problem has occured expiring objects from the cache.

finalize

protected void finalize()
Overrides Object.finalize(). Outputs a warning message to teh logs if the current DatabaseImpl instance still has valid scope. In this condition - a condition that ideally should not occur at all - we close the instance as well to free up resources.

See Also: java.lang.Object#finalize()

getCacheManager

public CacheManager getCacheManager()

See Also: getCacheManager

getClassLoader

public ClassLoader getClassLoader()
Gets the current application ClassLoader's instance. For use in OQLQueryImpl and TransactionContext.

Returns: the current ClassLoader's instance, or null if not provided

getDatabaseName

public String getDatabaseName()
} Return the name of the database

Returns: Name of the database.

getIdentity

public Object getIdentity(Object object)

getJdbcConnection

public Connection getJdbcConnection()
Get the underlying JDBC Connection. This is for advanced use only. Please make sure that you never close this Connection instance, as it will be closed by Castor.

Returns: the underlying JDBC connection, if possible

Throws: PersistenceException If the underlying JDBC connection cannot be obtained.

getLockEngine

LockEngine getLockEngine()

getOQLQuery

public OQLQuery getOQLQuery()

getOQLQuery

public OQLQuery getOQLQuery(String oql)

getQuery

public Query getQuery()

getScope

public PersistenceInfoGroup getScope()

getTransaction

protected TransactionContext getTransaction()

isActive

public boolean isActive()

isAutoStore

public boolean isAutoStore()
Return if the current transaction is set to autoStore, it there is transaction active. If there is no active transaction, return if the next transaction will be set to autoStore.

Returns: True if 'auto-store' mode is in use.

isClosed

public boolean isClosed()

isPersistent

public boolean isPersistent(Object object)

load

public Object load(Class type, Object identity)

load

public Object load(Class type, Object identity, Object object)

load

public Object load(Class type, Object identity, short accessMode)

load

public Object load(Class type, Object identity, AccessMode mode)

lock

public void lock(Object object)

remove

public void remove(Object object)

rollback

public void rollback()

setAutoStore

public void setAutoStore(boolean autoStore)
True if user prefer all reachable object to be stored automatically. False if user want only dependent object to be stored.

Parameters: autoStore True to indicate that 'autoStore' mode should be used.

setTxMap

void setTxMap(TxDatabaseMap txMap)

toString

public String toString()

update

public void update(Object object)
Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com