1 23 package fr.dyade.aaa.jndi2.impl; 24 25 import java.util.*; 26 import java.lang.ref.*; 27 28 public class ContextCache implements ContextTable { 29 30 private Hashtable table; 31 32 public ContextCache() { 33 table = new Hashtable(); 34 } 35 36 public void put(Object key, NamingContext nc) { 37 SoftReference sr = new SoftReference(nc); 38 table.put(key, sr); 39 } 40 41 public NamingContext get(Object key) { 42 SoftReference sr = 43 (SoftReference)table.get(key); 44 if (sr != null) { 45 Object obj = sr.get(); 46 if (obj != null) { 47 return (NamingContext)obj; 48 } 49 } 50 return null; 51 } 52 53 public void remove(Object key) { 54 table.remove(key); 55 } 56 } 57 | Popular Tags |