| Home >> All >> org >> mitre >> [ cvw Javadoc ] |
Source code: org/mitre/cvw/AdminProc.java
1 /* 2 * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/). 3 * All rights reserved. 4 * CVW comes with ABSOLUTELY NO WARRANTY. See license for details. 5 */ 6 7 package org.mitre.cvw; 8 9 import java.net.*; 10 import java.io.*; 11 import java.util.*; 12 13 /** 14 * CLASS DESCRIPTION 15 * This is a thread to launch the external Admin Tool 16 * @version 17 * @author unascribed 18 */ 19 public class AdminProc extends Thread { 20 CVWAdminTool at; 21 String[] args; 22 23 /** 24 * FUNCTION DESCRIPTION 25 * @return 26 */ 27 public AdminProc(CVWAdminTool at, String[] cmd) { 28 29 super("AdminProc"); 30 31 this.at = at; 32 args = cmd; 33 } 34 35 /** 36 * FUNCTION DESCRIPTION 37 */ 38 public void run() { 39 at.debugMsg("AdminProc:run() inital args: " + args[0] +" "+ args[1] +" "+ args[2] +" "+ args[3]); 40 41 if (args != null && args.length == 4) { 42 try { 43 Process child = Runtime.getRuntime().exec(args); 44 InputStream is = child.getInputStream(); 45 int c; 46 while ((c = is.read()) != -1) { 47 //System.out.print((char)c); 48 ; 49 } 50 is.close(); 51 //Wait for subprocess to close 52 try { 53 child.waitFor(); 54 } catch (InterruptedException e) { 55 at.errorMsg( 56 "AdminProc::run() InterruptedException , " 57 + e.getMessage()); 58 } 59 at.msg("EXITED " + child.exitValue()); 60 61 } catch (IOException e) { 62 at.errorMsg( 63 "AdminProc::run() IOException -- error launching admintool executable. "+ e.getMessage()); 64 at.msg("EXITED -2"); 65 } 66 } else { 67 at.errorMsg( 68 "AdminProc::run() -- improper args for Admin Tool."); 69 at.msg("EXITED -2"); 70 return; 71 } 72 } 73 74 private void stub(String msg) { 75 if (CVWCoordinator.DEBUG) System.out.println("*** STUB: " + msg); 76 } 77 78 }