You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/04/03 11:10:09 UTC
[10/15] james-project git commit: JAMES-1982 Cli should not double
output
JAMES-1982 Cli should not double output
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b547e70f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b547e70f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b547e70f
Branch: refs/heads/master
Commit: b547e70f38390b8e865470348089771a87716984
Parents: 4321bcc
Author: benwa <bt...@linagora.com>
Authored: Sat Apr 1 10:25:45 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon Apr 3 18:09:32 2017 +0700
----------------------------------------------------------------------
.../java/org/apache/james/cli/ServerCmd.java | 39 ++++++++++----------
1 file changed, 19 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b547e70f/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
----------------------------------------------------------------------
diff --git a/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java b/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
index 402b0d2..af882ed 100644
--- a/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
+++ b/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
@@ -86,24 +86,8 @@ public class ServerCmd {
* @param args Command-line arguments.
*/
public static void main(String[] args) {
-
try {
- StopWatch stopWatch = new StopWatch();
- stopWatch.start();
- CommandLine cmd = parseCommandLine(args);
- JmxConnection jmxConnection = new JmxConnection(cmd.getOptionValue(HOST_OPT_LONG), getPort(cmd));
- CmdType cmdType = new ServerCmd(
- new JmxDataProbe().connect(jmxConnection),
- new JmxMailboxProbe().connect(jmxConnection),
- new JmxQuotaProbe().connect(jmxConnection),
- new JmxSieveProbe().connect(jmxConnection)
- )
- .executeCommandLine(cmd);
- stopWatch.split();
- print(new String[] { Joiner.on(' ')
- .join(cmdType.getCommand(), "command executed sucessfully in", stopWatch.getSplitTime(), "ms.")},
- System.out);
- stopWatch.stop();
+ doMain(args);
System.exit(0);
} catch (JamesCliException e) {
failWithMessage(e.getMessage());
@@ -115,7 +99,25 @@ public class ServerCmd {
LOG.error("Error on command: {}", e);
failWithMessage("Error " + e.getClass() + " while executing command:" + e.getMessage());
}
+ }
+ public static void doMain(String[] args) throws Exception {
+ StopWatch stopWatch = new StopWatch();
+ stopWatch.start();
+ CommandLine cmd = parseCommandLine(args);
+ JmxConnection jmxConnection = new JmxConnection(cmd.getOptionValue(HOST_OPT_LONG), getPort(cmd));
+ CmdType cmdType = new ServerCmd(
+ new JmxDataProbe().connect(jmxConnection),
+ new JmxMailboxProbe().connect(jmxConnection),
+ new JmxQuotaProbe().connect(jmxConnection),
+ new JmxSieveProbe().connect(jmxConnection)
+ )
+ .executeCommandLine(cmd);
+ stopWatch.split();
+ print(new String[] { Joiner.on(' ')
+ .join(cmdType.getCommand(), "command executed sucessfully in", stopWatch.getSplitTime(), "ms.")},
+ System.out);
+ stopWatch.stop();
}
private final DataProbe probe;
@@ -321,9 +323,6 @@ public class ServerCmd {
private static void print(Iterable<String> data, PrintStream out) {
if (data != null) {
- for (String u : data) {
- out.println(u);
- }
out.println(Joiner.on('\n').join(data));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org