org.apache.torque.avalon
Interface Torque

All Superinterfaces:
org.apache.avalon.framework.component.Component
All Known Implementing Classes:
TorqueComponent

public interface Torque
extends org.apache.avalon.framework.component.Component

Avalon role interface for Torque.

Version:
$Id: Torque.java 493449 2007-01-06 11:46:50Z tv $
Author:
Henning P. Schmiedehausen, Thomas Vandahl

Field Summary
static java.lang.String ROLE
          The avalon role.
 
Method Summary
 void closeConnection(java.sql.Connection con)
          Closes a connection.
 org.apache.commons.configuration.Configuration getConfiguration()
          Get the configuration for this component.
 java.sql.Connection getConnection()
          This method returns a Connection from the default pool.
 java.sql.Connection getConnection(java.lang.String name)
           
 java.sql.Connection getConnection(java.lang.String name, java.lang.String username, java.lang.String password)
          This method returns a Connecton using the given parameters.
 Database getDatabase(java.lang.String databaseName)
          Returns the database for the key databaseName.
 DatabaseMap getDatabaseMap()
          Returns the default database map information.
 DatabaseMap getDatabaseMap(java.lang.String name)
          Returns the database map information.
 java.util.Map getDatabases()
          Returns a Map containing all Databases registered to Torque.
 DB getDB(java.lang.String name)
          Returns database adapter for a specific connection pool.
 java.lang.String getDefaultDB()
          Returns the name of the default database.
 AbstractBaseManager getManager(java.lang.String name)
          This method returns a Manager for the given name.
 AbstractBaseManager getManager(java.lang.String name, java.lang.String defaultClassName)
          This methods returns either the Manager from the configuration file, or the default one provided by the generated code.
 MapBuilder getMapBuilder(java.lang.String className)
          Get a MapBuilder
 Database getOrCreateDatabase(java.lang.String databaseName)
          Returns the database for the key databaseName.
 java.lang.String getSchema(java.lang.String name)
          This method returns the current schema for a database connection
 boolean isInit()
          Determine whether Torque has already been initialized.
 void registerMapBuilder(MapBuilder builder)
          Register a MapBuilder
 void registerMapBuilder(java.lang.String className)
          Register a MapBuilder
 void setSchema(java.lang.String name, java.lang.String schema)
          Sets the current schema for a database connection
 

Field Detail

ROLE

static final java.lang.String ROLE
The avalon role.

Method Detail

isInit

boolean isInit()
Determine whether Torque has already been initialized.

Returns:
true if Torque is already initialized

getConfiguration

org.apache.commons.configuration.Configuration getConfiguration()
Get the configuration for this component.

Returns:
the Configuration

getManager

AbstractBaseManager getManager(java.lang.String name)
This method returns a Manager for the given name.

Parameters:
name - name of the manager
Returns:
a Manager

getManager

AbstractBaseManager getManager(java.lang.String name,
                               java.lang.String defaultClassName)
This methods returns either the Manager from the configuration file, or the default one provided by the generated code.

Parameters:
name - name of the manager
defaultClassName - the class to use if name has not been configured
Returns:
a Manager

getDatabaseMap

DatabaseMap getDatabaseMap()
                           throws TorqueException
Returns the default database map information.

Returns:
A DatabaseMap.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getDatabaseMap

DatabaseMap getDatabaseMap(java.lang.String name)
                           throws TorqueException
Returns the database map information. Name relates to the name of the connection pool to associate with the map.

Parameters:
name - The name of the database corresponding to the DatabaseMap to retrieve.
Returns:
The named DatabaseMap.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

registerMapBuilder

void registerMapBuilder(java.lang.String className)
Register a MapBuilder

Parameters:
className - the MapBuilder

registerMapBuilder

void registerMapBuilder(MapBuilder builder)
Register a MapBuilder

Parameters:
builder - the instance of the MapBuilder

getMapBuilder

MapBuilder getMapBuilder(java.lang.String className)
                         throws TorqueException
Get a MapBuilder

Parameters:
className - of the MapBuilder
Returns:
A MapBuilder, not null
Throws:
TorqueException - if the Map Builder cannot be instantiated

getConnection

java.sql.Connection getConnection()
                                  throws TorqueException
This method returns a Connection from the default pool.

Returns:
The requested connection.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getConnection

java.sql.Connection getConnection(java.lang.String name)
                                  throws TorqueException
Parameters:
name - The database name.
Returns:
a database connection
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getConnection

java.sql.Connection getConnection(java.lang.String name,
                                  java.lang.String username,
                                  java.lang.String password)
                                  throws TorqueException
This method returns a Connecton using the given parameters. You should only use this method if you need user based access to the database!

Parameters:
name - The database name.
username - The name of the database user.
password - The password of the database user.
Returns:
A Connection.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getDB

DB getDB(java.lang.String name)
         throws TorqueException
Returns database adapter for a specific connection pool.

Parameters:
name - A pool name.
Returns:
The corresponding database adapter.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getDefaultDB

java.lang.String getDefaultDB()
Returns the name of the default database.

Returns:
name of the default DB

closeConnection

void closeConnection(java.sql.Connection con)
Closes a connection.

Parameters:
con - A Connection to close.

setSchema

void setSchema(java.lang.String name,
               java.lang.String schema)
               throws TorqueException
Sets the current schema for a database connection

Parameters:
name - The database name.
schema - The current schema name
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getSchema

java.lang.String getSchema(java.lang.String name)
                           throws TorqueException
This method returns the current schema for a database connection

Parameters:
name - The database name.
Returns:
The current schema name. Null means, no schema has been set.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getDatabase

Database getDatabase(java.lang.String databaseName)
                     throws TorqueException
Returns the database for the key databaseName.

Parameters:
databaseName - the key to get the database for.
Returns:
the database for the specified key, or null if the database does not exist.
Throws:
TorqueException - if Torque is not yet initialized.

getDatabases

java.util.Map getDatabases()
                           throws TorqueException
Returns a Map containing all Databases registered to Torque. The key of the Map is the name of the database, and the value is the database instance.
Note that in the very special case where a new database which is not configured in Torque's configuration gets known to Torque at a later time, the returned map may change, and there is no way to protect you against this.

Returns:
a Map containing all Databases known to Torque, never null.
Throws:
TorqueException - if Torque is not yet initialized.

getOrCreateDatabase

Database getOrCreateDatabase(java.lang.String databaseName)
Returns the database for the key databaseName. If no database is associated to the specified key, a new database is created, mapped to the specified key, and returned.

Parameters:
databaseName - the key to get the database for.
Returns:
the database associated with specified key, or the newly created database, never null.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.