diff artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java @ 87:0f48188a6e02

Added some javadoc to the artifactdatabase module. Not done yet. artifacts/trunk@839 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 26 Mar 2010 11:40:28 +0000
parents 93edc04f3a10
children d348fe1fd822
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java	Fri Mar 26 10:04:34 2010 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java	Fri Mar 26 11:40:28 2010 +0000
@@ -11,35 +11,72 @@
 import org.apache.log4j.Logger;
 
 /**
- *  @author Sascha L. Teichmann
+ * This class encapsulate the creation and pooling of database connections used
+ * by the artifact database. The credential to open the database connections
+ * are taken from the global configuratiion.
+ * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public class DBConnection
 {
     private static Logger logger = Logger.getLogger(DBConnection.class);
 
+    /**
+     * XPath to access the database driver within the global configuration.
+     */
     public static final String DB_DRIVER =
         "/artifact-database/database/driver/text()";
+    /**
+     * XPath to access the database URL within the global configuration.
+     */
     public static final String DB_URL =
         "/artifact-database/database/url/text()";
+    /**
+     * XPath to access the database use within the global configuration.
+     */
     public static final String DB_USER =
         "/artifact-database/database/user/text()";
+    /**
+     * XPath to access the database password within the global configuration.
+     */
     public static final String DB_PASSWORD =
         "/artifact-database/database/password/text()";
 
+    /**
+     * The default database driver: H2
+     */
     public static final String DEFAULT_DRIVER =
         "org.h2.Driver";
 
+    /**
+     * The default database name: artifacts.db
+     */
     public static final String DEFAULT_DATABASE_FILE =
         "artifacts.db";
 
+    /**
+     * The default database URL: This is created once by #getDefaultURL()
+     */
     public static final String DEFAULT_URL = getDefaultURL();
 
+    /**
+     * The default database user: ""
+     */
     public static final String DEFAULT_USER     = "";
+
+    /**
+     * The default database password: ""
+     */
     public static final String DEFAULT_PASSWORD = "";
 
     private DBConnection() {
     }
 
+    /**
+     * Constructs the default databse URL. It concats the
+     * config directory and the #DEFAULT_DATABASE_FILE
+     * to the string with is needed to access H2 databases.
+     * @return
+     */
     public static final String getDefaultURL() {
         File configDir = Config.getConfigDirectory();
         File databaseFile = new File(configDir, DEFAULT_DATABASE_FILE);
@@ -50,6 +87,7 @@
 
     private static final void addShutdownHook() {
         Runtime.getRuntime().addShutdownHook(new Thread() {
+            @Override
             public void run() {
                 if (dataSource != null) {
                     try {
@@ -63,6 +101,10 @@
         });
     }
 
+    /**
+     * Static method to fetch a database connection.
+     * @return a DataSource to access the database connection.
+     */
     public static synchronized DataSource getDataSource() {
         if (dataSource == null) {
             dataSource = new BasicDataSource();

http://dive4elements.wald.intevation.org