You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/10/17 15:28:46 UTC
svn commit: r705608 - in
/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io:
Closer.java Flusher.java IO.java PumpStreamHandler.java StreamPair.java
StreamPumper.java
Author: jdillon
Date: Fri Oct 17 06:28:45 2008
New Revision: 705608
URL: http://svn.apache.org/viewvc?rev=705608&view=rev
Log:
Added Closer and Flusher
Added:
geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java (with props)
geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java (with props)
Modified:
geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/IO.java
geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/PumpStreamHandler.java
geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPair.java
geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPumper.java
Added: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java?rev=705608&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java Fri Oct 17 06:28:45 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.io;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * Quietly closes {@link Closeable}s.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Closer
+{
+ public static void close(final Closeable... closeables) {
+ if (closeables != null) {
+ for (Closeable c : closeables) {
+ try {
+ c.close();
+ }
+ catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Closer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java?rev=705608&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java Fri Oct 17 06:28:45 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.io;
+
+import java.io.Flushable;
+import java.io.IOException;
+
+/**
+ * Quietly flushes {@link Flushable}s.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Flusher
+{
+ public static void flush(final Flushable... flushable) {
+ if (flushable != null) {
+ for (Flushable f : flushable) {
+ try {
+ f.flush();
+ }
+ catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/Flusher.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/IO.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/IO.java?rev=705608&r1=705607&r2=705608&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/IO.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/IO.java Fri Oct 17 06:28:45 2008
@@ -23,7 +23,6 @@
import jline.ConsoleReader;
import org.apache.geronimo.gshell.ansi.RenderWriter;
import org.apache.geronimo.gshell.yarn.Yarn;
-import org.codehaus.plexus.util.IOUtil;
import org.slf4j.helpers.MessageFormatter;
import java.io.IOException;
@@ -249,11 +248,11 @@
* Flush both output streams.
*/
public void flush() {
- out.flush();
+ Flusher.flush(out);
// Only attempt to flush the err stream if we aren't sharing it with out
if (!isSharedOutputStreams()) {
- err.flush();
+ Flusher.flush(err);
}
}
@@ -261,12 +260,11 @@
* Close all streams.
*/
public void close() throws IOException {
- IOUtil.close(in);
- IOUtil.close(out);
+ Closer.close(in, out);
// Only attempt to close the err stream if we aren't sharing it with out
if (!isSharedOutputStreams()) {
- IOUtil.close(err);
+ Closer.close(err);
}
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/PumpStreamHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/PumpStreamHandler.java?rev=705608&r1=705607&r2=705608&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/PumpStreamHandler.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/PumpStreamHandler.java Fri Oct 17 06:28:45 2008
@@ -19,12 +19,9 @@
package org.apache.geronimo.gshell.io;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.codehaus.plexus.util.IOUtil;
-
//
// Based on Apache Ant 1.6.5
//
@@ -100,7 +97,7 @@
inputPump = createInputPump(in, out, true);
}
else {
- IOUtil.close(out);
+ Closer.close(out);
}
}
@@ -161,19 +158,7 @@
inputPump.stop();
}
- try {
- err.flush();
- }
- catch (IOException e) {
- // ignore
- }
-
- try {
- out.flush();
- }
- catch (IOException e) {
- // ignore
- }
+ Flusher.flush(err, out);
}
/**
Modified: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPair.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPair.java?rev=705608&r1=705607&r2=705608&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPair.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPair.java Fri Oct 17 06:28:45 2008
@@ -64,18 +64,18 @@
}
public void flush() {
- out.flush();
-
+ Flusher.flush(out);
+
if (!combined) {
- err.flush();
+ Flusher.flush(err);
}
}
public void close() {
- out.close();
-
+ Closer.close(out);
+
if (!combined) {
- err.close();
+ Closer.close(err);
}
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPumper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPumper.java?rev=705608&r1=705607&r2=705608&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPumper.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-io/src/main/java/org/apache/geronimo/gshell/io/StreamPumper.java Fri Oct 17 06:28:45 2008
@@ -22,8 +22,6 @@
import java.io.InputStream;
import java.io.OutputStream;
-import org.codehaus.plexus.util.IOUtil;
-
//
// Based on Apache Ant 1.6.5
//
@@ -121,7 +119,7 @@
}
finally {
if (closeWhenExhausted) {
- IOUtil.close(out);
+ Closer.close(out);
}
finished = true;