1 14 15 package org.apache.activemq.kaha.impl.index; 16 17 import java.io.IOException ; 18 import java.util.HashMap ; 19 import java.util.Map ; 20 import org.apache.activemq.kaha.Marshaller; 21 import org.apache.activemq.kaha.StoreEntry; 22 import org.apache.activemq.kaha.impl.container.MapContainerImpl; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 31 public class VMIndex implements Index{ 32 private static final Log log=LogFactory.getLog(VMIndex.class); 33 private IndexManager indexManager; 34 private Map <Object ,StoreEntry> map=new HashMap <Object ,StoreEntry>(); 35 36 public VMIndex(IndexManager manager) { 37 this.indexManager= manager; 38 } 39 43 public void clear(){ 44 map.clear(); 45 } 46 47 52 public boolean containsKey(Object key){ 53 return map.containsKey(key); 54 } 55 56 61 public StoreEntry remove(Object key){ 62 StoreEntry result = map.remove(key); 63 if (result != null) { 64 try{ 65 result=indexManager.refreshIndex((IndexItem)result); 66 }catch(IOException e){ 67 log.error("Failed to refresh entry",e); 68 throw new RuntimeException ("Failed to refresh entry"); 69 } 70 } 71 return result; 72 } 73 74 80 public void store(Object key,StoreEntry entry){ 81 map.put(key,entry); 82 } 83 84 88 public StoreEntry get(Object key){ 89 StoreEntry result = map.get(key); 90 if (result != null) { 91 try{ 92 result=indexManager.refreshIndex((IndexItem)result); 93 }catch(IOException e){ 94 log.error("Failed to refresh entry",e); 95 throw new RuntimeException ("Failed to refresh entry"); 96 } 97 } 98 return result; 99 } 100 101 104 public boolean isTransient(){ 105 return true; 106 } 107 108 111 public void load(){ 112 } 113 114 117 public void unload(){ 118 map.clear(); 119 } 120 121 122 public void setKeyMarshaller(Marshaller marshaller){ 123 } 124 } 125 | Popular Tags |