1 19 package gcc.properties; 20 21 import gcc.util.*; 22 23 public class SystemProperties extends PropertyMap 24 { 25 28 30 public static final BooleanProperty debugProperty = 31 new BooleanProperty(SystemProperties.class, "gcc.debug"); 32 33 public static final BooleanProperty quietProperty = 34 new BooleanProperty(SystemProperties.class, "gcc.quiet"); 35 36 public static final BooleanProperty verboseProperty = 37 new BooleanProperty(SystemProperties.class, "gcc.verbose"); 38 39 public static final StringProperty homeProperty = 40 new StringProperty(SystemProperties.class, "gcc.home") 41 .isDirName(); 42 43 public static final StringProperty repositoryProperty = 44 new StringProperty(SystemProperties.class, "gcc.repository") 45 .isDirName(); 46 47 public static final StringProperty logFileProperty = 48 new StringProperty(SystemProperties.class, "gcc.logFile") 49 .defaultValue("~/logs/default.log") 50 .isFileName(); 51 52 public static final StringProperty tempDirProperty = 53 new StringProperty(SystemProperties.class, "gcc.tempDir") 54 .isFileName(); 55 56 public static final IntProperty rmiNamingContextCacheTimeoutProperty = 57 new IntProperty(SystemProperties.class, "gcc.rmi.namingContextCacheTimeout") 58 .defaultValue(600); 60 public static final IntProperty rmiSocketTimeoutProperty = 61 new IntProperty(SystemProperties.class, "gcc.rmi.socketTimeout") 62 .defaultValue(600); 64 public static final BooleanProperty rmiTraceProperty = 65 new BooleanProperty(SystemProperties.class, "gcc.rmiTrace"); 66 67 public static final BooleanProperty useThreadLocalRmiConnectionPoolsProperty = 68 new BooleanProperty(SystemProperties.class, "gcc.rmi.useThreadLocalConnectionPools"); 69 70 72 private static SystemProperties _instance; 73 private boolean _canAccessFileSystem = true; 74 private boolean _rmiTrace; 75 private boolean _debug; 76 private boolean _quiet; 77 private boolean _verbose; 78 private String _home; 79 private String _repository; 80 private String _tempDir; 81 82 static 83 { 84 _instance = new SystemProperties(); 85 _instance.init(); 86 } 87 88 public static SystemProperties getInstance() 89 { 90 return _instance; 91 } 92 93 95 private SystemProperties() 96 { 97 try 98 { 99 putAll(System.getProperties()); 100 } 101 catch (Exception ignore) { 103 _canAccessFileSystem = false; 104 } 105 } 106 107 private void init() 108 { 109 _debug = debugProperty.getBoolean(); 110 _quiet = quietProperty.getBoolean(); 111 _verbose = verboseProperty.getBoolean(); 112 113 if (_verbose) 114 { 115 System.out.println("System Property gcc.debug = " + _debug); 116 System.out.println("System Property gcc.verbose = true"); 117 } 118 119 _rmiTrace = rmiTraceProperty.getBoolean(); 120 121 homeProperty.defaultValue("/gcc"); 122 _home = homeProperty.getString(); 123 124 repositoryProperty.defaultValue(_home + "/Repository"); 125 _repository = repositoryProperty.getString(); 126 127 tempDirProperty.defaultValue(_home + "/temp"); 128 _tempDir = tempDirProperty.getString(); 129 } 130 131 133 public static boolean rmiTrace() 134 { 135 return getInstance()._rmiTrace; 136 } 137 138 public static boolean debug() 139 { 140 return getInstance()._debug; 141 } 142 143 public static boolean quiet() 144 { 145 return getInstance()._quiet; 146 } 147 148 public static boolean verbose() 149 { 150 return getInstance()._verbose; 151 } 152 153 public static boolean canAccessFileSystem() 154 { 155 return getInstance()._canAccessFileSystem; 156 } 157 158 public static String logFile() 159 { 160 try 163 { 164 String file = System.getProperty(logFileProperty.getPropertyName(), logFileProperty.getDefaultValue()); 165 file = FileUtil.expandHomeRelativePath(file); 166 return file; 167 } 168 catch (Exception ex) { 170 return logFileProperty.getString(); 171 } 172 } 173 174 public static String getHome() 175 { 176 return getInstance()._home; 177 } 178 179 public static String getRepository() 180 { 181 return getInstance()._repository; 182 } 183 184 public static String getTempDir() 185 { 186 return getInstance()._tempDir; 187 } 188 } 189 | Popular Tags |