1 4 package com.tc.objectserver.persistence.impl; 5 6 import com.tc.exception.TCRuntimeException; 7 import com.tc.objectserver.persistence.api.ClassPersistor; 8 9 import java.util.HashMap ; 10 import java.util.Map ; 11 12 public class InMemoryClassPersistor implements ClassPersistor { 13 14 Map clazzes = new HashMap (); 15 16 public InMemoryClassPersistor() { 17 super(); 18 } 19 20 public void storeClass(int clazzId, byte[] clazzBytes) { 21 clazzes.put(new Integer (clazzId), clazzBytes); 22 } 23 24 public byte[] retrieveClass(int clazzId) { 25 byte[] clazzbytes = (byte[]) clazzes.get(new Integer (clazzId)); 26 if (clazzbytes == null) { throw new TCRuntimeException("Class bytes not found : " + clazzId); } 27 return clazzbytes; 28 } 29 30 public Map retrieveAllClasses() { 31 return new HashMap (clazzes); 32 } 33 34 } 35 | Popular Tags |