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
018package org.apache.commons.exec;
019
020import java.io.IOException;
021import java.io.InputStream;
022import java.io.OutputStream;
023
024/**
025 * Handles stream of subprocesses for {@link Executor}s.
026 */
027public interface ExecuteStreamHandler {
028
029    /**
030     * Sets a handler for the error stream of the subprocess.
031     *
032     * @param inputStream input stream to read from the error stream from the subprocess.
033     * @throws IOException thrown when an I/O exception occurs.
034     */
035    void setProcessErrorStream(InputStream inputStream) throws IOException;
036
037    /**
038     * Sets a handler for the input stream of the subprocess.
039     *
040     * @param outputStream output stream to write to the standard input stream of the subprocess.
041     * @throws IOException thrown when an I/O exception occurs.
042     */
043    void setProcessInputStream(OutputStream outputStream) throws IOException;
044
045    /**
046     * Sets a handler for the output stream of the subprocess.
047     *
048     * @param inputStream input stream to read from the error stream from the subprocess.
049     * @throws IOException thrown when an I/O exception occurs.
050     */
051    void setProcessOutputStream(InputStream inputStream) throws IOException;
052
053    /**
054     * Starts handling of the streams.
055     *
056     * @throws IOException thrown when an I/O exception occurs.
057     */
058    void start() throws IOException;
059
060    /**
061     * Stops handling of the streams - will not be restarted. Will wait for pump threads to complete.
062     *
063     * @throws IOException thrown when an I/O exception occurs.
064     */
065    void stop() throws IOException;
066}