Hi. I'm designing Tile Cache for mapping service. I'm using Jboss Cache. I want to cache Tiles. Tiles are instances of class Image from SWT package. Those Images have dispose() method that should be called when You don't need the Image anymore.
I would like to invoke this method when node in cache that contains Image tile is evicted. I need this only for local cache on client application without replication and clusterring. I tried to make TileEvictionActionPolicy with such method:
@Override public boolean evict(Fqn fqn) { try { System.out.println("Start Eviction of: " + fqn); if (log.isTraceEnabled()) log.trace("Evicting Fqn " + fqn); Node<String, Object> node = (Node<String, Object>) cache.getNode(fqn); Image img = node.get("tile"); if (img!= null && !img.isDisposed())) { img.dispose(); } cache.evict(fqn); return true; } catch (Exception e) { if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e); return false; } }
Use a Cache Listener and register for the NodeEvicted callbacks.