1 23 24 28 50 package com.sun.jts.CosTransactions; 51 52 54 import java.util.logging.Logger ; 55 import java.util.logging.Level ; 56 import com.sun.logging.LogDomains; 57 import com.sun.jts.utils.LogFormatter; 58 59 60 72 79 class Log { 80 81 84 private LogControl logControl = null; 85 86 88 private String logPath = null; 90 93 static Logger _logger = LogDomains.getLogger(LogDomains.TRANSACTION_LOGGER); 94 95 103 Log() { 104 107 109 logControl = null; 110 111 114 if( logPath == null ) { 115 int[] result = new int[1]; 116 logPath = Configuration.getDirectory(Configuration.LOG_DIRECTORY, 117 Configuration.JTS_SUBDIRECTORY, 118 result); 119 120 122 if( result[0] == Configuration.DEFAULT_USED || 123 result[0] == Configuration.DEFAULT_INVALID ) { 124 125 128 if( logPath.length() > 0 ) { 129 _logger.log(Level.WARNING,"jts.invalid_log_path",logPath); 130 } 131 132 135 if( result[0] == Configuration.DEFAULT_INVALID ) { 136 _logger.log(Level.WARNING,"jts.invalid_default_log_path"); 137 logPath = "."; 138 } 139 } 140 } 141 142 } 143 144 145 Log(String logPath) { 146 logControl = null; 147 this.logPath = logPath; 148 } 149 150 158 public void finalize() { 159 160 logControl = null; 161 logPath = null; 162 163 } 164 165 173 boolean initialise() { 174 boolean result = true; 175 176 178 logControl = new LogControl(); 179 logControl.initLog(false,false,logPath); 180 181 return result; 182 } 183 184 185 198 LogFile open( String serverName, 199 LogUpcallTarget upcall ) { 200 201 LogFile logFile = null; 202 203 boolean[] newLog = new boolean[1]; newLog[0] = true; 204 205 207 try { 208 LogHandle handle = logControl.openFile(serverName,upcall,null,newLog); 209 210 212 logFile = new LogFile(handle); 213 } 214 215 217 catch( LogException le ) { 218 _logger.log(Level.SEVERE,"jts.log_error",le.toString()); 219 String msg = LogFormatter.getLocalizedMessage(_logger,"jts.log_error", 220 new java.lang.Object [] {le.toString()}); 221 throw new org.omg.CORBA.INTERNAL (msg); 222 } 223 224 return logFile; 225 } 226 227 235 boolean terminate() { 236 237 boolean result = true; 238 239 241 return result; 242 } 243 244 255 static boolean checkFileExists( String serverName ) { 256 boolean exists = false; 257 258 260 if( serverName != null ) { 261 String logPath = null; 262 int[] result = new int[1]; 263 logPath = Configuration.getDirectory(Configuration.LOG_DIRECTORY, 264 Configuration.JTS_SUBDIRECTORY, 265 result); 266 267 269 if( result[0] == Configuration.DEFAULT_USED || 270 result[0] == Configuration.DEFAULT_INVALID ) { 271 272 275 if( logPath.length() > 0 ) { 276 _logger.log(Level.WARNING,"jts.invalid_log_path",logPath); 277 } 278 279 282 if( result[0] == Configuration.DEFAULT_INVALID ) { 283 _logger.log(Level.WARNING,"jts.invalid_default_log_path"); 284 logPath = "."; 285 } 286 } 287 exists = LogControl.checkFileExists(serverName,logPath); 288 } 289 290 291 return exists; 292 } 293 294 302 void dump() { 303 305 308 logControl.dump(); 309 } 310 } 311 | Popular Tags |