1 21 22 package org.apache.derbyTesting.functionTests.harness; 23 24 30 31 import java.io.*; 32 import java.util.Vector ; 33 34 public class SysInfoLog 35 { 36 37 public SysInfoLog() 38 { 39 } 40 41 public void exec(String jvmName, String javaCmd, String classpath, 43 String framework, PrintWriter pw, boolean useprocess) 44 throws Exception 45 { 46 if ( useprocess == true ) 47 { 48 Process pr = null; 50 jvm javavm = null; try 52 { 53 if ( (jvmName == null) || (jvmName.length()==0) ) 56 jvmName = "jdk13"; 57 else if (jvmName.startsWith("jdk13")) 58 jvmName = "jdk13"; 59 60 javavm = jvm.getJvm(jvmName); 61 if (javaCmd != null) 62 javavm.setJavaCmd(javaCmd); 63 64 if (javavm == null) System.out.println("WHOA, javavm is NULL"); 65 if (javavm == null) pw.println("WHOA, javavm is NULL"); 66 67 if ( (classpath != null) && (classpath.length()>0) ) 68 { 69 javavm.setClasspath(classpath); 70 } 71 72 Vector v = javavm.getCommandLine(); 73 v.addElement("org.apache.derby.tools.sysinfo"); 74 String [] sCmd = new String [v.size()]; 76 for (int i = 0; i < v.size(); i++) 77 { 78 sCmd[i] = (String )v.elementAt(i); 79 } 81 82 pr = Runtime.getRuntime().exec(sCmd); 83 84 BackgroundStreamDrainer stdout = 86 new BackgroundStreamDrainer(pr.getInputStream(), null); 87 BackgroundStreamDrainer stderr = 88 new BackgroundStreamDrainer(pr.getErrorStream(), null); 89 90 pr.waitFor(); 91 String result = HandleResult.handleResult(pr.exitValue(), 92 stdout.getData(), stderr.getData(), pw); 93 pw.flush(); 94 95 if ( (framework != null) && (framework.length()>0) ) 96 { 97 pw.println("Framework: " + framework); 98 } 99 100 pr.destroy(); 101 pr = null; 102 } 103 catch(Throwable t) 104 { 105 if (javavm == null) System.out.println("WHOA, javavm is NULL"); 106 if (javavm == null) pw.println("WHOA, javavm is NULL"); 107 System.out.println("Process exception: " + t); 108 pw.println("Process exception: " + t); 109 t.printStackTrace(pw); 110 if (pr != null) 111 { 112 pr.destroy(); 113 pr = null; 114 } 115 } 116 } 117 else 118 { 119 129 } 130 } 131 } 132 133 | Popular Tags |