|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.jdo.JDO2
Implementation of the JDO engine used for obtaining database
connection. After successful instantiation, getDatabase()
is
used to obtain a new database connection. Any number of database
connections can be obtained from the same JDO object.
Please note that this clas is provided on an experimental base, and might still undergo minor changes.
An instance of this class is contructed with a two-step approach:
Example:
. . . JDO jdo; Database db; try { // load the JDO configuration file JDO.loadConfiguration ("jdo-config.xml"); // Construct a new JDO for the database 'mydb' jdo = JDO.createInstance ("mydb"); // Open a connection to the database db = jdo.getDatabase(); } catch (MappingException e) { ... } catch (DatabaseNotFoundException) { ... }
Field Summary | |
static java.lang.String |
DEFAULT_DESCRIPTION
Default description. |
static int |
DEFAULT_LOCK_TIMEOUT
The default lock timeout (specified in seconds). |
Method Summary | |
static JDO2 |
createInstance(java.lang.String databaseName)
Factory method for creating a JDOOld instance for one of the databases configured in the JDOOld config file. |
java.lang.ClassLoader |
getClassLoader()
Returns the application classloader. |
org.xml.sax.InputSource |
getConfiguration()
Return the URL of the database configuration file. |
Database |
getDatabase()
Opens and returns a connection to the database. |
java.lang.String |
getDatabaseName()
Returns the name of this database. |
boolean |
getDatabasePooling()
Indicates if jdo Database pooling is enable or not. |
java.lang.String |
getDescription()
Returns the description of this database. |
org.xml.sax.EntityResolver |
getEntityResolver()
Returns the entity resolver. |
int |
getLockTimeout()
Returns the lock timeout for this database. |
LogInterceptor |
getLogInterceptor()
Deprecated. There is no need for this method due to the implementation of Log4J which is controlled via the log4j.properties file. |
java.lang.Object |
getObjectInstance(java.lang.Object refObj,
javax.naming.Name name,
javax.naming.Context nameCtx,
java.util.Hashtable env)
|
javax.naming.Reference |
getReference()
|
boolean |
isAutoStore()
Return if the next Database instance will be set to autoStore. |
static void |
loadConfiguration(org.xml.sax.InputSource source,
org.xml.sax.EntityResolver resolver,
java.lang.ClassLoader loader)
Load the JDO configuration from the specified input source using a custom class loader. |
static void |
loadConfiguration(java.lang.String url)
Load the JDO configuration from the specified location. |
static void |
loadConfiguration(java.lang.String url,
java.lang.ClassLoader loader)
Load the JDO configuration from the specified location using a custom class loader. |
void |
setAutoStore(boolean autoStore)
Sets autoStore mode. |
void |
setCallbackInterceptor(CallbackInterceptor callback)
Overrides the default callback interceptor by a custom interceptor for this database source. |
void |
setConfiguration(org.xml.sax.InputSource source)
Sets the URL of the database configuration file. |
void |
setDatabasePooling(boolean pool)
Enable/disable jdo Database pooling. |
void |
setDescription(java.lang.String description)
Sets the description of this database. |
void |
setInstanceFactory(InstanceFactory factory)
Overrides the default instance factory by a custom one to be used by Castor to obtaining an instance of data object when it is needed during loading. |
void |
setLockTimeout(int seconds)
Sets the lock timeout for this database. |
void |
setLogInterceptor(LogInterceptor logInterceptor)
Deprecated. There is no need for this method due to the implementation of Log4J which is controlled via the log4j.properties file. |
void |
setLogWriter(java.io.PrintWriter logWriter)
Deprecated. There is no need for this method due to the implementation of Log4J which is controlled via the log4j.properties file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_LOCK_TIMEOUT
public static final java.lang.String DEFAULT_DESCRIPTION
Method Detail |
public static JDO2 createInstance(java.lang.String databaseName) throws MappingException
databaseName
- Database name as configured in the JDOOld config file.
MappingException
- The mapping file is invalid, or any
error occured trying to load the JDO configuration/mappingpublic void setLogWriter(java.io.PrintWriter logWriter)
The log writer is a character output stream to which all logging and tracing messages will be printed.
logWriter
- A PrintWriter instance.public void setLogInterceptor(LogInterceptor logInterceptor)
The interceptor is a callback to to which all logging and tracing messages are sent.
logInterceptor
- The log interceptor, null if disabledpublic void setCallbackInterceptor(CallbackInterceptor callback)
The interceptor is a callback that notifies data objects on persistent state events.
If callback interceptor is not overrided, events will be sent to data object that implements the org.exolab.castor.jdo.Persistent interface.
callback
- The callback interceptor, null if disabledpublic void setInstanceFactory(InstanceFactory factory)
If instance factory is not overrided, and if class loader is not set, Class.forName( className ).newInstance() will be used; if instance factory is not override, and class loader is set, loader.loadClass( className ).newInstance() will be used to create a new instance.
factory
- The instance factory, null to use the defaultpublic LogInterceptor getLogInterceptor()
public java.lang.ClassLoader getClassLoader()
public org.xml.sax.EntityResolver getEntityResolver()
public void setDescription(java.lang.String description)
The standard name for this property is description.
setDescription
in interface DataObjects
description
- The description of this databasepublic java.lang.String getDescription()
The standard name for this property is description.
getDescription
in interface DataObjects
public java.lang.String getDatabaseName()
The standard name for this property is databaseName.
getDatabaseName
in interface DataObjects
public void setLockTimeout(int seconds)
The standard name for this property is lockTimeout.
seconds
- The lock timeout, specified in secondspublic int getLockTimeout()
The standard name for this property is lockTimeout.
public void setConfiguration(org.xml.sax.InputSource source)
loadConfiguration(String)
methods
instead.
The standard name for this property is configuration.
source
- The URL of the database configuration file as an InputSource.public org.xml.sax.InputSource getConfiguration()
The standard name for this property is configuration.
public void setDatabasePooling(boolean pool)
getDatabase()
. If jdo Database pooling
is enabled, JDO will first search in the pool to see if there
is already a Database for the current transaction. If found, it
returns the database; if not, it create a new one, associates
it will the transaction and return the newly created Database.
This method should be called before the invocation of getDatabase()
.
Experimental maybe removed in the future releases
pool
- true to enable database poolingpublic boolean getDatabasePooling()
Experimental maybe removed in the further release
setDatabasePooling(boolean)
public void setAutoStore(boolean autoStore)
autoStore
- True if user prefer all reachable object to be stored automatically;
False if user want only dependent object to be stored.
See also, setAutoStore(boolean)
public boolean isAutoStore()
public Database getDatabase() throws DatabaseNotFoundException, PersistenceException
DatabaseNotFoundException
if no database configuration exists for
the named database.
getDatabase
in interface DataObjects
DatabaseNotFoundException
- Attempted to open a database
that does not exist
PersistenceException
- Database access failedpublic static void loadConfiguration(org.xml.sax.InputSource source, org.xml.sax.EntityResolver resolver, java.lang.ClassLoader loader) throws MappingException
source
- The JDO configuration file describing the databases, connection factory and mappings.resolver
- An (optional) entity resolver to resolve cached entities, e.g. for external mapping documents.loader
- The class loader to use, null for the default
MappingException
- The mapping file is invalid, or any
error occured trying to load the JDO configuration/mappingpublic static void loadConfiguration(java.lang.String url, java.lang.ClassLoader loader) throws MappingException
url
- The location from which to load the JDOOld config file.loader
- The custom class loader to use, null for the default.
MappingException
- The mapping file is invalid, or any
error occured trying to load the JDO configuration/mappingpublic static void loadConfiguration(java.lang.String url) throws MappingException
url
- The location from which to load the JDOOld config file.
MappingException
- The mapping file is invalid, or any
error occured trying to load the JDO configuration/mappingpublic javax.naming.Reference getReference()
getReference
in interface javax.naming.Referenceable
public java.lang.Object getObjectInstance(java.lang.Object refObj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable env) throws javax.naming.NamingException
getObjectInstance
in interface javax.naming.spi.ObjectFactory
javax.naming.NamingException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |