1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.exec; 19 20 import java.io.IOException; 21 import java.io.InputStream; 22 import java.io.OutputStream; 23 24 /** 25 * Handles stream of subprocesses for {@link Executor}s. 26 */ 27 public interface ExecuteStreamHandler { 28 29 /** 30 * Sets a handler for the error stream of the subprocess. 31 * 32 * @param inputStream input stream to read from the error stream from the subprocess. 33 * @throws IOException thrown when an I/O exception occurs. 34 */ 35 void setProcessErrorStream(InputStream inputStream) throws IOException; 36 37 /** 38 * Sets a handler for the input stream of the subprocess. 39 * 40 * @param outputStream output stream to write to the standard input stream of the subprocess. 41 * @throws IOException thrown when an I/O exception occurs. 42 */ 43 void setProcessInputStream(OutputStream outputStream) throws IOException; 44 45 /** 46 * Sets a handler for the output stream of the subprocess. 47 * 48 * @param inputStream input stream to read from the error stream from the subprocess. 49 * @throws IOException thrown when an I/O exception occurs. 50 */ 51 void setProcessOutputStream(InputStream inputStream) throws IOException; 52 53 /** 54 * Starts handling of the streams. 55 * 56 * @throws IOException thrown when an I/O exception occurs. 57 */ 58 void start() throws IOException; 59 60 /** 61 * Stops handling of the streams - will not be restarted. Will wait for pump threads to complete. 62 * 63 * @throws IOException thrown when an I/O exception occurs. 64 */ 65 void stop() throws IOException; 66 }