Author: tfischer
Date: Wed May 9 12:41:15 2012
New Revision: 1336147
URL: http://svn.apache.org/viewvc?rev=1336147&view=rev
Log:
remove outdated comments
fix javadoc
improve logging
split long code lines
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1336147&r1=1336146&r2=1336147&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
Wed May 9 12:41:15 2012
@@ -90,11 +90,11 @@ public class TorqueInstance
/** Torque-specific configuration. */
private Configuration conf;
- /** flag to set to true once this class has been initialized */
+ /** Flag to set to true once this class has been initialized */
private boolean isInit = false;
/**
- * a flag which indicates whether the DataSourceFactory in the database
+ * A flag which indicates whether the DataSourceFactory in the database
* named <code>DEFAULT</code> is a reference to another
* DataSourceFactory. This is important to know when closing the
* DataSourceFactories on shutdown();
@@ -134,12 +134,6 @@ public class TorqueInstance
+ "for further details.");
}
- // Now that we have dealt with processing the log4j properties
- // that may be contained in the configuration we will make the
- // configuration consist only of the remain torque specific
- // properties that are contained in the configuration. First
- // look for properties that are in the "torque" namespace.
-
initTransactionManager(conf);
initDefaultDbName(conf);
initDataSourceFactories(conf);
@@ -167,7 +161,8 @@ public class TorqueInstance
if ((!defaultDBName.equals(DEFAULT_NAME))
&& databaseInfoForKeyDefault.getDataSourceFactory() == null)
{
- log.debug("Adding the DatasourceFactory and DatabaseAdapter
from database "
+ log.debug("Adding the DatasourceFactory and DatabaseAdapter "
+ + "from database "
+ defaultDBName
+ " onto database " + DEFAULT_NAME);
databaseInfoForKeyDefault.setDataSourceFactory(
@@ -188,17 +183,19 @@ public class TorqueInstance
/**
- * Initializes the name of the default database and
- * associates the database with the name <code>DEFAULT_NAME</code>
- * to the default database.
+ * Initializes the transaction manager.
*
* @param conf the configuration representing the torque section.
* of the properties file.
- * @throws TorqueException if the appropriate key is not set.
+ *
+ * @throws TorqueException if the transaction manger configuration
+ * is invalid.
*/
private void initTransactionManager(Configuration conf)
throws TorqueException
{
+ log.debug("initTransactionManager(" + conf + ")");
+
String transactionManagerClassName =
conf.getString(Torque.TRANSACTION_MANAGER_KEY);
TransactionManager transactionManager;
@@ -245,11 +242,14 @@ public class TorqueInstance
*
* @param conf the configuration representing the torque section.
* of the properties file.
+ *
* @throws TorqueException if the appropriate key is not set.
*/
private void initDefaultDbName(Configuration conf)
throws TorqueException
{
+ log.debug("initDefaultDbName(" + conf + ")");
+
// Determine default database name.
defaultDBName =
conf.getString(
@@ -276,7 +276,8 @@ public class TorqueInstance
* to the databases.
*
* @param conf the Configuration representing the torque section of the
- * properties file
+ * properties file.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -317,12 +318,15 @@ public class TorqueInstance
Connection con = null;
try
{
- con =
database.getDataSourceFactory().getDataSource().getConnection();
+ con = database.getDataSourceFactory()
+ .getDataSource().getConnection();
db = DBFactory.autoDetectAdapter(con);
}
catch (SQLException e)
{
- log.error("Could not get product information from
JDBC", e);
+ log.error(
+ "Could not get product information from JDBC",
+ e);
}
finally
{
@@ -337,7 +341,8 @@ public class TorqueInstance
// Not supported, try manually defined adapter class
if (db == null)
{
- String adapterClassName = c.getString(key + "." +
adapter + ".className", null);
+ String adapterClassName = c.getString(
+ key + "." + adapter + ".className", null);
db = DBFactory.create(adapter, adapterClassName);
}
@@ -394,7 +399,8 @@ public class TorqueInstance
* of the default database is made from the database with the name
* <code>DEFAULT_NAME</code>.
*
- * @param conf the Configuration representing the properties file
+ * @param conf the Configuration representing the properties file.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -482,6 +488,15 @@ public class TorqueInstance
}
}
+ /**
+ * Reads the schema configuration from the database definitions in
+ * the configuration and assigns the defined schemata to the databases.
+ *
+ * @param conf the Configuration representing the properties file.
+ *
+ * @throws TorqueException Any exceptions caught during processing will be
+ * rethrown wrapped into a TorqueException.
+ */
private void initSchemata(Configuration conf)
throws TorqueException
{
@@ -547,9 +562,10 @@ public class TorqueInstance
}
/**
- * Initialization of Torque with a properties file.
+ * Initialization of Torque with a path to a properties file.
*
* @param configFile The absolute path to the configuration file.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -575,6 +591,7 @@ public class TorqueInstance
* Initialization of Torque with a Configuration object.
*
* @param conf The Torque configuration.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -759,8 +776,9 @@ public class TorqueInstance
* This methods returns either the Manager from the configuration file,
* or the default one provided by the generated code.
*
- * @param name name of the manager
- * @param defaultClassName the class to use if name has not been configured
+ * @param name name of the manager.
+ * @param defaultClassName the class to use if name has not been
configured.
+ *
* @return a Manager
*/
public AbstractBaseManager getManager(String name,
@@ -789,12 +807,13 @@ public class TorqueInstance
}
/**
- * Shuts down the service.
+ * Shuts down Torque.
*
* This method halts the IDBroker's daemon thread in all of
* the DatabaseMap's. It also closes all SharedPoolDataSourceFactories
* and PerUserPoolDataSourceFactories initialized by Torque.
- * @exception TorqueException if a DataSourceFactory could not be closed
+ *
+ * @throws TorqueException if a DataSourceFactory could not be closed
* cleanly. Only the first exception is rethrown, any following
* exceptions are logged but ignored.
*/
@@ -872,8 +891,7 @@ public class TorqueInstance
}
/**
- * Resets some internal configuration variables to
- * their defaults.
+ * Resets some internal configuration variables to their defaults.
*/
private void resetConfiguration()
{
@@ -882,9 +900,10 @@ public class TorqueInstance
}
/**
- * Returns the default database map information.
+ * Returns the database map information for the default db.
+ *
+ * @return the requested DatabaseMap, not null.
*
- * @return A DatabaseMap.
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -939,6 +958,7 @@ public class TorqueInstance
* This method returns a Connection from the default pool.
*
* @return The requested connection, never null.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -951,8 +971,11 @@ public class TorqueInstance
/**
* Returns a database connection to the database with the key
* <code>name</code>.
+ *
* @param name The database name.
- * @return a database connection, never null.
+ *
+ * @return a database connection to the named database, never null.
+ *
* @throws TorqueException If no DataSourceFactory is configured for the
* named database, the connection information is wrong, or the
* connection cannot be returned for any other reason.
@@ -982,8 +1005,10 @@ public class TorqueInstance
* <code>name</code>.
*
* @param name The name of the database to get the DSF for.
+ *
* @return A DataSourceFactory object, never null.
- * @throws TorqueException if Torque is not initiliaized, or
+ *
+ * @throws TorqueException if Torque is not initialized, or
* no DatasourceFactory is configured for the given name.
*/
public DataSourceFactory getDataSourceFactory(String name)
@@ -1015,7 +1040,9 @@ public class TorqueInstance
* @param name The database name.
* @param username The name of the database user.
* @param password The password of the database user.
- * @return A Connection.
+ *
+ * @return A Connection to the named database.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -1096,6 +1123,7 @@ public class TorqueInstance
*
* @param name The database name.
* @param schema The current schema name.
+ *
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
@@ -1109,7 +1137,9 @@ public class TorqueInstance
* This method returns the current schema for a database connection
*
* @param name The database name.
+ *
* @return 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.
*/
@@ -1158,6 +1188,7 @@ public class TorqueInstance
* protect you against this.
*
* @return a Map containing all Databases known to Torque, never null.
+ *
* @throws TorqueException if Torque is not yet initialized.
*/
public Map<String, Database> getDatabases() throws TorqueException
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]