|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.jdo.JDO
public final class JDO
Implementation of the JDO engine used for obtaining database connection. A
JDO object is constructed with the name of a database and other properties,
and getDatabase()
is used to obtain a new database connection. Any
number of database connections can be obtained from the same JDO object.
loadConfiguration(String)
methods. Alternatively, setConfiguration(String)
can be used to specify the URL of a database
configuration file. The configuration will be loaded only once.
For example:
// load the database configuration JDO.loadConfiguration( "database.xml" ); ... JDO jdo; Database db; // construct a new JDO for the database 'mydb' jdo = new JDO( "mydb" ); // open a connection to the database db = jdo.getDatabase();Or,
JDO jdo; Database db; // construct a new JDO for the database 'mydb' jdo = new JDO( "mydb" ); // specify the database configuration jdo.setConfiguration( "database.xml" ); // open a connection to the database db = jdo.getDatabase();
Field Summary | |
---|---|
static int |
DEFAULT_LOCK_TIMEOUT
Deprecated. The default lock timeout for this database is 10 seconds. |
Constructor Summary | |
---|---|
JDO()
Deprecated. Constructs a new JDO database factory. |
|
JDO(java.lang.String name)
Deprecated. Constructs a new JDO database factory for databases with the given name. |
Method Summary | |
---|---|
java.lang.ClassLoader |
getClassLoader()
Deprecated. Returns the application classloader. |
java.lang.String |
getConfiguration()
Deprecated. Return the URL of the database configuration file. |
Database |
getDatabase()
Deprecated. Opens and returns a connection to the database. |
java.lang.String |
getDatabaseName()
Deprecated. Returns the name of this database. |
boolean |
getDatabasePooling()
Deprecated. Indicates if jdo Database pooling is enable or not. |
java.lang.String |
getDescription()
Deprecated. Returns the description of this database. |
org.xml.sax.EntityResolver |
getEntityResolver()
Deprecated. Returns the entity resolver. |
int |
getLockTimeout()
Deprecated. 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)
Deprecated. Creates an instance of JDO from a JNDI reference. |
javax.naming.Reference |
getReference()
Deprecated. Creates a JNDI reference from the current JDO instance, to be bound to a JNDI tree. |
boolean |
isAutoStore()
Deprecated. 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)
Deprecated. Load database configuration from the specified input source. |
static void |
loadConfiguration(java.lang.String url)
Deprecated. Load database configuration from the specified URL. |
static void |
loadConfiguration(java.lang.String url,
java.lang.ClassLoader loader)
Deprecated. Load database configuration from the specified URL. |
void |
setAutoStore(boolean autoStore)
Deprecated. Sets autoStore mode. |
void |
setCallbackInterceptor(CallbackInterceptor callback)
Deprecated. Overrides the default callback interceptor by a custom interceptor for this database source. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Deprecated. Sets the application class loader. |
void |
setConfiguration(JdoConf jdoConfiguration)
Deprecated. Provides JDO with a JDO configuration file. |
void |
setConfiguration(java.lang.String url)
Deprecated. Sets the URL of the database configuration file. |
void |
setDatabaseName(java.lang.String name)
Deprecated. Sets the name of this database. |
void |
setDatabasePooling(boolean pool)
Deprecated. Enable/disable jdo Database pooling. |
void |
setDescription(java.lang.String description)
Deprecated. Sets the description of this database. |
void |
setEntityResolver(org.xml.sax.EntityResolver entityResolver)
Deprecated. Sets the entity resolver. |
void |
setInstanceFactory(InstanceFactory factory)
Deprecated. 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)
Deprecated. 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
Constructor Detail |
---|
public JDO()
setDatabaseName(java.lang.String)
before calling getDatabase()
.
public JDO(java.lang.String name)
name
- The database nameMethod Detail |
---|
public 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 void setClassLoader(java.lang.ClassLoader classLoader)
Class.forName(className)
.
Examples:
jdo.setClassLoader(getClass().getClassLoader());
jdo.setClassLoader(Thread.currentThread().getContextClassLoader());
classLoader
- New ClassLoader to be used or null to use the default.public java.lang.ClassLoader getClassLoader()
public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
entityResolver
- New EntityResolver to be used.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 void setDatabaseName(java.lang.String name)
The standard name for this property is databaseName.
name
- The name of this databasepublic 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(java.lang.String url)
loadConfiguration(String)
methods
instead.
The standard name for this property is configuration.
url
- The URL of the database configuration filepublic void setConfiguration(JdoConf jdoConfiguration)
jdoConfiguration
- A JDO configuration instance.public java.lang.String 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.
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.public boolean isAutoStore()
public Database getDatabase() throws PersistenceException
DatabaseNotFoundException
if the database named was not
set in the constructor or with a call to setDatabaseName(java.lang.String)
,
or if no database configuration exists for the named database.
getDatabase
in interface DataObjects
PersistenceException
- Database access failedpublic static void loadConfiguration(java.lang.String url) throws MappingException
url
- The JDO configuration file
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 JDO configuration fileloader
- 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(org.xml.sax.InputSource source, org.xml.sax.EntityResolver resolver, java.lang.ClassLoader loader) throws MappingException
source
- The JDO configuration fileresolver
- An optional entity resolverloader
- 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 javax.naming.Reference getReference() throws javax.naming.NamingException
getReference
in interface javax.naming.Referenceable
javax.naming.NamingException
- If the Reference cannot be created.Referenceable.getReference()
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
ObjectFactory
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |