org.exolab.castor.jdo
public class JDO extends Object implements DataObjects, Referenceable, ObjectFactory, Serializable
The database configuration can be loaded using one of the JDO method. Alternatively, JDO can be used to specify the URL of a database configuration file. The configuration will 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 and specify the configuration file jdo = new JDO( "mydb" ); jdo.setConfiguration( "database.xml" ); // Open a connection to the database db = jdo.getDatabase();
Version: $Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:07 $
Field Summary | |
---|---|
static int | DefaultLockTimeout
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) |
Reference | getReference() |
String | getTransactionManager()
Returns the JNDI name of the transaction manager.
|
boolean | isAutoStore() |
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) |
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 | 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.
|
void | setTransactionManager(String tmName)
Sets the JNDI name of the transaction manager. |
Parameters: name The database name
The standard name for this property is configuration.
Returns: The URL of the database configuration file
Returns: An open connection to the database
Throws: DatabaseNotFoundException Attempted to open a database that does not exist 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
See Also: JDO
The standard name for this property is description.
Returns: The description of this database
The standard name for this property is lockTimeout.
Returns: The lock timeout, specified in seconds
Returns: The log interceptor, null if disabled
UNKNOWN: The JNDI name of the transaction manager
Parameters: url The JDO configuration file
UNKNOWN: 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
UNKNOWN: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: source The JDO configuration file resolve An optional entity resolver loader The class loader to use, null for the default
UNKNOWN: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
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());
The standard name for this property is configuration.
Parameters: url The URL of the database configuration file
The standard name for this property is databaseName.
Parameters: name The name of this database
This 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
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
The interceptor is a callback to to which all logging and tracing messages are sent.
Parameters: logInterceptor The log interceptor, null if disabled
The log writer is a character output stream to which all logging and tracing messages will be printed.
Returns: The log writer, null if disabled
The standard name for this property is transactionManager.
Parameters: tmName The JNDI name of the transaction manager