1 57 58 59 60 package org.apache.soap.util; 61 62 import java.util.*; 63 64 76 public class ObjectRegistry { 77 Hashtable reg = new Hashtable (); 78 ObjectRegistry parent = null; 79 80 public ObjectRegistry () { 81 } 82 83 public ObjectRegistry (ObjectRegistry parent) { 84 this.parent = parent; 85 } 86 87 public void register (String name, Object obj) { 89 reg.put (name, obj); 90 } 91 92 public void unregister (String name) { 94 reg.remove (name); 95 } 96 97 public Object lookup (String name) throws IllegalArgumentException { 99 Object obj = reg.get (name); 100 101 if (obj == null && parent != null) { 102 obj = parent.lookup (name); 103 } 104 105 if (obj == null) { 106 throw new IllegalArgumentException ("object '" + name + "' not in registry"); 107 } 108 109 return obj; 110 } 111 } 112 | Popular Tags |