FileDocCategorySizeDatePackage
ProcessWatcher.javaAPI DocGlassfish v2 API3342Fri May 04 22:34:32 BST 2007com.sun.enterprise.deployment.backend

ProcessWatcher

public class ProcessWatcher extends Object
Workaround for now for the lack of APIs to access wsgen and wsimport utilities
author
Jerome Dochez

Fields Summary
Process
toWatch
Constructors Summary
public ProcessWatcher(Process p)
Creates a new instance of ProcessWatcher

    
           
       
        toWatch = p;
    
Methods Summary
public voiddump(java.io.InputStream is)

        if (is.available()>0) {
            byte[] bytes = new byte[is.available()];
            is.read(bytes, 0, bytes.length);
            System.out.println(new String(bytes));
        }
    
public intwatch()

        InputStream input = toWatch.getInputStream();
        InputStream error = toWatch.getErrorStream();
        boolean notDone = true;
        do {
            try {
                while (input.available()>0) {
                    dump(input);
                }
                while (error.available()>0) {
                    dump(error);
                }
            } catch(IOException e) {
                
            }
            try {
                toWatch.exitValue();
                notDone = false;
            } catch(IllegalThreadStateException e) {
            }            
        } while (notDone);
        return toWatch.exitValue();