Package org.castor.jdo.engine
Class DatabaseRegistry
java.lang.Object
org.castor.jdo.engine.DatabaseRegistry
- Since:
- 0.9.9
- Version:
- $Revision: 8129 $ $Date: 2006-04-10 16:39:24 -0600 (Mon, 10 Apr 2006) $
- Author:
- Assaf Arkin, Bruce Snyder, Ralf Joachim
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Reset all database configurations.static DatabaseContextgetDatabaseContext(String name) Get the ConnectionFactory for the given database name.static booleanCheck if any database configuration has been loaded.static booleanisDatabaseRegistred(String name) Check if database configuration with given name has been loaded.static voidloadDatabase(String name, String engine, DataSource datasource, Mapping mapping, TransactionManager txManager) Instantiates a DataSourceConnectionFactory with given name, engine, datasource and mapping.static voidloadDatabase(JdoConf jdoConf, EntityResolver resolver, ClassLoader loader, String baseURI) Creates a entry for every database and associates them with their name in a map.static voidloadDatabase(JdoConf jdoConf, EntityResolver resolver, ClassLoader loader, String baseURI, JDOClassDescriptorResolver classDescriptorResolver) Creates a entry for every database and associates them with their name in a map.static voidloadDatabase(InputSource source, EntityResolver resolver, ClassLoader loader) Instantiates a ConnectionFactory from the JDO configuration file.static voidloadDatabase(InputSource source, EntityResolver resolver, ClassLoader loader, JDOClassDescriptorResolver classDescriptorResolver) Instantiates a ConnectionFactory from the JDO configuration file.static voidunloadDatabase(String name) Unload the database configuration with given name.
-
Method Details
-
loadDatabase
public static void loadDatabase(String name, String engine, DataSource datasource, Mapping mapping, TransactionManager txManager) throws MappingException Instantiates a DataSourceConnectionFactory with given name, engine, datasource and mapping.- 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.
-
loadDatabase
public static void loadDatabase(InputSource source, EntityResolver resolver, ClassLoader loader) throws MappingException Instantiates a ConnectionFactory from the JDO configuration file.- Parameters:
source-InputSourcepointing to the JDO configuration.resolver- An entity resolver.loader- A class loader- Throws:
MappingException- If the database cannot be instantiated/loadeed.
-
loadDatabase
public static void loadDatabase(InputSource source, EntityResolver resolver, ClassLoader loader, JDOClassDescriptorResolver classDescriptorResolver) throws MappingException Instantiates a ConnectionFactory from the JDO configuration file.- Parameters:
source-InputSourcepointing to the JDO configuration.resolver- An entity resolver.loader- A class loaderclassDescriptorResolver-used for class to class descriptor resolution.invalid reference
ClassDescriptorResolver- Throws:
MappingException- If the database cannot be instantiated/loaded.
-
loadDatabase
public static void loadDatabase(JdoConf jdoConf, EntityResolver resolver, ClassLoader loader, String baseURI) throws MappingException Creates a entry for every database and associates them with their name in a map. It then instantiates all databases if 'org.exolab.castor.jdo.DatabaseInitializeAtLoad' key can not be found or is set totruein castor.properties file. If above property is set tofalseit will instantiate all databases only when they are needed.- Parameters:
jdoConf- An in-memory jdo configuration.resolver- An entity resolver.loader- A class loaderbaseURI- The base URL for the mapping- Throws:
MappingException- If the database cannot be instantiated/loadeed.
-
loadDatabase
public static void loadDatabase(JdoConf jdoConf, EntityResolver resolver, ClassLoader loader, String baseURI, JDOClassDescriptorResolver classDescriptorResolver) throws MappingException Creates a entry for every database and associates them with their name in a map. It then instantiates all databases if 'org.exolab.castor.jdo.DatabaseInitializeAtLoad' key can not be found or is set totruein castor.properties file. If above property is set tofalseit will instantiate all databases only when they are needed.- Parameters:
jdoConf- An in-memory jdo configuration.resolver- An entity resolver.loader- A class loaderbaseURI- The base URL for the mappingclassDescriptorResolver-used for class to class descriptor resolution.invalid reference
ClassDescriptorResolver- Throws:
MappingException- If the database cannot be instantiated/loadeed.
-
hasDatabaseRegistries
public static boolean hasDatabaseRegistries()Check if any database configuration has been loaded.- Returns:
trueif a databases configuration has been loaded.
-
isDatabaseRegistred
Check if database configuration with given name has been loaded.- Parameters:
name- Name of the database to check if loaded.- Returns:
trueif databases configuration has been loaded.
-
getDatabaseContext
Get the ConnectionFactory for the given database name.- Parameters:
name- Name of the database configuration.- Returns:
- The ConnectionFactory for the given database name.
- Throws:
MappingException- If database can not be instantiated.
-
clear
public static void clear()Reset all database configurations. -
unloadDatabase
Unload the database configuration with given name.- Parameters:
name- Name of the database to be unloaded.
-