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