1 7 8 package com.sun.corba.se.impl.orbutil; 9 10 import java.util.Stack ; 11 import java.util.Hashtable ; 12 import java.util.EmptyStackException ; 13 import java.util.Enumeration ; 14 15 class RepositoryIdPool_1_3_1 extends Stack { 17 18 private static int MAX_CACHE_SIZE = 4; 19 private RepositoryIdCache_1_3_1 cache; 20 21 public final synchronized RepositoryId_1_3_1 popId() { 22 23 try { 24 return (RepositoryId_1_3_1)super.pop(); 25 } 26 catch(EmptyStackException e) { 27 increasePool(5); 28 return (RepositoryId_1_3_1)super.pop(); 29 } 30 31 } 32 33 final void increasePool(int size) { 35 for (int i = size; i > 0; i--) 37 push(new RepositoryId_1_3_1()); 38 55 } 56 57 final void setCaches(RepositoryIdCache_1_3_1 cache) { 58 this.cache = cache; 59 } 60 61 } 62 63 public class RepositoryIdCache_1_3_1 extends Hashtable { 64 65 private RepositoryIdPool_1_3_1 pool = new RepositoryIdPool_1_3_1(); 66 67 public RepositoryIdCache_1_3_1() { 68 pool.setCaches(this); 69 } 70 71 public final synchronized RepositoryId_1_3_1 getId(String key) { 72 RepositoryId_1_3_1 repId = (RepositoryId_1_3_1)super.get(key); 73 74 if (repId != null) 75 return repId; 76 else { 77 repId = new RepositoryId_1_3_1(key); 79 put(key, repId); 80 return repId; 81 } 82 83 } 84 } 85 86 87 | Popular Tags |