|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.torque.Torque
public final class Torque
A static facade wrapper around the Torque implementation (which is in
TorqueInstance
).
Field Summary | |
---|---|
static String |
CACHE_KEY
Name of config property to determine whether caching is used. |
static String |
DATABASE_KEY
The prefix for configuring the database adapters and the default database. |
static String |
DEFAULT_KEY
The key used to configure the name of the default database. |
static String |
DEFAULT_SCHEMA_KEY
default schema name for the configuration |
static String |
DEFAULTS_KEY
"defaults" Key for the configuration |
static String |
MANAGER_PREFIX
A prefix for Manager properties in the configuration. |
static String |
MANAGER_SUFFIX
A Service property determining its implementing
class name . |
static String |
SCHEMA_KEY
"schema" Key for the configuration |
static String |
TORQUE_KEY
The prefix for all configuration keys used by Torque. |
static String |
TRANSACTION_MANAGER_KEY
The prefix for configuring the transaction manger. |
Method Summary | ||
---|---|---|
static void |
closeConnection(Connection con)
Closes a connection. |
|
static Adapter |
getAdapter(String name)
Returns the database adapter for a specific database name. |
|
static org.apache.commons.configuration.Configuration |
getConfiguration()
Get the configuration for this component. |
|
static Connection |
getConnection()
This method returns a Connection from the default pool. |
|
static Connection |
getConnection(String name)
This method returns a Connecton using the given database name. |
|
static Connection |
getConnection(String name,
String username,
String password)
This method returns a Connecton using the given parameters. |
|
static Database |
getDatabase(String name)
Returns the database for the given key. |
|
static DatabaseMap |
getDatabaseMap()
Returns the default database map information. |
|
static DatabaseMap |
getDatabaseMap(String name)
Returns the database map information for a given database. |
|
static Map<String,Database> |
getDatabases()
Returns a Map containing all Databases registered to Torque. |
|
static Adapter |
getDB(String name)
Deprecated. use getAdapter(String) instead. This method will be removed in a future version of Torque. |
|
static String |
getDefaultDB()
Returns the name of the default database. |
|
static TorqueInstance |
getInstance()
Retrieves the single TorqueInstance
used by this class. |
|
static
|
getManager(String name)
This method returns a Manager for the given name. |
|
static
|
getManager(String name,
String defaultClassName)
This methods returns either the Manager from the configuration file, or the default one provided by the generated code. |
|
static Database |
getOrCreateDatabase(String name)
Returns the database for the key databaseName . |
|
static String |
getSchema(String name)
This method returns the current schema for a database connection |
|
static void |
init(org.apache.commons.configuration.Configuration conf)
Initialization of Torque with a configuration. |
|
static void |
init(String configFile)
Initialization of Torque with a path to a properties file. |
|
static boolean |
isInit()
Determine whether Torque has already been initialized. |
|
static void |
registerIDBroker(IDBroker idBroker)
Registers an id broker. |
|
static void |
setConfiguration(org.apache.commons.configuration.Configuration conf)
Sets the configuration for Torque and all dependencies. |
|
static void |
setInstance(TorqueInstance instance)
Sets the single TorqueInstance
used by this class. |
|
static void |
setSchema(String name,
String schema)
Sets the current schema for a database connection |
|
static void |
shutdown()
Shuts down the service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TORQUE_KEY
public static final String DATABASE_KEY
public static final String DEFAULT_KEY
public static final String SCHEMA_KEY
public static final String DEFAULTS_KEY
public static final String DEFAULT_SCHEMA_KEY
public static final String MANAGER_PREFIX
Manager
properties in the configuration.
public static final String MANAGER_SUFFIX
Service
property determining its implementing
class name .
public static final String CACHE_KEY
public static final String TRANSACTION_MANAGER_KEY
Method Detail |
---|
public static TorqueInstance getInstance()
TorqueInstance
used by this class.
public static void setInstance(TorqueInstance instance)
TorqueInstance
used by this class. This is used by the Avalon component
to make sure that only one instance of Torque exists.
instance
- Our singleton.public static void init(String configFile) throws TorqueException
configFile
- The absolute path to the configuration file.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static void init(org.apache.commons.configuration.Configuration conf) throws TorqueException
conf
- The Torque configuration.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static boolean isInit()
public static void setConfiguration(org.apache.commons.configuration.Configuration conf) throws TorqueException
conf
- the Configuration
TorqueException
- if the configuration does not contain
any keys starting with Torque.TORQUE_KEY
.public static org.apache.commons.configuration.Configuration getConfiguration()
public static <T extends AbstractBaseManager<? extends Persistent>> T getManager(String name)
name
- name of the manager.
public static <T extends AbstractBaseManager<? extends Persistent>> T getManager(String name, String defaultClassName)
name
- name of the manager.defaultClassName
- the class to use if name has not been configured.
public static void shutdown() throws TorqueException
TorqueException
- if a DataSourceFactory could not be closed
cleanly. Only the first exception is rethrown, any following
exceptions are logged but ignored.public static DatabaseMap getDatabaseMap() throws TorqueException
TorqueException
- if Torque is not initialized.public static DatabaseMap getDatabaseMap(String name) throws TorqueException
name
- The name of the database corresponding to the
DatabaseMap
to retrieve, or null
for the default database.
DatabaseMap
, not null.
TorqueException
- if Torque is not initialized and name is null.public static void registerIDBroker(IDBroker idBroker)
idBroker
- the id broker to register, not null.
NullPointerException
- if idBroker is null.public static Connection getConnection() throws TorqueException
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static Connection getConnection(String name) throws TorqueException
name
- The database name.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static Connection getConnection(String name, String username, String password) throws TorqueException
name
- The database name.username
- The name of the database user.password
- The password of the database user.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.@Deprecated public static Adapter getDB(String name) throws TorqueException
name
- the database name, or null for the default db.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static Adapter getAdapter(String name) throws TorqueException
name
- the database name, or null for the default db.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static String getDefaultDB()
public static void closeConnection(Connection con)
con
- A Connection to close.public static void setSchema(String name, String schema)
name
- The database name.schema
- The current schema name.
NullPointerException
- if databaseName is null.public static String getSchema(String name) throws TorqueException
name
- The database name.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static Database getDatabase(String name) throws TorqueException
name
- the key to get the database for,
or null for the default database.
TorqueException
- if Torque is not yet initialized.public static Database getOrCreateDatabase(String name)
databaseName
.
If no database is associated to the specified key,
a new database is created, mapped to the specified key, and returned.
name
- the key to get the database for, not null.
IllegalArgumentException
- if databaseName is null.public static Map<String,Database> getDatabases() throws TorqueException
TorqueException
- if Torque is not yet initialized.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |