Mercurial > dive4elements > framework
comparison 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 |
comparison
equal
deleted
inserted
replaced
127:0245a87df368 | 128:bfa65a812c7a |
---|---|
77 * The SQL statement to replace the content of an | 77 * The SQL statement to replace the content of an |
78 * existing artifact inside the database. | 78 * existing artifact inside the database. |
79 */ | 79 */ |
80 public static final String SQL_REPLACE = | 80 public static final String SQL_REPLACE = |
81 SQL.get("artifacts.replace"); | 81 SQL.get("artifacts.replace"); |
82 | |
83 /** The singleton.*/ | |
84 protected static Backend instance; | |
82 | 85 |
83 /** | 86 /** |
84 * The database cleaner. Reference is stored here because | 87 * The database cleaner. Reference is stored here because |
85 * the cleaner is woken up if the backend finds an outdated | 88 * the cleaner is woken up if the backend finds an outdated |
86 * artifact. This artifact should be removed as soon as | 89 * artifact. This artifact should be removed as soon as |
205 */ | 208 */ |
206 public Backend(DatabaseCleaner cleaner) { | 209 public Backend(DatabaseCleaner cleaner) { |
207 this.cleaner = cleaner; | 210 this.cleaner = cleaner; |
208 } | 211 } |
209 | 212 |
213 | |
214 /** | |
215 * Returns the singleton of this Backend. | |
216 * | |
217 * @return the backend. | |
218 */ | |
219 public static synchronized Backend getInstance() { | |
220 if (instance == null) { | |
221 instance = new Backend(); | |
222 } | |
223 | |
224 return instance; | |
225 } | |
226 | |
210 /** | 227 /** |
211 * Sets the factory lookup mechanism to decouple ArtifactDatabase | 228 * Sets the factory lookup mechanism to decouple ArtifactDatabase |
212 * and Backend. | 229 * and Backend. |
213 * @param factoryLookup | 230 * @param factoryLookup |
214 */ | 231 */ |