org.exolab.castor.jdo
public final class JDO extends Object implements DataObjects, Referenceable, ObjectFactory, Serializable
Deprecated: JDO has been replaced by JDOManager.
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 JDO is used to obtain a new database connection. Any number of database connections can be obtained from the same JDO object. The database configuration can be loaded using one of the loadConfiguration methods. Alternatively, setConfiguration 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();
Version: $Revision: 6216 $ $Date: 2006-04-12 15:13:08 -0600 (Wed, 12 Apr 2006) $
Field Summary | |
---|---|
static int | DEFAULT_LOCK_TIMEOUT
The default lock timeout for this database is 10 seconds. |
Constructor Summary | |
---|---|
JDO()
Constructs a new JDO database factory. | |
JDO(String name)
Constructs a new JDO database factory for databases with
the given name.
|
Method Summary | |
---|---|
ClassLoader | getClassLoader()
Returns the application classloader.
|
String | getConfiguration()
Return the URL of the database configuration file.
|
Database | getDatabase()
Opens and returns a connection to the database. |
String | getDatabaseName()
Returns the name of this database.
|
boolean | getDatabasePooling()
Indicates if jdo database pooling is enable or not.
|
String | getDescription()
Returns the description of this database.
|
EntityResolver | getEntityResolver()
Returns the entity resolver.
|
int | getLockTimeout()
Returns the lock timeout for this database.
|
LogInterceptor | getLogInterceptor()
Returns the log interceptor for this database source.
|
Object | getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env)
{@inheritDoc }
Creates an instance of JDO from a JNDI reference.
|
Reference | getReference()
Creates a JNDI reference from the current JDO instance, to be bound to
a JNDI tree.
|
boolean | isAutoStore()
Return if the next database instance will be set to autoStore.
|
static void | loadConfiguration(String url)
Load database configuration from the specified URL. |
static void | loadConfiguration(String url, ClassLoader loader)
Load database configuration from the specified URL. |
static void | loadConfiguration(InputSource source, EntityResolver resolver, ClassLoader loader)
Load database configuration from the specified input source.
|
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 | setClassLoader(ClassLoader classLoader)
Sets the application class loader. |
void | setConfiguration(String url)
Sets the URL of the database configuration file. |
void | setConfiguration(JdoConf jdoConfiguration)
Provides JDO with a JDO configuration file. |
void | setDatabaseName(String name)
Sets the name of this database. |
void | setDatabasePooling(boolean pool)
Enable/disable jdo Database pooling. |
void | setDescription(String description)
Sets the description of this database.
|
void | setEntityResolver(EntityResolver entityResolver)
Sets the entity resolver. |
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)
Sets the log interceptor for this database source.
|
void | setLogWriter(PrintWriter logWriter)
Returns the log writer for this database source.
|
Parameters: name The database name
Returns: The currently used ClassLoader or null if default is used.
The standard name for this property is configuration.
Returns: The URL of the database configuration file
Returns: An open connection to the database
Throws: PersistenceException Database access failed
The standard name for this property is databaseName.
Returns: The name of this database
Experimental maybe removed in the further release
Returns: true
if database pooling is enable.
See Also: JDO
The standard name for this property is description.
Returns: The description of this database
Returns: The EntityResolver currently in use.
The standard name for this property is lockTimeout.
Returns: The lock timeout, specified in seconds
Deprecated: There is no need for this method due to the implementation of Log4J which is controlled via the log4j.properties file.
Returns the log interceptor for this database source.Returns: The log interceptor, null if disabled
See Also: javax.naming.spi.ObjectFactory
Returns: valid A JNDI Reference.
Throws: NamingException If the Reference cannot be created.
See Also: javax.naming.Referenceable#getReference()
Returns: True if autoStore is enabled.
Parameters: url The JDO configuration file
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: url The JDO configuration file loader The class loader to use, null for the default
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: source The JDO configuration file resolver An optional entity resolver loader The class loader to use, null for the default
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: autoStore True if user prefer all reachable object to be stored automatically; False if user want only dependent object to be stored.
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.
Parameters: callback The callback interceptor, null if disabled
Class.forName(className)
.
Examples:
jdo.setClassLoader(getClass().getClassLoader());
jdo.setClassLoader(Thread.currentThread().getContextClassLoader());
Parameters: classLoader New ClassLoader to be used or null to use the default.
The standard name for this property is configuration.
Parameters: url The URL of the database configuration file
Parameters: jdoConfiguration A JDO configuration instance.
The standard name for this property is databaseName.
Parameters: name The name of this database
Method should be called before the invocation of JDO.
Experimental maybe removed in the future releases
Parameters: pool true to enable database pooling
The standard name for this property is description.
Parameters: description The description of this database
Parameters: entityResolver New EntityResolver to be used.
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.
Parameters: factory The instance factory, null to use the default
The standard name for this property is lockTimeout.
Parameters: seconds The lock timeout, specified in seconds
Deprecated: There is no need for this method due to the implementation of Log4J which is controlled via the log4j.properties file.
Sets the log interceptor for this database source.The interceptor is a callback to to which all logging and tracing messages are sent.
Parameters: logInterceptor The log interceptor, null if disabled
Deprecated: There is no need for this method due to the implementation of Log4J which is controlled via the log4j.properties file.
Returns the log writer for this database source.The log writer is a character output stream to which all logging and tracing messages will be printed.
Parameters: logWriter A PrintWriter instance.