org.exolab.castor.jdo
public final class JDOManager extends Object implements DataObjects, Referenceable, ObjectFactory, Serializable
... JDOManager jdo; Database db; try { // load the JDOManager configuration file JDOManager.loadConfiguration("jdo-config.xml"); // construct a new JDOManager for 'mydb' jdo = JDOManager.createInstance("mydb"); // open a connection to the database db = jdo.getDatabase(); } catch (MappingException ex) { ... } catch (DatabaseNotFoundException ex) { ... }
Version: $Revision: 6216 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
Field Summary | |
---|---|
static String | DEFAULT_DESCRIPTION
Default description. |
static int | DEFAULT_LOCK_TIMEOUT
The default lock timeout (specified in seconds). |
Method Summary | |
---|---|
void | close()
Lyfe-cycle methods to close JDOManager instance and initiate resource cleanup. |
static JDOManager | createInstance(String databaseName)
Factory method for creating a JDOManager instance for one of the
databases configured in the JDOManager configuration file. |
CallbackInterceptor | getCallbackInterceptor()
Returns the callback interceptor.
|
ClassLoader | getClassLoader()
Returns the application classloader.
|
InputSource | getConfiguration()
Return the URL of the database configuration file.
|
ConnectionFactory | getConnectionFactory()
Returns the ConnectionFactory for this JDOManager instance.
|
Database | getDatabase()
Opens and returns a connection to the database. |
String | getDatabaseName()
Returns the name of this database.
|
boolean | getDatabasePooling()
Indicates if database pooling is enable or not. |
String | getDescription()
Returns the description of this database.
|
EntityResolver | getEntityResolver()
Returns the entity resolver.
|
InstanceFactory | getInstanceFactory()
Returns the instance factory.
|
int | getLockTimeout()
Returns the lock timeout for this database.
|
Object | getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env) |
Reference | getReference()
Constructs a new reference to JDOManager being its own factory.
|
boolean | isAutoStore()
Return if the next database instance will be set to autoStore.
|
static void | loadConfiguration(String name, String engine, DataSource datasource, Mapping mapping, TransactionManager txManager)
Initialize the JDOManager configuration with given name, engine, datasource,
transaction demarcation and mapping.
|
static void | loadConfiguration(JdoConf jdoConf, EntityResolver resolver, ClassLoader loader, String baseURI)
Load the JDOManager configuration from the specified in-memory JdoConf. |
static void | loadConfiguration(JdoConf jdoConf, ClassLoader loader, String baseURI)
Load the JDOManager configuration from the specified in-memory JdoConf. |
static void | loadConfiguration(JdoConf jdoConf, String baseURI)
Load the JDOManager configuration from the specified in-memory JdoConf.
|
static void | loadConfiguration(InputSource source, EntityResolver resolver, ClassLoader loader)
Load the JDOManager configuration from the specified input source using
a custom class loader. |
static void | loadConfiguration(String url, ClassLoader loader)
Load the JDOManager configuration from the specified location using a
custom class loader.
|
static void | loadConfiguration(String url)
Load the JDOManager configuration from the specified location.
|
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 | setDatabasePooling(boolean pool)
Enable/disable database pooling. |
void | setDescription(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 a data object when it is needed during
loading.
|
void | setLockTimeout(int seconds)
Sets the lock timeout for this database. |
Parameters: databaseName Database name as configured in the JDOManager configuration file.
Returns: A JDOManager instance.
Throws: MappingException The mapping file is invalid, or any error occured trying to load the mapping from JDOManager configuration file.
Returns: The currently used CallbackInterceptor or null if not overriden.
Returns: The currently used ClassLoader or null if default is used.
Returns: The URL of the database configuration file as InputSource.
Returns: The connection factory used by this JDOManager instance.
Throws: MappingException If database can not be instantiated or is not configured.
Returns: An open connection to the database.
Throws: PersistenceException Database access failed.
Returns: The name of this database
Returns: True if pooling is enabled for this Database instance.
See Also: JDOManager
Returns: The description of this database
Returns: The EntityResolver currently in use.
Returns: The currently used InstanceFactoryor null if not overriden.
Returns: The lock timeout, specified in seconds
See Also: javax.naming.spi.ObjectFactory
Returns: A new Reference to JDOManager.
See Also: javax.naming.Reference javax.naming.spi.ObjectFactory
Returns: True if autoStore is enabled.
Parameters: name The Name of the database configuration. engine The Name of the persistence factory to use. datasource The preconfigured datasource to use for creating connections. mapping The previously loaded mapping. txManager The transaction manager to use.
Throws: MappingException If LockEngine could not be initialized.
Parameters: jdoConf the in-memory JdoConf. 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 baseURI The base URL for the mapping
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: jdoConf the in-memory JdoConf. loader The class loader to use, null for the default baseURI The base URL for the mapping
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: jdoConf the in-memory JdoConf. baseURI The base URL for the mapping
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: source The JDOManager 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
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDO configuration/mapping
Parameters: url The location from which to load the configuration file. loader The custom class loader to use, null for the default.
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDOManager configuration/mapping.
Parameters: url The location from which to load the configuration file.
Throws: MappingException The mapping file is invalid, or any error occured trying to load the JDOManager 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.
Parameters: callback The callback interceptor, null if disabled
Parameters: pool true to enable database pooling
Parameters: description The description of this database
Parameters: factory The instance factory, null to use the default
Parameters: seconds The lock timeout, specified in seconds