|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.torque.TorqueInstance
The core of Torque's implementation. Both the classic Torque
static wrapper and the TorqueComponent
Avalon implementation leverage
this class.
Constructor Summary | |
TorqueInstance()
Creates a new instance with default configuration. |
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. |
DatabaseMap |
getDatabaseMap()
Returns the default database map information. |
DatabaseMap |
getDatabaseMap(java.lang.String name)
Returns the database map information. |
protected DataSourceFactory |
getDataSourceFactory(java.lang.String name)
Returns a DataSourceFactory |
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. |
java.lang.String |
getSchema(java.lang.String name)
This method returns the current schema for a database connection |
void |
init(org.apache.commons.configuration.Configuration conf)
Initialization of Torque with a properties file. |
void |
init(java.lang.String configFile)
Initialization of Torque with a properties file. |
protected void |
initManagerMappings(org.apache.commons.configuration.Configuration conf)
Creates a mapping between classes and their manager classes. |
boolean |
isInit()
Determine whether Torque has already been initialized. |
void |
registerMapBuilder(java.lang.String className)
Register a MapBuilder |
void |
setConfiguration(org.apache.commons.configuration.Configuration conf)
Sets the configuration for Torque and all dependencies. |
void |
setSchema(java.lang.String name,
java.lang.String schema)
Sets the current schema for a database connection |
void |
shutdown()
Shuts down the service. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TorqueInstance()
#resetConfiguration()
Method Detail |
public void init(java.lang.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 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.protected void initManagerMappings(org.apache.commons.configuration.Configuration conf) throws TorqueException
torque.managed_class.com.mycompany.Myclass.manager= \ com.mycompany.MyManagerImpl services.managed_class.com.mycompany.Myotherclass.manager= \ com.mycompany.MyOtherManagerImpl
conf
- the Configuration representing the properties file
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public boolean isInit()
public void setConfiguration(org.apache.commons.configuration.Configuration conf)
conf
- the Configurationpublic org.apache.commons.configuration.Configuration getConfiguration()
public AbstractBaseManager getManager(java.lang.String name)
name
- name of the manager
public AbstractBaseManager getManager(java.lang.String name, java.lang.String defaultClassName)
name
- name of the managerdefaultClassName
- the class to use if name has not been configured
public 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 DatabaseMap getDatabaseMap() throws TorqueException
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public DatabaseMap getDatabaseMap(java.lang.String name) throws TorqueException
name
- The name of the database corresponding to the
DatabaseMap
to retrieve.
DatabaseMap
.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public void registerMapBuilder(java.lang.String className)
className
- the MapBuilderpublic java.sql.Connection getConnection() throws TorqueException
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public java.sql.Connection getConnection(java.lang.String name) throws TorqueException
name
- The database name.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.protected DataSourceFactory getDataSourceFactory(java.lang.String name) throws TorqueException
name
- Name of the DSF to get
TorqueException
public java.sql.Connection getConnection(java.lang.String name, java.lang.String username, java.lang.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.public DB getDB(java.lang.String name) throws TorqueException
name
- A pool name.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public java.lang.String getDefaultDB()
public void closeConnection(java.sql.Connection con)
con
- A Connection to close.public void setSchema(java.lang.String name, java.lang.String schema) throws TorqueException
name
- The database name.schema
- The current schema name
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public java.lang.String getSchema(java.lang.String name) throws TorqueException
name
- The database name.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |