1 28 29 package com.caucho.naming; 30 31 import javax.naming.NamingException ; 32 import java.util.ArrayList ; 33 import java.util.HashMap ; 34 import java.util.List ; 35 36 39 public class MemoryModel extends AbstractModel { 40 private HashMap <String ,Object > _children = 41 new HashMap <String ,Object >(8); 42 43 46 public MemoryModel() 47 { 48 } 49 50 53 protected AbstractModel create() 54 { 55 return new MemoryModel(); 56 } 57 58 65 public Object lookup(String name) 66 throws NamingException 67 { 68 return _children.get(name); 69 } 70 71 74 public void bind(String name, Object obj) 75 throws NamingException 76 { 77 _children.put(name, obj); 78 } 79 80 83 public void unbind(String name) 84 throws NamingException 85 { 86 _children.remove(name); 87 } 88 89 92 public AbstractModel createSubcontext(String name) 93 throws NamingException 94 { 95 if (_children.get(name) != null) 96 throw new NamingException ("can't create subcontext: " + name + " " + _children.get(name)); 97 98 MemoryModel model = new MemoryModel(); 99 100 _children.put(name, model); 101 102 return model; 103 } 104 105 108 public List list() 109 { 110 return new ArrayList (_children.keySet()); 111 } 112 } 113 | Popular Tags |