1 21 22 package org.apache.derby.client.am; 23 24 import org.apache.derby.shared.common.i18n.MessageUtil; 25 26 27 28 public abstract class Version { 29 static MessageUtil msgutil = SqlException.getMessageUtil(); 30 31 private static String SECURITY_MANAGER_NO_ACCESS_ID = "J108"; 33 private static String UNKNOWN_HOST_ID = "J109"; 34 35 public static String getDriverName() { 37 return Configuration.dncDriverName; 38 } 39 40 public static String getDriverVersion() { 42 return Configuration.dncProductVersionHolder__.getVersionBuildString(true); 43 } 44 45 46 public static int getMajorVersion() { 48 return Configuration.getProductVersionHolder().getMajorVersion(); 49 } 50 51 public static int getMinorVersion() { 52 return Configuration.getProductVersionHolder().getMinorVersion(); 53 } 54 55 public static int getBuildNumber() { 56 return Configuration.getProductVersionHolder().getBuildNumberAsInt(); 57 } 58 59 public static int getProtocolMaintVersion() { 60 return Configuration.getProductVersionHolder().getDrdaMaintVersion(); 61 } 62 63 public static boolean isAlpha() { 64 return Configuration.getProductVersionHolder().isAlpha(); 65 } 66 67 public static boolean isBeta() { 68 return Configuration.getProductVersionHolder().isBeta(); 69 } 70 71 private static String getDriverNameAndVersion() { 73 return Configuration.dncDriverName + " " + 74 Configuration.dncProductVersionHolder__.getVersionBuildString(true); 75 } 76 77 79 public static void writeDriverConfiguration(java.io.PrintWriter printWriter) { 80 String header = "[derby] "; 81 synchronized (printWriter) { 82 printWriter.println(header + "BEGIN TRACE_DRIVER_CONFIGURATION"); 83 printWriter.println(header + "Driver: " + getDriverNameAndVersion()); 84 85 printWriter.print(header + "Compatible JRE versions: { "); 86 for (int i = 0; i < Configuration.dncCompatibleJREVersions.length; i++) { 87 printWriter.print(Configuration.dncCompatibleJREVersions[i]); 88 if (i != Configuration.dncCompatibleJREVersions.length - 1) { 89 printWriter.print(", "); 90 } 91 } 92 printWriter.println(" }"); 93 94 printWriter.println(header + "Range checking enabled: " + Configuration.rangeCheckCrossConverters); 95 printWriter.println(header + "Bug check level: 0x" + Integer.toHexString(Configuration.bugCheckLevel)); 96 printWriter.println(header + "Default fetch size: " + Configuration.defaultFetchSize); 97 printWriter.println(header + "Default isolation: " + Configuration.defaultIsolation); 98 99 java.lang.SecurityManager security = java.lang.System.getSecurityManager(); 100 if (security == null) { 101 printWriter.println(header + "No security manager detected."); 102 } else { 103 printWriter.println(header + "Security manager detected."); 104 } 105 106 detectLocalHost(java.lang.System.getSecurityManager(), printWriter); 107 108 printSystemProperty(security, "JDBC 1 system property jdbc.drivers = ", "jdbc.drivers", printWriter); 109 110 printSystemProperty(security, "Java Runtime Environment version ", "java.version", printWriter); 111 printSystemProperty(security, "Java Runtime Environment vendor = ", "java.vendor", printWriter); 112 printSystemProperty(security, "Java vendor URL = ", "java.vendor.url", printWriter); 113 printSystemProperty(security, "Java installation directory = ", "java.home", printWriter); 114 printSystemProperty(security, "Java Virtual Machine specification version = ", "java.vm.specification.version", printWriter); 115 printSystemProperty(security, "Java Virtual Machine specification vendor = ", "java.vm.specification.vendor", printWriter); 116 printSystemProperty(security, "Java Virtual Machine specification name = ", "java.vm.specification.name", printWriter); 117 printSystemProperty(security, "Java Virtual Machine implementation version = ", "java.vm.version", printWriter); 118 printSystemProperty(security, "Java Virtual Machine implementation vendor = ", "java.vm.vendor", printWriter); 119 printSystemProperty(security, "Java Virtual Machine implementation name = ", "java.vm.name", printWriter); 120 printSystemProperty(security, "Java Runtime Environment specification version = ", "java.specification.version", printWriter); 121 printSystemProperty(security, "Java Runtime Environment specification vendor = ", "java.specification.vendor", printWriter); 122 printSystemProperty(security, "Java Runtime Environment specification name = ", "java.specification.name", printWriter); 123 printSystemProperty(security, "Java class format version number = ", "java.class.version", printWriter); 124 printSystemProperty(security, "Java class path = ", "java.class.path", printWriter); 125 printSystemProperty(security, "Java native library path = ", "java.library.path", printWriter); 126 printSystemProperty(security, "Path of extension directory or directories = ", "java.ext.dirs", printWriter); 127 printSystemProperty(security, "Operating system name = ", "os.name", printWriter); 128 printSystemProperty(security, "Operating system architecture = ", "os.arch", printWriter); 129 printSystemProperty(security, "Operating system version = ", "os.version", printWriter); 130 printSystemProperty(security, "File separator (\"/\" on UNIX) = ", "file.separator", printWriter); 131 printSystemProperty(security, "Path separator (\":\" on UNIX) = ", "path.separator", printWriter); 132 printSystemProperty(security, "User's account name = ", "user.name", printWriter); 133 printSystemProperty(security, "User's home directory = ", "user.home", printWriter); 134 printSystemProperty(security, "User's current working directory = ", "user.dir", printWriter); 135 printWriter.println(header + "END TRACE_DRIVER_CONFIGURATION"); 136 printWriter.flush(); 137 } 138 } 139 140 private static void printSystemProperty(java.lang.SecurityManager security, 141 String prefix, 142 String property, 143 java.io.PrintWriter printWriter) { 144 String header = "[derby] "; 145 synchronized (printWriter) { 146 try { 147 if (security != null) { 148 security.checkPropertyAccess(property); 149 } 150 String result = System.getProperty(property); 151 printWriter.println(header + prefix + result); 152 printWriter.flush(); 153 } catch (SecurityException e) { 154 printWriter.println(header + 155 msgutil.getTextMessage(SECURITY_MANAGER_NO_ACCESS_ID, property)); 156 printWriter.flush(); 157 } 158 } 159 } 160 161 private static void detectLocalHost(java.lang.SecurityManager security, java.io.PrintWriter printWriter) { 163 String header = "[derby] "; 164 if (security == null) { 166 try { 167 printWriter.print(header + "Detected local client host: "); 168 printWriter.println(java.net.InetAddress.getLocalHost().toString()); 169 printWriter.flush(); 170 } catch (java.net.UnknownHostException e) { 171 printWriter.println(header + 172 msgutil.getTextMessage(UNKNOWN_HOST_ID, e.getMessage())); 173 printWriter.flush(); 174 } 175 } 176 } 177 } 178 | Popular Tags |