001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.process;
016    
017    import com.liferay.portal.kernel.util.StreamUtil;
018    
019    import java.io.IOException;
020    import java.io.InputStream;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class EchoOutputProcessor implements OutputProcessor<Void, Void> {
026    
027            @Override
028            public Void processStdErr(InputStream stdErrInputStream)
029                    throws ProcessException {
030    
031                    try {
032                            StreamUtil.transfer(stdErrInputStream, System.err, false);
033                    }
034                    catch (IOException ioe) {
035                            throw new ProcessException(ioe);
036                    }
037    
038                    return null;
039            }
040    
041            @Override
042            public Void processStdOut(InputStream stdOutInputStream)
043                    throws ProcessException {
044    
045                    try {
046                            StreamUtil.transfer(stdOutInputStream, System.out, false);
047                    }
048                    catch (IOException ioe) {
049                            throw new ProcessException(ioe);
050                    }
051    
052                    return null;
053            }
054    
055    }