Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/CacheInvalidationService.java @ 3818:dc18457b1cef
merged flys-artifacts/pre2.7-2012-03-16
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:59 +0200 |
parents | 0ccabd82ec76 |
children | 247f3e98a14b |
comparison
equal
deleted
inserted
replaced
2456:60ab1054069d | 3818:dc18457b1cef |
---|---|
1 package de.intevation.flys.artifacts.services; | |
2 | |
3 import de.intevation.artifacts.CallMeta; | |
4 import de.intevation.artifacts.GlobalContext; | |
5 | |
6 import de.intevation.artifacts.common.utils.XMLUtils; | |
7 | |
8 import de.intevation.artifactdatabase.DefaultService; | |
9 | |
10 import de.intevation.flys.artifacts.cache.CacheFactory; | |
11 | |
12 import net.sf.ehcache.Cache; | |
13 | |
14 import org.w3c.dom.Document; | |
15 import org.w3c.dom.Element; | |
16 import org.w3c.dom.NodeList; | |
17 | |
18 public class CacheInvalidationService | |
19 extends DefaultService | |
20 { | |
21 @Override | |
22 public Document process( | |
23 Document data, | |
24 GlobalContext globalContext, | |
25 CallMeta callMeta | |
26 ) { | |
27 Document result = XMLUtils.newDocument(); | |
28 | |
29 Element all = result.createElement("caches"); | |
30 | |
31 NodeList caches = data.getElementsByTagName("cache"); | |
32 | |
33 for (int i = 0, C = caches.getLength(); i < C; ++i) { | |
34 Element c = (Element)caches.item(i); | |
35 String name = c.getAttribute("name"); | |
36 Element e = result.createElement("cache"); | |
37 e.setAttribute("name", name); | |
38 Cache cache = CacheFactory.getCache(name); | |
39 if (cache != null) { | |
40 cache.removeAll(); | |
41 e.setTextContent("All elements removed."); | |
42 } | |
43 else { | |
44 e.setTextContent("Error: Cache not found."); | |
45 } | |
46 all.appendChild(e); | |
47 } | |
48 | |
49 result.appendChild(all); | |
50 | |
51 return result; | |
52 } | |
53 } | |
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |