1 55 package org.jboss.axis.utils; 56 57 import java.util.Hashtable ; 58 import java.util.Vector ; 59 60 71 public class LockableHashtable extends Hashtable 72 { 73 74 77 Vector lockedEntries = new Vector (); 78 79 82 private Hashtable parent = null; 83 84 public LockableHashtable() 85 { 86 super(); 87 } 88 89 public LockableHashtable(int p1, float p2) 90 { 91 super(p1, p2); 92 } 93 94 public LockableHashtable(java.util.Map p1) 95 { 96 super(p1); 97 } 98 99 public LockableHashtable(int p1) 100 { 101 super(p1); 102 } 103 104 107 public synchronized void setParent(Hashtable parent) 108 { 109 this.parent = parent; 110 } 111 112 116 public synchronized Object get(Object key) 117 { 118 Object ret = super.get(key); 119 if ((ret == null) && (parent != null)) 120 { 121 ret = parent.get(key); 122 } 123 return ret; 124 } 125 126 130 public synchronized Object put(Object p1, Object p2, boolean locked) 131 { 132 if (this.containsKey(p1) && lockedEntries.contains(p1)) 133 { 134 return null; 135 } 136 if (locked) lockedEntries.add(p1); 137 return super.put(p1, p2); 138 } 139 140 143 public synchronized Object put(Object p1, Object p2) 144 { 145 return put(p1, p2, false); 146 } 147 148 151 public synchronized Object remove(Object p1) 152 { 153 if (lockedEntries.contains(p1)) 154 { 155 return null; 156 } 157 if (lockedEntries.contains(p1)) lockedEntries.remove(p1); 158 return super.remove(p1); 159 } 160 161 164 public boolean isKeyLocked(Object key) 165 { 166 return lockedEntries.contains(key); 167 } 168 } 169 | Popular Tags |