001 /* 002 @license.text@ 003 */ 004 005 package biz.hammurapi.legacy.persistence; 006 007 import java.util.HashMap; 008 import java.util.Map; 009 010 /** 011 * This class allows to 012 * persist and unload from memory persistable objects which refer to 013 * non-persistable objects. 014 * @author Pavel Vlasov 015 * @version $Revision: 1.1 $ 016 */ 017 public class MemoryStorage implements Storage { 018 private static Map objects=new HashMap(); 019 private static int counter; 020 021 public String put(Object o) { 022 final String key=String.valueOf(counter++); 023 objects.put(key, o); 024 return key; 025 } 026 027 public void remove(String key) { 028 objects.remove(key); 029 } 030 031 public Object get(String key) { 032 return objects.get(key); 033 } 034 }