You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2011/07/08 05:11:22 UTC
svn commit: r1144136 - in
/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main:
LongStartupMonitor.java ProgressBarStartupMonitor.java
SimpleProgressBarStartupMonitor.java
Author: xuhaihong
Date: Fri Jul 8 03:11:21 2011
New Revision: 1144136
URL: http://svn.apache.org/viewvc?rev=1144136&view=rev
Log:
1. Replace stringbuffer with stringbuilder
2. Update max_width to 110, now I could see the current operation component while using geronimo run to start the server
Modified:
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/LongStartupMonitor.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/SimpleProgressBarStartupMonitor.java
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/LongStartupMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/LongStartupMonitor.java?rev=1144136&r1=1144135&r2=1144136&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/LongStartupMonitor.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/LongStartupMonitor.java Fri Jul 8 03:11:21 2011
@@ -67,7 +67,7 @@ public class LongStartupMonitor implemen
* Length of longest module name
*/
private int longestModuleNameLength;
-
+
/**
* Time Geronimo was started
*/
@@ -95,7 +95,7 @@ public class LongStartupMonitor implemen
public synchronized void foundModules(Artifact[] modules) {
numModules = modules.length;
numModulesDigits = Integer.toString(numModules).length();
-
+
for (int i = 0, len= 0; i < modules.length; i++) {
len = modules[i].toString().length();
if (len > longestModuleNameLength)
@@ -104,7 +104,7 @@ public class LongStartupMonitor implemen
}
public synchronized void moduleLoading(Artifact module) {
- StringBuffer buf = new StringBuffer("Module ");
+ StringBuilder buf = new StringBuilder("Module ");
// pad module index
int configIndexDigits = Integer.toString(++moduleNum).length();
for (; configIndexDigits < numModulesDigits; configIndexDigits++) {
@@ -130,27 +130,27 @@ public class LongStartupMonitor implemen
}
public synchronized void moduleStarted(Artifact module) {
- long time = System.currentTimeMillis() - moduleStarted;
- StringBuffer buf = new StringBuffer();
+ long time = System.currentTimeMillis() - moduleStarted;
+ StringBuilder buf = new StringBuilder();
buf.append(" started in ");
-
+
String formattedTime = getFormattedTime(time);
if (formattedTime.startsWith("0.")) {
// don't display zero seconds
formattedTime = " " +formattedTime.substring(1);
}
-
+
// if first number (e.g. seconds or minutes) is one digit,
// pad it with a leading space to get times to line up nicely
int index = formattedTime.indexOf(':'); // must look for colon first
if (index == -1)
index = formattedTime.indexOf('.');
-
+
if (index == 1)
buf.append(' ');
-
+
buf.append(formattedTime);
-
+
out.println(buf.toString());
}
@@ -166,7 +166,7 @@ public class LongStartupMonitor implemen
problem.printStackTrace(out);
}
- // time formatting method - thanks to Maven
+ // time formatting method - thanks to Maven
private static String getFormattedTime( long time )
{
String pattern = "s.SSS's'";
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java?rev=1144136&r1=1144135&r2=1144136&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java Fri Jul 8 03:11:21 2011
@@ -100,7 +100,7 @@ public class ProgressBarStartupMonitor i
break;
}
}
- percent += Math.round(90f * (float) progress / (float) total);
+ percent += Math.round(90f * progress / total);
this.percent = percent;
}
@@ -166,7 +166,7 @@ public class ProgressBarStartupMonitor i
buf.append(' ');
}
buf.append(percent).append("% ");
- int time = Math.round((float) (System.currentTimeMillis() - started) / 1000f);
+ int time = Math.round((System.currentTimeMillis() - started) / 1000f);
if (time < 10) {
buf.append(' ');
}
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/SimpleProgressBarStartupMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/SimpleProgressBarStartupMonitor.java?rev=1144136&r1=1144135&r2=1144136&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/SimpleProgressBarStartupMonitor.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/SimpleProgressBarStartupMonitor.java Fri Jul 8 03:11:21 2011
@@ -29,7 +29,7 @@ import org.apache.geronimo.system.server
* number of lines output to the terminal.
* <p/>
* This implementation displays a fixed-size bar.
- * <p/>
+ * <p/>
* A summary will also be produced containing a list of ports
* Geronimo is listening on, the configIds of application modules
* that were started and the context roots of Web applications that were started.
@@ -42,7 +42,7 @@ public class SimpleProgressBarStartupMon
private final static char STATUS_LOADED = '>';
private final static char STATUS_STARTED = '*';
private final static char STATUS_FAILED = 'x';
- private final static int MAX_WIDTH = 79;
+ private final static int MAX_WIDTH = 110;
private PrintStream out;
private String currentOperation;
private Artifact[] modules;
@@ -53,7 +53,7 @@ public class SimpleProgressBarStartupMon
private int operationLimit = 50;
private boolean finished = false;
private UpdateThread thread;
-
+
private int barSize = 40;
private int barProgress;
@@ -106,7 +106,7 @@ public class SimpleProgressBarStartupMon
break;
}
}
- percent += Math.round(95f * (float) progress / (float) total);
+ percent += Math.round(95f * progress / total);
this.percent = percent;
this.barProgress = (this.barSize * this.percent) / 100;
}
@@ -164,15 +164,15 @@ public class SimpleProgressBarStartupMon
}
private synchronized void repaint() {
- StringBuffer buf = new StringBuffer();
- buf.append("\r[");
+ StringBuilder buf = new StringBuilder();
+ buf.append("\r[");
for (int i = 0; i < barSize; i++) {
if (i < barProgress) {
buf.append("*");
} else {
buf.append(" ");
}
- }
+ }
buf.append("] ");
if (percent < 10) {
buf.append(" ");
@@ -180,7 +180,7 @@ public class SimpleProgressBarStartupMon
buf.append(" ");
}
buf.append(percent).append("% ");
- int time = Math.round((float) (System.currentTimeMillis() - started) / 1000f);
+ int time = Math.round((System.currentTimeMillis() - started) / 1000f);
if (time < 10) {
buf.append(' ');
}