1 55 56 package org.apache.bsf.util; 57 58 import java.util.*; 59 60 71 public class ObjectRegistry { 72 Hashtable reg = new Hashtable (); 73 ObjectRegistry parent = null; 74 75 public ObjectRegistry () { 76 } 77 public ObjectRegistry (ObjectRegistry parent) { 78 this.parent = parent; 79 } 80 public Object lookup (String name) throws IllegalArgumentException { 82 Object obj = reg.get (name); 83 84 if (obj == null && parent != null) { 85 obj = parent.lookup (name); 86 } 87 88 if (obj == null) { 89 throw new IllegalArgumentException ("object '" + name + "' not in registry"); 90 } 91 92 return obj; 93 } 94 public void register (String name, Object obj) { 96 reg.put (name, obj); 97 } 98 public void unregister (String name) { 100 reg.remove (name); 101 } 102 } 103 | Popular Tags |