From 7b09f76c7501f692657385025ccb10be5d974c7a Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 10 Jul 2007 20:30:09 +0000
Subject: [PATCH] Update all of the tools provided with OpenDS to ensure that they are easier to invoke programmatically. This includes:
---
opends/src/server/org/opends/server/loggers/TextWriter.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/loggers/TextWriter.java b/opends/src/server/org/opends/server/loggers/TextWriter.java
index eb33715..3856072 100644
--- a/opends/src/server/org/opends/server/loggers/TextWriter.java
+++ b/opends/src/server/org/opends/server/loggers/TextWriter.java
@@ -26,6 +26,7 @@
*/
package org.opends.server.loggers;
+import java.io.OutputStream;
import java.io.PrintWriter;
/**
@@ -139,4 +140,56 @@
return stream.written;
}
}
+
+ /**
+ * A TextWriter implementation which writes to a given output stream.
+ */
+ public class STREAM implements TextWriter
+ {
+ private MeteredStream stream;
+ private PrintWriter writer;
+
+ /**
+ * Creates a new text writer that will write to the provided output stream.
+ *
+ * @param outputStream The output stream to which
+ */
+ public STREAM(OutputStream outputStream)
+ {
+ stream = new MeteredStream(outputStream, 0);
+ writer = new PrintWriter(stream, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeRecord(String record)
+ {
+ writer.println(record);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void flush()
+ {
+ writer.flush();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void shutdown()
+ {
+ // Should never close the system error stream.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getBytesWritten()
+ {
+ return stream.written;
+ }
+ }
}
--
Gitblit v1.10.0