* Make getConnection() and init() synchronized.

* Fix JavaDoc comments.
This commit is contained in:
hns 2005-11-17 16:23:51 +00:00
parent b51be97d41
commit dd8ac80a09

View file

@ -42,10 +42,9 @@ public class DbSource {
/** /**
* Creates a new DbSource object. * Creates a new DbSource object.
* *
* @param name ... * @param name the db source name
* @param props ... * @param props the properties
* * @throws ClassNotFoundException if the JDBC driver couldn't be loaded
* @throws ClassNotFoundException ...
*/ */
public DbSource(String name, ResourceProperties props) public DbSource(String name, ResourceProperties props)
throws ClassNotFoundException { throws ClassNotFoundException {
@ -55,14 +54,15 @@ public class DbSource {
} }
/** /**
* Get a JDBC connection to the db source.
* *
* @return a JDBC connection
* *
* @return ... * @throws ClassNotFoundException if the JDBC driver couldn't be loaded
* * @throws SQLException if the connection couldn't be created
* @throws ClassNotFoundException ...
* @throws SQLException ...
*/ */
public Connection getConnection() throws ClassNotFoundException, SQLException { public synchronized Connection getConnection()
throws ClassNotFoundException, SQLException {
Connection con = null; Connection con = null;
Transactor tx = null; Transactor tx = null;
if (Thread.currentThread() instanceof Transactor) { if (Thread.currentThread() instanceof Transactor) {
@ -93,7 +93,12 @@ public class DbSource {
return con; return con;
} }
private void init() throws ClassNotFoundException { /**
* Initialize the db source from the properties
*
* @throws ClassNotFoundException if the JDBC driver couldn't be loaded
*/
private synchronized void init() throws ClassNotFoundException {
lastRead = (defaultProps == null) ? props.lastModified() lastRead = (defaultProps == null) ? props.lastModified()
: Math.max(props.lastModified(), : Math.max(props.lastModified(),
defaultProps.lastModified()); defaultProps.lastModified());