Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 30:88972c6daa4f
Added a cleanup thread which periodically removes
outdated artifacts from database and calls there
endOfLife() method.
artifacts/trunk@70 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 10 Sep 2009 23:16:18 +0000 |
parents | 75bdaf900473 |
children | c4d85a8532d1 |
comparison
equal
deleted
inserted
replaced
29:22b03d5c84c5 | 30:88972c6daa4f |
---|---|
45 public static final String SQL_TOUCH = | 45 public static final String SQL_TOUCH = |
46 SQL.get("artifacts.touch"); | 46 SQL.get("artifacts.touch"); |
47 | 47 |
48 public static final String SQL_LOAD_BY_GID = | 48 public static final String SQL_LOAD_BY_GID = |
49 SQL.get("artifacts.select.gid"); | 49 SQL.get("artifacts.select.gid"); |
50 | |
51 protected DatabaseCleaner cleaner; | |
50 | 52 |
51 /** | 53 /** |
52 * Used to wrap the calls to invole database actions. | 54 * Used to wrap the calls to invole database actions. |
53 */ | 55 */ |
54 public class ArtifactProxy | 56 public class ArtifactProxy |
151 } // class ArtifactProxy | 153 } // class ArtifactProxy |
152 | 154 |
153 public Backend() { | 155 public Backend() { |
154 } | 156 } |
155 | 157 |
158 public Backend(DatabaseCleaner cleaner) { | |
159 this.cleaner = cleaner; | |
160 } | |
161 | |
156 public Artifact getArtifact(String idenitfier) { | 162 public Artifact getArtifact(String idenitfier) { |
157 UUID uuid; | 163 UUID uuid; |
158 | 164 |
159 try { | 165 try { |
160 uuid = UUID.fromString(idenitfier); | 166 uuid = UUID.fromString(idenitfier); |
249 return null; | 255 return null; |
250 } | 256 } |
251 | 257 |
252 public static Artifact restoreArtifact(byte [] bytes) { | 258 public static Artifact restoreArtifact(byte [] bytes) { |
253 | 259 |
260 if (bytes == null) { | |
261 return null; | |
262 } | |
263 | |
254 ObjectInputStream ois = null; | 264 ObjectInputStream ois = null; |
255 | 265 |
256 try { | 266 try { |
257 ByteArrayInputStream bis = new ByteArrayInputStream(bytes); | 267 ByteArrayInputStream bis = new ByteArrayInputStream(bytes); |
258 GZIPInputStream gis = new GZIPInputStream(bis); | 268 GZIPInputStream gis = new GZIPInputStream(bis); |
279 return null; | 289 return null; |
280 } | 290 } |
281 | 291 |
282 protected void artifactOutdated(int id) { | 292 protected void artifactOutdated(int id) { |
283 logger.info("artifactOutdated: id = " + id); | 293 logger.info("artifactOutdated: id = " + id); |
294 if (cleaner != null) { | |
295 cleaner.wakeup(); | |
296 } | |
284 } | 297 } |
285 | 298 |
286 protected int insertDatabase(UUID uuid, Long ttl) { | 299 protected int insertDatabase(UUID uuid, Long ttl) { |
287 Connection connection = null; | 300 Connection connection = null; |
288 PreparedStatement stmnt_next_id = null; | 301 PreparedStatement stmnt_next_id = null; |