org.apache.torque
Class Database

java.lang.Object
  extended by org.apache.torque.Database

public class Database
extends Object

Bundles all information about a database. This includes the database adapter, the database Map and the Data Source Factory.


Method Summary
 void addIdGenerator(String type, IdGenerator idGen)
          Adds an IdGenerator to the database.
 DB getAdapter()
          Returns the adapther to this database.
 DatabaseMap getDatabaseMap()
          Returns the database map for this database.
 DataSourceFactory getDataSourceFactory()
          Returns the DataSourceFactory for this database.
 IDBroker getIDBroker()
          Get the IDBroker for this database.
 IdGenerator getIdGenerator(String type)
          Returns the IdGenerator of the given type for this Database.
 String getName()
          returns the name of the database.
 String getSchema()
          Returns the database schema for this Database.
 void setAdapter(DB anAdapter)
          Sets the adapter for this database.
 void setDataSourceFactory(DataSourceFactory aDataSourceFactory)
          Sets the DataSourceFactory for this database.
 void setSchema(String schema)
          Sets the schema for this database.
 boolean startIDBroker()
          Creates the IDBroker for this DatabaseMap and starts it for the given database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public String getName()
returns the name of the database.

Returns:
the name of the database. May be null.

getAdapter

public DB getAdapter()
Returns the adapther to this database.

Returns:
the adapter to this database, or null if no adapter is set.

setAdapter

public void setAdapter(DB anAdapter)
Sets the adapter for this database.

Parameters:
anAdapter - The adapter for this database, or null to remove the current adapter from this database.

getDatabaseMap

public DatabaseMap getDatabaseMap()
Returns the database map for this database. If the database map does not exist yet, it is created by this method.


getDataSourceFactory

public DataSourceFactory getDataSourceFactory()
Returns the DataSourceFactory for this database. The DataSourceFactory is responsible to create connections to this database.

Returns:
the DataSourceFactory for this database, or null if no DataSourceFactory exists for this database.

setDataSourceFactory

public void setDataSourceFactory(DataSourceFactory aDataSourceFactory)
Sets the DataSourceFactory for this database. The DataSourceFactory is responsible to create connections to this database.

Parameters:
aDataSourceFactory - The new DataSorceFactory for this database, or null to remove the current DataSourceFactory.

getIDBroker

public IDBroker getIDBroker()
Get the IDBroker for this database.

Returns:
The IDBroker for this database, or null if no IdBroker has been started for this database.

startIDBroker

public boolean startIDBroker()
Creates the IDBroker for this DatabaseMap and starts it for the given database. The information about the IdTable is stored in the databaseMap. If an IDBroker already exists for the DatabaseMap, the method does nothing.

Returns:
true if a new IDBroker was created, false otherwise.

getIdGenerator

public IdGenerator getIdGenerator(String type)
Returns the IdGenerator of the given type for this Database.

Parameters:
type - The type (i.e.name) of the IdGenerator
Returns:
The IdGenerator of the requested type, or null if no IdGenerator exists for the requested type.

addIdGenerator

public void addIdGenerator(String type,
                           IdGenerator idGen)
Adds an IdGenerator to the database.

Parameters:
type - The type of the IdGenerator
idGen - The new IdGenerator for the type, or null to remove the IdGenerator of the given type.

getSchema

public String getSchema()
Returns the database schema for this Database.

Returns:
the database schema for this database, or null if no schema has been set.

setSchema

public void setSchema(String schema)
Sets the schema for this database.

Parameters:
schema - the name of the database schema to set, or null to remove the current schema.
Throws:
NullPointerException - if no DatasourceFactory exists for this database.


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