1 18 package org.apache.geronimo.interop.properties; 19 20 import org.apache.geronimo.interop.util.FileUtil; 21 22 23 public class SystemProperties extends PropertyMap { 24 27 29 public static final BooleanProperty debugProperty = 30 new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.debug"); 31 32 public static final BooleanProperty quietProperty = 33 new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.quiet"); 34 35 public static final BooleanProperty verboseProperty = 36 new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.verbose"); 37 38 public static final StringProperty homeProperty = 39 new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.home") 40 .isDirName(); 41 42 public static final StringProperty repositoryProperty = 43 new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.repository") 44 .isDirName(); 45 46 public static final StringProperty logFileProperty = 47 new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.logFile") 48 .defaultValue("~/logs/default.log") 49 .isFileName(); 50 51 public static final StringProperty tempDirProperty = 52 new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.tempDir") 53 .isFileName(); 54 55 public static final IntProperty rmiNamingContextCacheTimeoutProperty = 56 new IntProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.namingContextCacheTimeout") 57 .defaultValue(600); 59 public static final IntProperty rmiSocketTimeoutProperty = 60 new IntProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.socketTimeout") 61 .defaultValue(600); 63 public static final BooleanProperty rmiTraceProperty = 64 new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmiTrace"); 65 66 public static final BooleanProperty useThreadLocalRmiConnectionPoolsProperty = 67 new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.useThreadLocalConnectionPools"); 68 69 71 private static SystemProperties instance; 72 private boolean canAccessFileSystem = true; 73 private boolean rmiTrace; 74 private boolean debug; 75 private boolean quiet; 76 private boolean verbose; 77 private String home; 78 private String repository; 79 private String tempDir; 80 81 static { 82 instance = new SystemProperties(); 83 instance.init(); 84 } 85 86 public static SystemProperties getInstance() { 87 return instance; 88 } 89 90 92 private SystemProperties() { 93 try { 94 putAll(System.getProperties()); 95 } catch (Exception ignore) { 97 canAccessFileSystem = false; 98 } 99 } 100 101 private void init() { 102 debug = debugProperty.getBoolean(); 103 quiet = quietProperty.getBoolean(); 104 verbose = verboseProperty.getBoolean(); 105 106 if (verbose) { 107 System.out.println("System Property org.apache.geronimo.interop.debug = " + debug); 108 System.out.println("System Property org.apache.geronimo.interop.verbose = true"); 109 } 110 111 rmiTrace = rmiTraceProperty.getBoolean(); 112 113 homeProperty.defaultValue("/org.apache.geronimo.interop"); 114 home = homeProperty.getString(); 115 116 repositoryProperty.defaultValue(home + "/Repository"); 117 repository = repositoryProperty.getString(); 118 119 tempDirProperty.defaultValue(home + "/temp"); 120 tempDir = tempDirProperty.getString(); 121 } 122 123 125 public static boolean rmiTrace() { 126 return getInstance().rmiTrace; 127 } 128 129 public static boolean debug() { 130 return getInstance().debug; 131 } 132 133 public static boolean quiet() { 134 return getInstance().quiet; 135 } 136 137 public static boolean verbose() { 138 return getInstance().verbose; 139 } 140 141 public static boolean canAccessFileSystem() { 142 return getInstance().canAccessFileSystem; 143 } 144 145 public static String logFile() { 146 try { 149 String file = System.getProperty(logFileProperty.getPropertyName(), logFileProperty.getDefaultValue()); 150 file = FileUtil.expandHomeRelativePath(file); 151 return file; 152 } catch (Exception ex) { 154 return logFileProperty.getString(); 155 } 156 } 157 158 public static String getHome() { 159 return getInstance().home; 160 } 161 162 public static String getRepository() { 163 return getInstance().repository; 164 } 165 166 public static String getTempDir() { 167 return getInstance().tempDir; 168 } 169 } 170 | Popular Tags |