Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 1060:cc4ec127d666
Remove the elements of an outdated state from cache if its endOfLife method is called.
gnv-artifacts/trunk@1143 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 01 Jun 2010 16:54:21 +0000 |
parents | 9981452c7e75 |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
1059:174f6eacd595 | 1060:cc4ec127d666 |
---|---|
957 | 957 |
958 this.hash = newHash + nhash; | 958 this.hash = newHash + nhash; |
959 } | 959 } |
960 | 960 |
961 | 961 |
962 protected String getHash(String uuid) { | 962 protected String getHash() { |
963 return this.hash; | 963 return this.hash; |
964 } | 964 } |
965 | 965 |
966 | 966 |
967 public List<Object> getDescibeData(String uuid) { | 967 public List<Object> getDescibeData(String uuid) { |
968 CacheFactory factory = CacheFactory.getInstance(); | 968 CacheFactory factory = CacheFactory.getInstance(); |
969 if (factory.isInitialized()) { | 969 if (factory.isInitialized()) { |
970 // we use a cache | 970 // we use a cache |
971 Cache cache = factory.getCache(); | 971 Cache cache = factory.getCache(); |
972 String key = getHash(uuid); | 972 String key = getHash(); |
973 | 973 |
974 log.debug("Using cache - key: " + key); | 974 log.debug("Using cache - key: " + key); |
975 | 975 |
976 net.sf.ehcache.Element value = cache.get(key); | 976 net.sf.ehcache.Element value = cache.get(key); |
977 if (value != null) { | 977 if (value != null) { |
1057 return null; | 1057 return null; |
1058 } | 1058 } |
1059 | 1059 |
1060 | 1060 |
1061 public void endOfLife(Object globalContext) { | 1061 public void endOfLife(Object globalContext) { |
1062 log.debug("end of life of the current state."); | |
1063 | |
1064 CacheFactory factory = CacheFactory.getInstance(); | |
1065 if (factory.isInitialized()) { | |
1066 Cache cache = factory.getCache(); | |
1067 String key = getHash(); | |
1068 | |
1069 if (key != null && cache.remove(key)) { | |
1070 log.info("Removed element from cache - key: " + key); | |
1071 } | |
1072 } | |
1062 } | 1073 } |
1063 | 1074 |
1064 | 1075 |
1065 public void cleanup(Object context) { | 1076 public void cleanup(Object context) { |
1066 } | 1077 } |