From ff7c11c7448af13047040206ea352a0b2a1b0b47 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 6 Jan 2002 01:37:25 +0000 Subject: [PATCH] Added the ExecOutputHandler abstraction so that tasks don't have to worry about more complicated stream parsing and can work with just notification of lines appearing. Also added a default implementation that conforms to the most common pattern of making stdout info log messages and stderr warn log messages git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270550 13f79535-47bb-0310-9956-ffa450edef68 --- .../exec/DefaultExecOutputHandler.java | 40 +++++++++++++++++++ .../framework/exec/ExecOutputHandler.java | 30 ++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/DefaultExecOutputHandler.java create mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecOutputHandler.java diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/DefaultExecOutputHandler.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/DefaultExecOutputHandler.java new file mode 100644 index 000000000..ca18c7e07 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/DefaultExecOutputHandler.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.myrmidon.framework.exec; + +import org.apache.avalon.framework.logger.AbstractLogEnabled; + +/** + * This class is used to receive notifications of what the native + * process outputs to standard output and standard error. + * + * @author Peter Donald + * @version $Revision$ $Date$ + */ +public class DefaultExecOutputHandler + extends AbstractLogEnabled + implements ExecOutputHandler +{ + /** + * Receive notification about the process writing + * to standard output. + */ + public void stdout( final String line ) + { + getLogger().info( line ); + } + + /** + * Receive notification about the process writing + * to standard error. + */ + public void stderr( final String line ) + { + getLogger().warn( line ); + } +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecOutputHandler.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecOutputHandler.java new file mode 100644 index 000000000..3094c5a5e --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecOutputHandler.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.myrmidon.framework.exec; + +/** + * This class is used to receive notifications of what the native + * process outputs to standard output and standard error. + * + * @author Peter Donald + * @version $Revision$ $Date$ + */ +public interface ExecOutputHandler +{ + /** + * Receive notification about the process writing + * to standard output. + */ + void stdout( String line ); + + /** + * Receive notification about the process writing + * to standard error. + */ + void stderr( String line ); +}