1 23 package com.sun.enterprise.diagnostics; 24 25 import java.util.Map ; 26 import java.util.HashMap ; 27 28 33 public class ServiceConfigFactory { 34 35 40 private static Map diagnosticServiceConfigs; 41 42 45 private static Map instanceConfigMap; 46 47 50 private static ServiceConfig defaultConfig; 51 52 private static ServiceConfigFactory configFactory; 53 54 55 private ServiceConfigFactory() { 56 diagnosticServiceConfigs = new HashMap (5); 57 instanceConfigMap = new HashMap (5); 58 } 59 60 64 public static ServiceConfigFactory getInstance() { 65 if (configFactory == null) 66 configFactory = new ServiceConfigFactory(); 67 68 return configFactory; 69 } 70 71 74 public static ServiceConfig getDefaultServiceConfig() { 75 if( defaultConfig == null) { 76 defaultConfig = new ServiceConfig(true,true, true, 77 true,true, true, Defaults.MIN_LOG_LEVEL, 78 Defaults.MAX_NO_OF_ENTRIES, Defaults.LOG_FILE, null, null); 79 return defaultConfig; 80 } 81 return null; 82 } 83 84 89 public ServiceConfig getServiceConfig(String instanceName) { 90 if (instanceName != null) { 91 String configName = (String )instanceConfigMap.get(instanceName); 92 return (ServiceConfig)diagnosticServiceConfigs.get(configName); 93 } 94 return null; 95 } 96 97 105 public ServiceConfig getServiceConfig(boolean local, String repositoryRoot, 106 String instanceName) { 107 if (repositoryRoot != null && instanceName != null) { 108 try { 109 110 ServiceConfig config = new ServiceConfig(local, 111 repositoryRoot, instanceName); 112 return config; 113 }catch(Exception de) { 114 return getDefaultServiceConfig(); 118 } 119 } 120 return null; 121 } 122 } 123 | Popular Tags |