01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.objectserver.persistence.impl;
05:
06: import com.tc.exception.TCRuntimeException;
07: import com.tc.objectserver.persistence.api.ClassPersistor;
08:
09: 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) {
27: throw new TCRuntimeException("Class bytes not found : "
28: + clazzId);
29: }
30: return clazzbytes;
31: }
32:
33: public Map retrieveAllClasses() {
34: return new HashMap(clazzes);
35: }
36:
37: }
|