1 package org.jacorb.test.common.launch; 2 3 23 24 import java.util.*; 25 import java.io.*; 26 27 34 public class DirectLauncher extends JacORBLauncher 35 { 36 public DirectLauncher(String jacorbHome, boolean coverage) 37 { 38 super(jacorbHome, coverage); 39 } 40 41 public Process launch(String classpath, 42 Properties props, 43 String mainClass, 44 String [] args) 45 { 46 Runtime rt = Runtime.getRuntime(); 47 48 List cmdList = new ArrayList(); 49 50 String javaHome = System.getProperty("java.home"); 51 String javaCommand = javaHome + "/bin/java"; 52 cmdList.add (javaCommand); 53 cmdList.add ("-classpath"); 54 cmdList.add (classpath + ":" + getJacORBLibraryPath()); 55 cmdList.add ("-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB"); 56 cmdList.add ("-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton"); 57 cmdList.addAll (propsToArgList(props)); 58 cmdList.add ("-Djacorb.home=" + jacorbHome); 59 cmdList.add (mainClass); 60 cmdList.addAll (Arrays.asList(args)); 61 62 String [] envp = new String [] 63 { 64 "JACORB_HOME=" + jacorbHome 65 }; 66 67 try 68 { 69 String [] cmd = toStringArray(cmdList); 70 return rt.exec (cmd, envp); 78 } 79 catch (IOException ex) 80 { 81 throw new RuntimeException (ex); 82 } 83 } 84 85 public String getJacORBLibraryPath() 86 { 87 return getJacORBPath() + ":" 88 + jacorbHome + "/lib/logkit-1.2.jar:" 89 + jacorbHome + "/lib/avalon-framework-4.1.5.jar:" 90 + jacorbHome + "/lib/concurrent-1.3.2.jar:" 91 + jacorbHome + "/lib/antlr-2.7.2.jar:" 92 + jacorbHome + "/lib/picocontainer-1.2-021105.jar"; 93 } 94 95 public String getJacORBPath() 96 { 97 File result = null; 98 if (coverage) 99 { 100 result = new File (jacorbHome, "classes-instrumented"); 101 if (!result.exists()) 102 System.out.println ("WARNING: JacORB installation " 103 + jacorbHome 104 + " is not instrumented; coverage " 105 + " will not be available"); 106 else 107 return result.toString() + ":" 108 + jacorbHome + "/classes:" 109 + jacorbHome + "/test/regression/lib/emma.jar"; 110 } 111 result = new File (jacorbHome, "classes/org"); 112 if (result.exists()) 113 return new File (jacorbHome, "classes").toString(); 114 else 115 return new File (jacorbHome, "lib/jacorb.jar").toString(); 116 } 117 } 118 | Popular Tags |