From 8684c89c1cdf8f9b2650688f2ac7d3b8ea48ac29 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 27 Aug 2007 08:37:44 +0000
Subject: [PATCH] Fix for issue 2167.
---
opends/src/quicksetup/org/opends/quicksetup/Application.java | 69 ++++++++++++++++++++++++++++++----
1 files changed, 61 insertions(+), 8 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opends/src/quicksetup/org/opends/quicksetup/Application.java
index 20e604e..8e517ed 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -83,6 +83,9 @@
/** Handler for listeners and event firing. */
protected ProgressUpdateListenerDelegate listenerDelegate;
+ private ErrorPrintStream err = new ErrorPrintStream();
+ private OutputPrintStream out = new OutputPrintStream();
+
/**
* Creates an application by instantiating the Application class
* denoted by the System property
@@ -725,6 +728,27 @@
}
/**
+ * Returns the error stream to be used by the application when launching
+ * command lines.
+ * @return the error stream to be used by the application when launching
+ * command lines.
+ */
+ protected ErrorPrintStream getApplicationErrorStream()
+ {
+ return err;
+ }
+
+ /**
+ * Returns the output stream to be used by the application when launching
+ * command lines.
+ * @return the output stream to be used by the application when launching
+ * command lines.
+ */
+ protected OutputPrintStream getApplicationOutputStream()
+ {
+ return out;
+ }
+ /**
* This class is used to notify the ProgressUpdateListeners of events
* that are written to the standard error. It is used in WebStartInstaller
* and in OfflineInstaller. These classes just create a ErrorPrintStream and
@@ -791,6 +815,8 @@
private boolean isFirstLine;
+ private boolean notifyListeners = true;
+
/**
* Format a string before sending a listener notification.
* @param string to format
@@ -814,16 +840,21 @@
@Override
public void println(String msg)
{
- MessageBuilder mb = new MessageBuilder();
- if (isFirstLine)
+ if (notifyListeners)
{
- mb.append(formatString(msg));
- } else
- {
- mb.append(formatter.getLineBreak());
- mb.append(formatString(msg));
+ MessageBuilder mb = new MessageBuilder();
+ if (isFirstLine)
+ {
+ mb.append(formatString(msg));
+ } else
+ {
+ mb.append(formatter.getLineBreak());
+ mb.append(formatString(msg));
+ }
+
+ notifyListeners(mb.toMessage());
}
- notifyListeners(mb.toMessage());
+ LOG.log(Level.INFO, "server: " + msg);
isFirstLine = false;
}
@@ -845,5 +876,27 @@
}
println(new String(b, off, len));
}
+
+ /**
+ * Notifies the progress update listeners of the application of the message
+ * we received.
+ * @return <CODE>true</CODE> if we must notify the application listeners
+ * of the message and <CODE>false</CODE> otherwise.
+ */
+ public boolean isNotifyListeners()
+ {
+ return notifyListeners;
+ }
+
+ /**
+ * Tells whether we must notify the listeners or not of the message
+ * received.
+ * @param notifyListeners the boolean that informs of whether we have
+ * to notify the listeners or not.
+ */
+ public void setNotifyListeners(boolean notifyListeners)
+ {
+ this.notifyListeners = notifyListeners;
+ }
}
}
--
Gitblit v1.10.0