1 23 24 28 29 package com.sun.jts.CosTransactions; 30 31 33 import java.util.*; 34 35 36 61 62 63 64 class CoordinatorLogPool { 65 66 private Stack pool; 67 private static final int MAXSTACKSIZE = 3; 68 69 public static CoordinatorLogPool CLPool = new CoordinatorLogPool(); 70 public static Hashtable CLPooltable = new Hashtable(); 71 72 73 77 public CoordinatorLogPool() { 78 pool = new Stack(); 79 } 80 81 86 public static synchronized CoordinatorLog getCoordinatorLog() { 87 if (Configuration.isDBLoggingEnabled() || 88 Configuration.isFileLoggingDisabled()) 89 return null; 90 if (CLPool.pool.empty()) { 91 return new CoordinatorLog(); 92 } 93 else { 94 CoordinatorLog cl = (CoordinatorLog) CLPool.pool.pop(); 95 return cl; 96 } 97 } 98 99 106 public static void putCoordinatorLog(CoordinatorLog cl) { 107 if (CLPool.pool.size() <= MAXSTACKSIZE) { 108 CLPool.pool.push(cl); 109 } 110 } 111 112 public static synchronized CoordinatorLog getCoordinatorLog(String logPath) { 114 CoordinatorLogPool clpool = (CoordinatorLogPool)CLPooltable.get(logPath); 115 if (clpool == null) { 116 clpool = new CoordinatorLogPool(); 117 CLPooltable.put(logPath,clpool); 118 } 119 if (clpool.pool.empty()) { 120 return new CoordinatorLog(logPath); 121 } 122 else { 123 return (CoordinatorLog)clpool.pool.pop(); 124 } 125 } 126 127 public static void putCoordinatorLog(CoordinatorLog cl, String logPath) { 129 CoordinatorLogPool clpool = (CoordinatorLogPool)CLPooltable.get(logPath); 130 if (clpool == null) { 131 clpool = new CoordinatorLogPool(); 132 CLPooltable.put(logPath,clpool); 133 } 134 if (clpool.pool.size() <= MAXSTACKSIZE) { 135 clpool.pool.push(cl); 136 } 137 } 138 139 } 140 141 | Popular Tags |