| 1 | package com.mysql.management.util; |
| 2 | |
| 3 | import java.io.File; |
| 4 | import java.io.InputStream; |
| 5 | import java.io.OutputStream; |
| 6 | |
| 7 | public interface RuntimeI { |
| 8 | |
| 9 | /** |
| 10 | * @see java.lang.Runtime#addShutdownHook(Thread hook) { |
| 11 | */ |
| 12 | void addShutdownHook(Thread hook); |
| 13 | |
| 14 | /** |
| 15 | * @see java.lang.Runtime#availableProcessors() |
| 16 | */ |
| 17 | int availableProcessors(); |
| 18 | |
| 19 | /** |
| 20 | * @see java.lang.Runtime#exec(java.lang.String, java.lang.String[], |
| 21 | * java.io.File) |
| 22 | */ |
| 23 | Process exec(String command, String[] envp, File dir); |
| 24 | |
| 25 | /** |
| 26 | * @see java.lang.Runtime#exec(java.lang.String, java.lang.String[]) |
| 27 | */ |
| 28 | Process exec(String cmd, String[] envp); |
| 29 | |
| 30 | /** |
| 31 | * @see java.lang.Runtime#exec(java.lang.String) |
| 32 | */ |
| 33 | Process exec(String command); |
| 34 | |
| 35 | /** |
| 36 | * @see java.lang.Runtime#exec(java.lang.String[], java.lang.String[], |
| 37 | * java.io.File) |
| 38 | */ |
| 39 | Process exec(String[] cmdarray, String[] envp, File dir); |
| 40 | |
| 41 | /** |
| 42 | * @see java.lang.Runtime#exec(java.lang.String[], java.lang.String[]) |
| 43 | */ |
| 44 | Process exec(String[] cmdarray, String[] envp); |
| 45 | |
| 46 | /** |
| 47 | * @see java.lang.Runtime#exec(java.lang.String[]) |
| 48 | */ |
| 49 | Process exec(String[] cmdarray); |
| 50 | |
| 51 | /** |
| 52 | * @see java.lang.Runtime#exit(int) |
| 53 | */ |
| 54 | void exit(int status); |
| 55 | |
| 56 | /** |
| 57 | * @see java.lang.Runtime#freeMemory() |
| 58 | */ |
| 59 | long freeMemory(); |
| 60 | |
| 61 | /** |
| 62 | * @see java.lang.Runtime#gc() |
| 63 | */ |
| 64 | void gc(); |
| 65 | |
| 66 | /** |
| 67 | * @see java.lang.Runtime#getLocalizedInputStream(java.io.InputStream) |
| 68 | * @deprecated As of JDK 1.1, the preferred way to translate a byte |
| 69 | * stream in the local encoding into a character stream in |
| 70 | * Unicode is via the <code>InputStreamReader</code> and |
| 71 | * <code>BufferedReader</code> classes. |
| 72 | */ |
| 73 | InputStream getLocalizedInputStream(InputStream in); |
| 74 | |
| 75 | /** |
| 76 | * @see java.lang.Runtime#getLocalizedOutputStream(java.io.OutputStream) |
| 77 | * @deprecated As of JDK 1.1, the preferred way to translate a Unicode |
| 78 | * character stream into a byte stream in the local encoding is |
| 79 | * via the <code>OutputStreamWriter</code>, |
| 80 | * <code>BufferedWriter</code>, and <code>PrintWriter</code> |
| 81 | * classes. |
| 82 | */ |
| 83 | OutputStream getLocalizedOutputStream(OutputStream out); |
| 84 | |
| 85 | /** |
| 86 | * @see java.lang.Runtime#halt(int) |
| 87 | */ |
| 88 | void halt(int status); |
| 89 | |
| 90 | /** |
| 91 | * @see java.lang.Runtime#load(java.lang.String) |
| 92 | */ |
| 93 | void load(String filename); |
| 94 | |
| 95 | /** |
| 96 | * @see java.lang.Runtime#loadLibrary(java.lang.String) |
| 97 | */ |
| 98 | void loadLibrary(String libname); |
| 99 | |
| 100 | /** |
| 101 | * @see java.lang.Runtime#maxMemory() |
| 102 | */ |
| 103 | long maxMemory(); |
| 104 | |
| 105 | /** |
| 106 | * @see java.lang.Runtime#removeShutdownHook(java.lang.Thread) |
| 107 | */ |
| 108 | boolean removeShutdownHook(Thread hook); |
| 109 | |
| 110 | /** |
| 111 | * @see java.lang.Runtime#runFinalization() |
| 112 | */ |
| 113 | void runFinalization(); |
| 114 | |
| 115 | /** |
| 116 | * @see java.lang.Runtime#totalMemory() |
| 117 | */ |
| 118 | long totalMemory(); |
| 119 | |
| 120 | /** |
| 121 | * @see java.lang.Runtime#traceInstructions(boolean) |
| 122 | */ |
| 123 | void traceInstructions(boolean on); |
| 124 | |
| 125 | /** |
| 126 | * @see java.lang.Runtime#traceMethodCalls(boolean) |
| 127 | */ |
| 128 | void traceMethodCalls(boolean on); |
| 129 | |
| 130 | // ------------------------------------- |
| 131 | public static final class Default extends RuntimeI.Stub { |
| 132 | Runtime runtime = Runtime.getRuntime(); |
| 133 | |
| 134 | // public void addShutdownHook(Thread hook) { |
| 135 | // runtime.addShutdownHook(hook); |
| 136 | // } |
| 137 | |
| 138 | public int availableProcessors() { |
| 139 | return runtime.availableProcessors(); |
| 140 | } |
| 141 | |
| 142 | // public Process exec(String command, String[] envp, File dir) |
| 143 | // { |
| 144 | // return runtime.exec(command, envp, dir); |
| 145 | // } |
| 146 | |
| 147 | // public Process exec(String cmd, String[] envp) { |
| 148 | // return runtime.exec(cmd, envp); |
| 149 | // } |
| 150 | |
| 151 | // public Process exec(String command) { |
| 152 | // return runtime.exec(command); |
| 153 | // } |
| 154 | |
| 155 | public Process exec(final String[] cmdarray, final String[] envp, |
| 156 | final File dir) { |
| 157 | Exceptions.Block block = new Exceptions.Block() { |
| 158 | protected Object inner() throws Exception { |
| 159 | return runtime.exec(cmdarray, envp, dir); |
| 160 | } |
| 161 | }; |
| 162 | return (Process) block.exec(); |
| 163 | } |
| 164 | |
| 165 | // public Process exec(String[] cmdarray, String[] envp) |
| 166 | // { |
| 167 | // return runtime.exec(cmdarray, envp); |
| 168 | // } |
| 169 | |
| 170 | // public Process exec(String[] cmdarray) { |
| 171 | // return runtime.exec(cmdarray); |
| 172 | // } |
| 173 | |
| 174 | // public void exit(int status) { |
| 175 | // runtime.exit(status); |
| 176 | // } |
| 177 | |
| 178 | public long freeMemory() { |
| 179 | return runtime.freeMemory(); |
| 180 | } |
| 181 | |
| 182 | // public void gc() { |
| 183 | // runtime.gc(); |
| 184 | // } |
| 185 | |
| 186 | // /** @deprecated */ |
| 187 | // public InputStream getLocalizedInputStream(InputStream in) { |
| 188 | // return runtime.getLocalizedInputStream(in); |
| 189 | // } |
| 190 | |
| 191 | // /** @deprecated */ |
| 192 | // public OutputStream getLocalizedOutputStream(OutputStream out) { |
| 193 | // return runtime.getLocalizedOutputStream(out); |
| 194 | // } |
| 195 | |
| 196 | // public void halt(int status) { |
| 197 | // runtime.halt(status); |
| 198 | // } |
| 199 | |
| 200 | // public void load(String filename) { |
| 201 | // runtime.load(filename); |
| 202 | // } |
| 203 | |
| 204 | // public void loadLibrary(String libname) { |
| 205 | // runtime.loadLibrary(libname); |
| 206 | // } |
| 207 | |
| 208 | public long maxMemory() { |
| 209 | return runtime.maxMemory(); |
| 210 | } |
| 211 | |
| 212 | // public boolean removeShutdownHook(Thread hook) { |
| 213 | // return runtime.removeShutdownHook(hook); |
| 214 | // } |
| 215 | |
| 216 | // public void runFinalization() { |
| 217 | // runtime.runFinalization(); |
| 218 | // } |
| 219 | |
| 220 | public long totalMemory() { |
| 221 | return runtime.totalMemory(); |
| 222 | } |
| 223 | |
| 224 | // public void traceInstructions(boolean on) { |
| 225 | // runtime.traceInstructions(on); |
| 226 | // } |
| 227 | |
| 228 | // public void traceMethodCalls(boolean on) { |
| 229 | // runtime.traceMethodCalls(on); |
| 230 | // } |
| 231 | } |
| 232 | |
| 233 | // ------------------------------------- |
| 234 | public static class Stub implements RuntimeI { |
| 235 | |
| 236 | public void addShutdownHook(Thread hook) { |
| 237 | throw new NotImplementedException(hook); |
| 238 | } |
| 239 | |
| 240 | public int availableProcessors() { |
| 241 | throw new NotImplementedException(); |
| 242 | } |
| 243 | |
| 244 | public Process exec(String command, String[] envp, File dir) { |
| 245 | throw new NotImplementedException(command, envp, dir); |
| 246 | } |
| 247 | |
| 248 | public Process exec(String cmd, String[] envp) { |
| 249 | throw new NotImplementedException(cmd, envp); |
| 250 | } |
| 251 | |
| 252 | public Process exec(String command) { |
| 253 | throw new NotImplementedException(command); |
| 254 | } |
| 255 | |
| 256 | public Process exec(String[] cmdarray, String[] envp, File dir) { |
| 257 | throw new NotImplementedException(cmdarray, envp, dir); |
| 258 | } |
| 259 | |
| 260 | public Process exec(String[] cmdarray, String[] envp) { |
| 261 | throw new NotImplementedException(cmdarray, envp); |
| 262 | } |
| 263 | |
| 264 | public Process exec(String[] cmdarray) { |
| 265 | throw new NotImplementedException(cmdarray); |
| 266 | } |
| 267 | |
| 268 | public void exit(int status) { |
| 269 | throw new NotImplementedException(new Integer(status)); |
| 270 | } |
| 271 | |
| 272 | public long freeMemory() { |
| 273 | throw new NotImplementedException(); |
| 274 | } |
| 275 | |
| 276 | public void gc() { |
| 277 | throw new NotImplementedException(); |
| 278 | } |
| 279 | |
| 280 | public InputStream getLocalizedInputStream(InputStream in) { |
| 281 | throw new NotImplementedException(in); |
| 282 | } |
| 283 | |
| 284 | public OutputStream getLocalizedOutputStream(OutputStream out) { |
| 285 | throw new NotImplementedException(out); |
| 286 | } |
| 287 | |
| 288 | public void halt(int status) { |
| 289 | throw new NotImplementedException(new Integer(status)); |
| 290 | } |
| 291 | |
| 292 | public void load(String filename) { |
| 293 | throw new NotImplementedException(filename); |
| 294 | } |
| 295 | |
| 296 | public void loadLibrary(String libname) { |
| 297 | throw new NotImplementedException(libname); |
| 298 | } |
| 299 | |
| 300 | public long maxMemory() { |
| 301 | throw new NotImplementedException(); |
| 302 | } |
| 303 | |
| 304 | public boolean removeShutdownHook(Thread hook) { |
| 305 | throw new NotImplementedException(hook); |
| 306 | } |
| 307 | |
| 308 | public void runFinalization() { |
| 309 | throw new NotImplementedException(); |
| 310 | } |
| 311 | |
| 312 | public long totalMemory() { |
| 313 | throw new NotImplementedException(); |
| 314 | } |
| 315 | |
| 316 | public void traceInstructions(boolean on) { |
| 317 | throw new NotImplementedException(new Boolean(on)); |
| 318 | } |
| 319 | |
| 320 | public void traceMethodCalls(boolean on) { |
| 321 | throw new NotImplementedException(new Boolean(on)); |
| 322 | } |
| 323 | } |
| 324 | } |