1 21 package oracle.toplink.essentials.internal.sequencing; 23 24 import java.util.Vector ; 25 import java.util.Hashtable ; 26 27 class PreallocationHandler implements SequencingLogInOut { 28 protected Hashtable preallocatedSequences; 29 30 public PreallocationHandler() { 31 super(); 32 } 33 34 39 protected Vector getPreallocatedSequences(String seqName) { 40 Vector sequencesForName; 41 synchronized (preallocatedSequences) { 42 sequencesForName = (Vector )preallocatedSequences.get(seqName); 43 if (sequencesForName == null) { 44 sequencesForName = new Vector (); 45 preallocatedSequences.put(seqName, sequencesForName); 46 } 47 } 48 return sequencesForName; 49 } 50 51 public void onConnect() { 53 initializePreallocated(); 54 } 55 56 public void onDisconnect() { 57 preallocatedSequences = null; 58 } 59 60 public boolean isConnected() { 61 return preallocatedSequences != null; 62 } 63 64 public void initializePreallocated() { 68 preallocatedSequences = new Hashtable (20); 69 } 70 71 public void initializePreallocated(String seqName) { 75 preallocatedSequences.remove(seqName); 76 } 77 78 public Vector getPreallocated(String seqName) { 79 return getPreallocatedSequences(seqName); 80 } 81 82 public void setPreallocated(String seqName, Vector sequences) { 83 getPreallocatedSequences(seqName).addAll(sequences); 84 } 85 } 86 | Popular Tags |