Package org.apache.torque.avalon

# Schnittstelle Torque

Alle Superschnittstellen:
  `org.apache.avalon.framework.component.Component`

Alle bekannten Implementierungsklassen:
  `TorqueComponent`

public interface Torque extends org.apache.avalon.framework.component.Component
Avalon role interface for Torque.

Version:
  $Id: Torque.java 1917245 2024-04-21 14:06:23Z tv $
Autor:
  Henning P. Schmiedehausen, Thomas Vandahl

- ## Feldübersicht

  Felder
  Modifizierer und Typ
  Feld
  Beschreibung
  `static final String`
  `ROLE`
  The avalon role.

- ## Methodenübersicht

  Modifizierer und Typ
  Methode
  Beschreibung
  `void`
  `closeConnection(Connection con)`
  Closes a connection.
  `Adapter`
  `getAdapter(String name)`
  Returns database adapter for a specific connection pool.
  `org.apache.commons.configuration2.Configuration`
  `getConfiguration()`
  Get the configuration for this component.
  `Connection`
  `getConnection()`
  This method returns a Connection from the default pool.
  `Connection`
  `getConnection(String name)`
  `Connection`
  `getConnection(String name, String username, String password)`
  This method returns a Connecton using the given parameters.
  `Database`
  `getDatabase(String databaseName)`
  Returns the database for the key `databaseName`.
  `DatabaseMap`
  `getDatabaseMap()`
  Returns the default database map information.
  `DatabaseMap`
  `getDatabaseMap(String name)`
  Returns the database map information.
  `Map<String,Database>`
  `getDatabases()`
  Returns a Map containing all Databases registered to Torque.
  `String`
  `getDefaultDB()`
  Returns the name of the default database.
  `<T extends AbstractBaseManager<? extends Persistent>>
  T`
  `getManager(String name)`
  This method returns a Manager for the given name.
  `<T extends AbstractBaseManager<? extends Persistent>>
  T`
  `getManager(String name, String defaultClassName)`
  This methods returns either the Manager from the configuration file, or the default one provided by the generated code.
  `Database`
  `getOrCreateDatabase(String databaseName)`
  Returns the database for the key `databaseName`.
  `String`
  `getSchema(String name)`
  This method returns the current schema for a database connection
  `boolean`
  `isInit()`
  Determine whether Torque has already been initialized.
  `void`
  `setSchema(String name, String schema)`
  Sets the current schema for a database connection

- ## Felddetails

  - ### ROLE

    static final String ROLE
    The avalon role.

- ## Methodendetails

  - ### isInit

    boolean isInit()
    Determine whether Torque has already been initialized.
    Gibt zurück:
      true if Torque is already initialized

  - ### getConfiguration

    org.apache.commons.configuration2.Configuration getConfiguration()
    Get the configuration for this component.
    Gibt zurück:
      the Configuration

  - ### getManager

    <T extends AbstractBaseManager<? extends Persistent>> T getManager(String name)
    This method returns a Manager for the given name.
    Typparameter:
      `T` - manager class type
    Parameter:
      `name` - name of the manager
    Gibt zurück:
      a Manager

  - ### getManager

    <T extends AbstractBaseManager<? extends Persistent>> T getManager(String name, String defaultClassName)
    This methods returns either the Manager from the configuration file, or the default one provided by the generated code.
    Typparameter:
      `T` - manager class type
    Parameter:
      `name` - name of the manager
      `defaultClassName` - the class to use if name has not been configured
    Gibt zurück:
      a Manager

  - ### getDatabaseMap

    DatabaseMap getDatabaseMap() throws TorqueException
    Returns the default database map information.
    Gibt zurück:
      A DatabaseMap.
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getDatabaseMap

    DatabaseMap getDatabaseMap(String name) throws TorqueException
    Returns the database map information. Name relates to the name of the connection pool to associate with the map.
    Parameter:
      `name` - The name of the database corresponding to the `DatabaseMap` to retrieve.
    Gibt zurück:
      The named `DatabaseMap`.
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getConnection

    Connection getConnection() throws TorqueException
    This method returns a Connection from the default pool.
    Gibt zurück:
      The requested connection.
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getConnection

    Connection getConnection(String name) throws TorqueException
    Parameter:
      `name` - The database name.
    Gibt zurück:
      a database connection
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getConnection

    Connection getConnection(String name, String username, 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!
    Parameter:
      `name` - The database name.
      `username` - The name of the database user.
      `password` - The password of the database user.
    Gibt zurück:
      A Connection.
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getAdapter

    Adapter getAdapter(String name) throws TorqueException
    Returns database adapter for a specific connection pool.
    Parameter:
      `name` - A pool name.
    Gibt zurück:
      The corresponding database adapter.
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getDefaultDB

    String getDefaultDB()
    Returns the name of the default database.
    Gibt zurück:
      name of the default DB

  - ### closeConnection

    void closeConnection(Connection con)
    Closes a connection.
    Parameter:
      `con` - A Connection to close.

  - ### setSchema

    void setSchema(String name, String schema) throws TorqueException
    Sets the current schema for a database connection
    Parameter:
      `name` - The database name.
      `schema` - The current schema name
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getSchema

    String getSchema(String name) throws TorqueException
    This method returns the current schema for a database connection
    Parameter:
      `name` - The database name.
    Gibt zurück:
      The current schema name. Null means, no schema has been set.
    Löst aus:
      `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

  - ### getDatabase

    Database getDatabase(String databaseName) throws TorqueException
    Returns the database for the key `databaseName`.
    Parameter:
      `databaseName` - the key to get the database for.
    Gibt zurück:
      the database for the specified key, or null if the database does not exist.
    Löst aus:
      `TorqueException` - if Torque is not yet initialized.

  - ### getDatabases

    Map<String,Database> 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.

    Gibt zurück:
      a Map containing all Databases known to Torque, never null.
    Löst aus:
      `TorqueException` - if Torque is not yet initialized.

  - ### getOrCreateDatabase

    Database getOrCreateDatabase(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.
    Parameter:
      `databaseName` - the key to get the database for.
    Gibt zurück:
      the database associated with specified key, or the newly created database, never null.