1 23 package com.sun.enterprise.diagnostics; 24 25 import java.io.File ; 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import com.sun.logging.LogDomains; 29 import com.sun.enterprise.config.serverbeans.ServerTags; 30 import com.sun.enterprise.diagnostics.Constants; 31 32 36 public class ServiceConfig { 37 38 private static Logger logger = 39 LogDomains.getLogger(LogDomains.ADMIN_LOGGER); 40 private String logFile; 41 private int minLogLevel; 42 private int maxNoOfEntries ; 43 private String repositoryDir; 44 private String instanceName; 45 private boolean local; 46 private boolean captureSystemInfoEnabled; 47 private boolean captureChecksumEnabled = true; 48 private boolean captureAppDDEnabled = true; 49 private boolean captureInstallLogEnabled = true; 50 private boolean verifyDomainEnabled = true; 51 private boolean captureHadbInfoEnabled ; 52 private ServiceConfigHelper configHelper; 53 54 public ServiceConfig(boolean localFlag, String repositoryDir, 55 String instanceName) throws DiagnosticException { 56 local = localFlag; 57 this.repositoryDir = repositoryDir; 58 this.instanceName = instanceName; 59 setValues(); 60 } 61 62 public ServiceConfig(boolean captureChecksumEnabled, 63 boolean captureAppDDEnabled, boolean captureInstallLogEnabled, 64 boolean verifyDomainEnabled, boolean captureHadbInfoEnabled, 65 boolean captureSystemInfoEnabled, int minLogLevel, 66 int maxNoOfEntries, String logFile, String repositoryDir, 67 String instanceName 68 ) { 69 this.captureChecksumEnabled = captureChecksumEnabled; 70 this.captureAppDDEnabled = captureAppDDEnabled; 71 this.captureInstallLogEnabled = captureInstallLogEnabled; 72 this.verifyDomainEnabled = verifyDomainEnabled; 73 this.captureHadbInfoEnabled = captureHadbInfoEnabled; 74 this.captureSystemInfoEnabled = captureSystemInfoEnabled; 75 this.minLogLevel = minLogLevel; 76 this.maxNoOfEntries = maxNoOfEntries; 77 this.logFile = logFile; 78 this.instanceName = instanceName; 79 this.repositoryDir = repositoryDir; 80 } 81 82 85 public int getMaxNoOfEntries() { 86 return maxNoOfEntries; 87 } 88 89 92 public int getMinLogLevel() { 93 return minLogLevel; 94 } 95 96 99 public String getLogFile() { 100 return logFile; 101 } 103 106 public String getRepositoryDir() { 107 return repositoryDir; 108 } 109 110 111 114 public boolean isCaptureAppDDEnabled() { 115 return captureAppDDEnabled; 116 } 117 118 121 public boolean isCaptureInstallLogEnabled() { 122 return captureInstallLogEnabled; 123 } 124 125 128 public boolean isVerifyDomainEnabled() { 129 return verifyDomainEnabled; 130 } 131 132 135 public boolean isCaptureChecksumEnabled() { 136 return captureChecksumEnabled; 137 } 138 141 public boolean isCaptureHadbInfoEnabled() { 142 return captureHadbInfoEnabled; 143 } 144 145 public String getInstanceName() { 146 return instanceName; 147 } 148 149 152 public boolean isCaptureSystemInfoEnabled() { 153 return captureSystemInfoEnabled; 154 } 155 156 159 public String getConfigName() { 160 if (configHelper != null) 161 return configHelper.getConfigName(); 162 return null; 163 164 } 165 166 public void debug() { 167 logger.log(Level.FINEST, "diagnostic-service.capture_app_dd ", 168 new Object [] {captureAppDDEnabled}); 169 logger.log(Level.FINEST, "diagnostic-service.capture_hadb_info", 170 new Object []{captureHadbInfoEnabled}); 171 logger.log(Level.FINEST, "diagnostic-service.capture_checksum", 172 new Object []{captureChecksumEnabled}); 173 logger.log(Level.FINEST, "diagnostic-service.capture_install_log", 174 new Object []{captureInstallLogEnabled}); 175 logger.log(Level.FINEST, "diagnostic-service.min_log_level", 176 new Object []{minLogLevel}); 177 logger.log(Level.FINEST, "diagnostic-service.max_log_entries", 178 new Object []{maxNoOfEntries}); 179 } 180 181 public String toString() { 182 return getInstanceName() + "," + getConfigName() + 183 "," + getMaxNoOfEntries() +"," + getMinLogLevel() + 184 "," + getLogFile() + 185 "," + getRepositoryDir() + "," + isCaptureAppDDEnabled() + 186 "," + isCaptureChecksumEnabled() + 187 "," + isCaptureHadbInfoEnabled() + 188 "," + isCaptureInstallLogEnabled() + 189 "," + isVerifyDomainEnabled() ; 190 } 191 194 private void setValues() throws DiagnosticException { 195 configHelper = new ServiceConfigHelper(repositoryDir, instanceName, local); 197 minLogLevel = Level.parse 198 (getAttribute(ServerTags.MIN_LOG_LEVEL)).intValue(); 199 logFile = getAttribute(ServerTags.FILE); 200 maxNoOfEntries = Integer.parseInt 201 (getAttribute(ServerTags.MAX_LOG_ENTRIES)); 202 captureAppDDEnabled = getBooleanAttribute(ServerTags.CAPTURE_APP_DD); 203 captureInstallLogEnabled =getBooleanAttribute(ServerTags.CAPTURE_INSTALL_LOG); 204 verifyDomainEnabled = getBooleanAttribute(ServerTags.VERIFY_CONFIG); 205 captureHadbInfoEnabled = getBooleanAttribute(ServerTags.CAPTURE_HADB_INFO); 206 captureChecksumEnabled = getBooleanAttribute(ServerTags.COMPUTE_CHECKSUM); 207 captureSystemInfoEnabled = getBooleanAttribute(ServerTags.CAPTURE_SYSTEM_INFO); 208 } 209 210 213 private String getAttribute(String attribute) throws DiagnosticException { 214 return configHelper.getAttribute(attribute); 215 } 216 217 private boolean getBooleanAttribute(String attrName) 218 throws DiagnosticException{ 219 return Boolean.valueOf(getAttribute(attrName)).booleanValue(); 220 } 221 } 222 | Popular Tags |