/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ProcessExecutor.java,v 1.1 2008/11/22 02:19:58 ak138937 Exp $
*
*/
public class ProcessExecutor {
private boolean canDeleteOutputFile = true;
private boolean canDeleteErrorFile = true;
/**
* Creates new ProcessExecutor
*/
}
/**
* Creates new ProcessExecutor
*/
}
/**
* Creates new ProcessExecutor
*/
}
/**
* Creates a new <code> ProcessExecutor </code> that executes the given
* command.
*
* @param cmd String that has command name and its command line arguments
* @param timeoutSeconds long integer timeout to be applied in seconds.
* After this time if the process to execute does not end, it will
* be destroyed.
*/
public ProcessExecutor(
long timeoutSeconds,
) {
mCmdStrings = cmd;
char fwdSlashChar = '/';
char backSlashChar = '\\';
if (!isWindows()) {
mCmdStrings[i] =
} else {
mCmdStrings[i] =
}
}
}
private boolean getDeleteOutFilePolicy(){
return canDeleteOutputFile;
}
private boolean getDeleteErrFilePolicy(){
return canDeleteErrorFile;
}
boolean deletePolicy
) {
try {
} else{
}
} catch(IOException ioex) {
}
return retval;
}
private void init() {
try {
} catch (IllegalArgumentException iae){
}
}
private boolean isWindows(){
if (indx == -1) {
return false;
} else {
return true;
}
}
private void deleteTempFiles(){
}
public void execute() {
execute(false);
}
boolean bReturnOutputLines,
boolean exceptionOnNonZeroExitVal
) {
init();
try {
if(mInputLines != null)
if (!bReturnOutputLines) {
} else {
}
boolean timeoutReached = false;
boolean isSubProcessFinished = false;
boolean shouldBeDone = false;
if (bReturnOutputLines) {
}
while (! shouldBeDone) {
try {
isSubProcessFinished = true;
break;
} catch(IllegalThreadStateException itse) {
isSubProcessFinished = false;
//ignore exception
}
}
if (!isSubProcessFinished) {
mExitValue = -255;
} else {
if (mExitValue != 0) {
/* read the error message from error file */
if (!exceptionOnNonZeroExitVal) {
return cmdOp;
}
}
if (bReturnOutputLines) {
//inputStream = getRedirectedProcessOutputHandle();
return cmdOp;
} else {
return null;
}
}
} catch(SecurityException se) {
return null;
} catch(IOException ioe) {
return null;
} finally {
}
return cmdOp;
}
/**
* Executes the command.
*
* @return An array containing the output of the command
*/
boolean bReturnOutputLines,
boolean exceptionOnNonZeroExitVal
) {
init();
try {
if (mInputLines != null)
if (!bReturnOutputLines) {
} else {
}
boolean timeoutReached = false;
boolean isSubProcessFinished = false;
boolean shouldBeDone = false;
if (bReturnOutputLines) {
}
while (! shouldBeDone) {
try {
isSubProcessFinished = true;
break;
} catch(IllegalThreadStateException itse) {
isSubProcessFinished = false;
//ignore exception
}
}
if (!isSubProcessFinished) {
mExitValue = -255;
return null;
} else {
if (mExitValue != 0) {
/* read the error message from error file */
return cmdOp;
}
}
if (bReturnOutputLines) {
return cmdOp;
} else {
return null;
}
}
} catch(SecurityException se) {
return null;
} catch(IOException ioe) {
return null;
} finally {
}
}
return execute(bReturnOutputLines,true);
}
if (mInputLines == null) {
return;
}
try {
out = new PrintWriter(
new BufferedWriter(
}
} catch (Exception e) {
//do nothing
} finally {
try {
} catch (Throwable t) {
}
}
}
if (inputStream==null) {
return null;
}
try {
}
return null;
}
} catch (Exception e) {
return null;
} finally {
try {
} catch (Throwable t) {
}
}
}
try {
} catch (Exception e) {
//ignore exception
}
}
try {
} catch (Exception e) {
//ignore exception
}
}
try {
} catch(InterruptedException ie) {
//ignore exception
}
}
/**
* Returns the contents of a file as a String. If the file is empty,
* an empty string is returned.
*
* @param file the file to read
* @return String containing the file contents
*/
try {
}
} catch(Exception e) {
//ignore exception
} finally {
try {
} catch(Exception e) {}
}
}
}
}
public void run() {
try {
int ch;
}
} catch(IOException ioe) {
//ignore exception
} finally {
try {
mOutStream.flush();
mOutStream.close();
} catch(IOException e) {
//ignore exception
}
}
}
}