diff artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 128:bfa65a812c7a

Made the backend singleton. artifacts/trunk@1352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 01 Mar 2011 18:52:48 +0000
parents 933bbc9fc11f
children 2950c6011afa
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Tue Mar 01 18:45:34 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Tue Mar 01 18:52:48 2011 +0000
@@ -80,6 +80,9 @@
     public static final String SQL_REPLACE =
         SQL.get("artifacts.replace");
 
+    /** The singleton.*/
+    protected static Backend instance;
+
     /**
      * The database cleaner. Reference is stored here because
      * the cleaner is woken up if the backend finds an outdated
@@ -207,6 +210,20 @@
         this.cleaner = cleaner;
     }
 
+
+    /**
+     * Returns the singleton of this Backend.
+     *
+     * @return the backend.
+     */
+    public static synchronized Backend getInstance() {
+        if (instance == null) {
+            instance = new Backend();
+        }
+
+        return instance;
+    }
+
     /**
      * Sets the factory lookup mechanism to decouple ArtifactDatabase
      * and Backend.

http://dive4elements.wald.intevation.org