001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 */ 018 019package org.apache.commons.exec; 020 021import java.io.IOException; 022import java.io.InputStream; 023import java.io.OutputStream; 024 025/** 026 * Used by {@code Execute} to handle input and output stream of 027 * subprocesses. 028 * 029 * @version $Id: ExecuteStreamHandler.java 1636064 2014-11-01 22:01:19Z ggregory $ 030 */ 031public interface ExecuteStreamHandler { 032 033 /** 034 * Install a handler for the input stream of the subprocess. 035 * 036 * @param os 037 * output stream to write to the standard input stream of the subprocess 038 * @throws IOException 039 * thrown when an I/O exception occurs. 040 */ 041 void setProcessInputStream(OutputStream os) throws IOException; 042 043 /** 044 * Install a handler for the error stream of the subprocess. 045 * 046 * @param is 047 * input stream to read from the error stream from the subprocess 048 * @throws IOException 049 * thrown when an I/O exception occurs. 050 */ 051 void setProcessErrorStream(InputStream is) throws IOException; 052 053 /** 054 * Install a handler for the output stream of the subprocess. 055 * 056 * @param is 057 * input stream to read from the error stream from the subprocess 058 * @throws IOException 059 * thrown when an I/O exception occurs. 060 */ 061 void setProcessOutputStream(InputStream is) throws IOException; 062 063 /** 064 * Start handling of the streams. 065 * 066 * @throws IOException 067 * thrown when an I/O exception occurs. 068 */ 069 void start() throws IOException; 070 071 /** 072 * Stop handling of the streams - will not be restarted. Will wait for pump threads to complete. 073 * 074 * @throws IOException 075 * thrown when an I/O exception occurs. 076 */ 077 void stop() throws IOException; 078}